Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Oct 17, 2023
2 parents 6b5c393 + d0ea2a5 commit a23e667
Show file tree
Hide file tree
Showing 74 changed files with 1,147 additions and 554 deletions.
15 changes: 15 additions & 0 deletions make/hotspot/gensrc/GensrcAdlc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ ifeq ($(call check-jvm-feature, compiler2), true)
ADLCFLAGS += -DARM=1
endif

# Set ASSERT, NDEBUG and PRODUCT flags just like in JvmFlags.gmk
ifeq ($(DEBUG_LEVEL), release)
# release builds disable uses of assert macro from <assert.h>.
ADLCFLAGS += -DNDEBUG
# For hotspot, release builds differ internally between "optimized" and "product"
# in that "optimize" does not define PRODUCT.
ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
ADLCFLAGS += -DPRODUCT
endif
else ifeq ($(DEBUG_LEVEL), fastdebug)
ADLCFLAGS += -DASSERT
else ifeq ($(DEBUG_LEVEL), slowdebug)
ADLCFLAGS += -DASSERT
endif

##############################################################################
# Concatenate all ad source files into a single file, which will be fed to
# adlc. Also include a #line directive at the start of every included file
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/frame_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@

frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);

frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb);
frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb, bool allow_cb_null = false);
// used for fast frame construction by continuations
frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb, const ImmutableOopMap* oop_map, bool on_heap);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
init(sp, fp, pc);
}

inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb) {
inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb, bool allow_cb_null) {
assert(pauth_ptr_is_raw(pc), "cannot be signed");
intptr_t a = intptr_t(sp);
intptr_t b = intptr_t(fp);
Expand All @@ -102,7 +102,7 @@ inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address
assert(pc != nullptr, "no pc?");
_cb = cb;
_oop_map = nullptr;
assert(_cb != nullptr, "pc: " INTPTR_FORMAT, p2i(pc));
assert(_cb != nullptr || allow_cb_null, "pc: " INTPTR_FORMAT, p2i(pc));
_on_heap = false;
DEBUG_ONLY(_frame_index = -1;)

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ frame os::fetch_compiled_frame_from_context(const void* ucVoid) {

// JVM compiled with -fno-omit-frame-pointer, so RFP is saved on the stack.
frame os::get_sender_for_C_frame(frame* fr) {
return frame(fr->link(), fr->link(), fr->sender_pc());
return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
}

NOINLINE frame os::current_frame() {
Expand Down
17 changes: 16 additions & 1 deletion src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,23 @@ frame os::fetch_compiled_frame_from_context(const void* ucVoid) {

// By default, gcc always saves frame pointer rfp on this stack. This
// may get turned off by -fomit-frame-pointer.
// The "Procedure Call Standard for the Arm 64-bit Architecture" doesn't
// specify a location for the frame record within a stack frame (6.4.6).
// GCC currently chooses to save it at the top of the frame (lowest address).
// This means that using fr->sender_sp() to set the caller's frame _unextended_sp,
// as we do in x86, is wrong. Using fr->link() instead only makes sense for
// native frames. Setting a correct value for _unextended_sp is important
// if this value is later used to get that frame's caller. This will happen
// if we end up calling frame::sender_for_compiled_frame(), which will be the
// case if the _pc is associated with a CodeBlob that has a _frame_size > 0
// (nmethod, runtime stub, safepoint stub, etc).
frame os::get_sender_for_C_frame(frame* fr) {
return frame(fr->link(), fr->link(), fr->sender_pc());
address pc = fr->sender_pc();
CodeBlob* cb = CodeCache::find_blob(pc);
bool use_codeblob = cb != nullptr && cb->frame_size() > 0;
assert(!use_codeblob || !Interpreter::contains(pc), "should not be an interpreter frame");
intptr_t* sender_sp = use_codeblob ? (fr->link() + frame::metadata_words - cb->frame_size()) : fr->link();
return frame(sender_sp, sender_sp, fr->link(), pc, cb, true /* allow_cb_null */);
}

NOINLINE frame os::current_frame() {
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,8 +1700,11 @@ void CompileBroker::wait_for_completion(CompileTask* task) {
bool free_task;
#if INCLUDE_JVMCI
AbstractCompiler* comp = compiler(task->comp_level());
if (comp->is_jvmci() && !task->should_wait_for_compilation()) {
if (!UseJVMCINativeLibrary && comp->is_jvmci() && !task->should_wait_for_compilation()) {
// It may return before compilation is completed.
// Note that libjvmci should not pre-emptively unblock
// a thread waiting for a compilation as it does not call
// Java code and so is not deadlock prone like jarjvmci.
free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread);
} else
#endif
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/gc/shared/space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class Space: public CHeapObj<mtGC> {
virtual void set_bottom(HeapWord* value) { _bottom = value; }
virtual void set_end(HeapWord* value) { _end = value; }

virtual HeapWord* saved_mark_word() const { return _saved_mark_word; }
HeapWord* saved_mark_word() const { return _saved_mark_word; }

void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; }

// Returns true if this object has been allocated since a
// generation's "save_marks" call.
virtual bool obj_allocated_since_save_marks(const oop obj) const {
bool obj_allocated_since_save_marks(const oop obj) const {
return cast_from_oop<HeapWord*>(obj) >= saved_mark_word();
}

Expand Down Expand Up @@ -178,7 +178,7 @@ class Space: public CHeapObj<mtGC> {
// structure supporting these calls, possibly speeding up future calls.
// The default implementation, however, is simply to call the const
// version.
virtual HeapWord* block_start(const void* p);
HeapWord* block_start(const void* p);

// Requires "addr" to be the start of a chunk, and returns its size.
// "addr + size" is required to be the start of a new chunk, or the end
Expand All @@ -191,7 +191,7 @@ class Space: public CHeapObj<mtGC> {

// Requires "addr" to be the start of a block, and returns "TRUE" iff
// the block is an object and the object is alive.
virtual bool obj_is_alive(const HeapWord* addr) const;
bool obj_is_alive(const HeapWord* addr) const;

// Allocation (return null if full). Assumes the caller has established
// mutually exclusive access to the space.
Expand All @@ -206,10 +206,10 @@ class Space: public CHeapObj<mtGC> {
virtual void adjust_pointers() = 0;
#endif

virtual void print() const;
void print() const;
virtual void print_on(outputStream* st) const;
virtual void print_short() const;
virtual void print_short_on(outputStream* st) const;
void print_short() const;
void print_short_on(outputStream* st) const;

// Debugging
virtual void verify() const = 0;
Expand Down
35 changes: 21 additions & 14 deletions src/hotspot/share/runtime/basicLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,26 @@ void BasicLock::move_to(oop obj, BasicLock* dest) {
// is small (given the support for inflated fast-path locking in the fast_lock, etc)
// we'll leave that optimization for another time.

if (displaced_header().is_neutral()) {
// The object is locked and the resulting ObjectMonitor* will also be
// locked so it can't be async deflated until ownership is dropped.
ObjectSynchronizer::inflate_helper(obj);
// WARNING: We cannot put a check here, because the inflation
// will not update the displaced header. Once BasicLock is inflated,
// no one should ever look at its content.
} else {
// Typically the displaced header will be 0 (recursive stack lock) or
// unused_mark. Naively we'd like to assert that the displaced mark
// value is either 0, neutral, or 3. But with the advent of the
// store-before-CAS avoidance in fast_lock/compiler_lock_object
// we can find any flavor mark in the displaced mark.
if (LockingMode == LM_LEGACY) {
if (displaced_header().is_neutral()) {
// The object is locked and the resulting ObjectMonitor* will also be
// locked so it can't be async deflated until ownership is dropped.
ObjectSynchronizer::inflate_helper(obj);
// WARNING: We cannot put a check here, because the inflation
// will not update the displaced header. Once BasicLock is inflated,
// no one should ever look at its content.
} else {
// Typically the displaced header will be 0 (recursive stack lock) or
// unused_mark. Naively we'd like to assert that the displaced mark
// value is either 0, neutral, or 3. But with the advent of the
// store-before-CAS avoidance in fast_lock/compiler_lock_object
// we can find any flavor mark in the displaced mark.
}
dest->set_displaced_header(displaced_header());
}
dest->set_displaced_header(displaced_header());
#ifdef ASSERT
else {
dest->set_displaced_header(markWord(badDispHeaderDeopt));
}
#endif
}
26 changes: 17 additions & 9 deletions src/hotspot/share/runtime/sharedRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3257,16 +3257,24 @@ JRT_LEAF(intptr_t*, SharedRuntime::OSR_migration_begin( JavaThread *current) )
kptr2 = fr.next_monitor_in_interpreter_frame(kptr2) ) {
if (kptr2->obj() != nullptr) { // Avoid 'holes' in the monitor array
BasicLock *lock = kptr2->lock();
// Inflate so the object's header no longer refers to the BasicLock.
if (lock->displaced_header().is_unlocked()) {
// The object is locked and the resulting ObjectMonitor* will also be
// locked so it can't be async deflated until ownership is dropped.
// See the big comment in basicLock.cpp: BasicLock::move_to().
ObjectSynchronizer::inflate_helper(kptr2->obj());
if (LockingMode == LM_LEGACY) {
// Inflate so the object's header no longer refers to the BasicLock.
if (lock->displaced_header().is_unlocked()) {
// The object is locked and the resulting ObjectMonitor* will also be
// locked so it can't be async deflated until ownership is dropped.
// See the big comment in basicLock.cpp: BasicLock::move_to().
ObjectSynchronizer::inflate_helper(kptr2->obj());
}
// Now the displaced header is free to move because the
// object's header no longer refers to it.
buf[i] = (intptr_t)lock->displaced_header().value();
}
// Now the displaced header is free to move because the
// object's header no longer refers to it.
buf[i++] = (intptr_t)lock->displaced_header().value();
#ifdef ASSERT
else {
buf[i] = badDispHeaderOSR;
}
#endif
i++;
buf[i++] = cast_from_oop<intptr_t>(kptr2->obj());
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/utilities/globalDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,8 @@ const juint badHeapWordVal = 0xBAADBABE; // value used to zap
const juint badMetaWordVal = 0xBAADFADE; // value used to zap metadata heap after GC
const int badCodeHeapNewVal= 0xCC; // value used to zap Code heap at allocation
const int badCodeHeapFreeVal = 0xDD; // value used to zap Code heap at deallocation

const intptr_t badDispHeaderDeopt = 0xDE0BD000; // value to fill unused displaced header during deoptimization
const intptr_t badDispHeaderOSR = 0xDEAD05A0; // value to fill unused displaced header during OSR

// (These must be implemented as #defines because C++ compilers are
// not obligated to inline non-integral constants!)
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static frame next_frame(frame fr, Thread* t) {
if (!t->is_in_full_stack((address)(fr.real_fp() + 1))) {
return invalid;
}
if (fr.is_java_frame() || fr.is_native_frame() || fr.is_runtime_frame()) {
if (fr.is_interpreted_frame() || (fr.cb() != nullptr && fr.cb()->frame_size() > 0)) {
RegisterMap map(JavaThread::cast(t),
RegisterMap::UpdateMap::skip,
RegisterMap::ProcessFrames::include,
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type
}
return xattrEnabled;
}
// POSIX attributes not supported on FAT
// POSIX attributes not supported on FAT32
if (type == PosixFileAttributeView.class && entry().fstype().equals("vfat"))
return false;
return super.supportsFileAttributeView(type);
Expand Down
10 changes: 9 additions & 1 deletion src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@

package sun.nio.fs;

import java.io.IOException;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.UserDefinedFileAttributeView;
import java.io.IOException;
import java.util.Arrays;

/**
Expand Down Expand Up @@ -100,13 +101,20 @@ public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type
UnixPath dir = new UnixPath(file().getFileSystem(), entry().dir());
return isExtendedAttributesEnabled(dir);
}
// POSIX attributes not supported on FAT32
if (type == PosixFileAttributeView.class &&
entry().fstype().equals("msdos"))
return false;
return super.supportsFileAttributeView(type);
}

@Override
public boolean supportsFileAttributeView(String name) {
if (name.equals("user"))
return supportsFileAttributeView(UserDefinedFileAttributeView.class);
// UNIX attributes not supported on FAT32
if (name.equals("unix") && entry().fstype().equals("msdos"))
return false;
return super.supportsFileAttributeView(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@
* type must not be null, and any null argument will elicit a {@code NullPointerException}. This fact is not individually
* documented for methods of this API.
*
* @apiNote Usual memory model guarantees, for example stated in {@jls 6.6} and {@jls 10.4}, do not apply
* when accessing native memory segments as these segments are backed by off-heap regions of memory.
* @apiNote Usual memory model guarantees (see {@jls 17.4}) do not apply when accessing native memory segments as
* these segments are backed by off-heap regions of memory.
*
* @implNote
* In the reference implementation, access to restricted methods can be granted to specific modules using the command line option
Expand Down
10 changes: 8 additions & 2 deletions src/java.base/share/classes/java/net/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,10 @@ public int read(byte[] b, int off, int len) throws IOException {
}
long start = SocketReadEvent.timestamp();
int nbytes = implRead(b, off, len);
SocketReadEvent.offer(start, nbytes, parent.getRemoteSocketAddress(), getSoTimeout());
long duration = SocketReadEvent.timestamp() - start;
if (SocketReadEvent.shouldCommit(duration)) {
SocketReadEvent.emit(start, duration, nbytes, parent.getRemoteSocketAddress(), getSoTimeout());
}
return nbytes;
}

Expand Down Expand Up @@ -1209,7 +1212,10 @@ public void write(byte[] b, int off, int len) throws IOException {
}
long start = SocketWriteEvent.timestamp();
implWrite(b, off, len);
SocketWriteEvent.offer(start, len, parent.getRemoteSocketAddress());
long duration = SocketWriteEvent.timestamp() - start;
if (SocketWriteEvent.shouldCommit(duration)) {
SocketWriteEvent.emit(start, duration, len, parent.getRemoteSocketAddress());
}
}

private void implWrite(byte[] b, int off, int len) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,19 @@ public static long timestamp() {
* {@link #commit(long, long, String, String, int, long, long, boolean)}.
*
* @param start the start time
* @param duration the duration
* @param nbytes how many bytes were transferred
* @param remote the address of the remote socket
* @param timeout maximum time to wait
*/
public static void offer(long start, long nbytes, SocketAddress remote, long timeout) {
long duration = timestamp() - start;
if (shouldCommit(duration)) {
boolean eof = nbytes < 0 ? true : false;
nbytes = nbytes < 0 ? 0 : nbytes;
if (remote instanceof InetSocketAddress isa) {
commit(start, duration, isa.getHostString(), isa.getAddress().getHostAddress(), isa.getPort(), timeout, nbytes, eof);
} else if (remote instanceof UnixDomainSocketAddress udsa) {
String path = "[" + udsa.getPath().toString() + "]";
commit(start, duration, "Unix domain socket", path, 0, timeout, nbytes, eof);
}
public static void emit(long start, long duration, long nbytes, SocketAddress remote, long timeout) {
boolean eof = nbytes < 0 ? true : false;
nbytes = nbytes < 0 ? 0 : nbytes;
if (remote instanceof InetSocketAddress isa) {
commit(start, duration, isa.getHostString(), isa.getAddress().getHostAddress(), isa.getPort(), timeout, nbytes, eof);
} else if (remote instanceof UnixDomainSocketAddress udsa) {
String path = "[" + udsa.getPath().toString() + "]";
commit(start, duration, "Unix domain socket", path, 0, timeout, nbytes, eof);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,17 @@ public static long timestamp() {
* {@link #commit(long, long, String, String, int, long)}.
*
* @param start the start time
* @param duration the duration
* @param bytesWritten how many bytes were sent
* @param remote the address of the remote socket being written to
*/
public static void offer(long start, long bytesWritten, SocketAddress remote) {
long duration = timestamp() - start;
if (shouldCommit(duration)) {
long bytes = bytesWritten < 0 ? 0 : bytesWritten;
if (remote instanceof InetSocketAddress isa) {
commit(start, duration, isa.getHostString(), isa.getAddress().getHostAddress(), isa.getPort(), bytes);
} else if (remote instanceof UnixDomainSocketAddress udsa) {
String path = "[" + udsa.getPath().toString() + "]";
commit(start, duration, "Unix domain socket", path, 0, bytes);
}
public static void emit(long start, long duration, long bytesWritten, SocketAddress remote) {
long bytes = bytesWritten < 0 ? 0 : bytesWritten;
if (remote instanceof InetSocketAddress isa) {
commit(start, duration, isa.getHostString(), isa.getAddress().getHostAddress(), isa.getPort(), bytes);
} else if (remote instanceof UnixDomainSocketAddress udsa) {
String path = "[" + udsa.getPath().toString() + "]";
commit(start, duration, "Unix domain socket", path, 0, bytes);
}
}
}
10 changes: 3 additions & 7 deletions src/java.base/share/classes/sun/nio/ch/Invoker.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -70,12 +70,8 @@ void incrementInvokeCount() {
handlerInvokeCount++;
}
}
private static final ThreadLocal<GroupAndInvokeCount> myGroupAndInvokeCount =
new ThreadLocal<GroupAndInvokeCount>() {
@Override protected GroupAndInvokeCount initialValue() {
return null;
}
};
private static final ThreadLocal<GroupAndInvokeCount> myGroupAndInvokeCount
= new ThreadLocal<GroupAndInvokeCount>();

/**
* Binds this thread to the given group
Expand Down
Loading

0 comments on commit a23e667

Please sign in to comment.