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 Dec 21, 2023
2 parents e03e0c3 + 6de23bf commit f8c8b66
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 89 deletions.
11 changes: 11 additions & 0 deletions src/hotspot/cpu/riscv/assembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,17 @@ enum Nf {
return uabs(target - branch) < branch_range;
}

// Decode the given instruction, checking if it's a 16-bit compressed
// instruction and return the address of the next instruction.
static address locate_next_instruction(address inst) {
// Instruction wider than 16 bits has the two least-significant bits set.
if ((0x3 & *inst) == 0x3) {
return inst + instruction_size;
} else {
return inst + compressed_instruction_size;
}
}

Assembler(CodeBuffer* code) : AbstractAssembler(code), _in_compressible_region(true) {}
};

Expand Down
100 changes: 39 additions & 61 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ bool os::dll_address_to_library_name(address addr, char* buf,
// in case of error it checks if .dll/.so was built for the
// same architecture as Hotspot is running on

void *os::Bsd::dlopen_helper(const char *filename, int mode) {
void *os::Bsd::dlopen_helper(const char *filename, int mode, char *ebuf, int ebuflen) {
#ifndef IA32
bool ieee_handling = IEEE_subnormal_handling_OK();
if (!ieee_handling) {
Expand All @@ -1005,27 +1005,44 @@ void *os::Bsd::dlopen_helper(const char *filename, int mode) {
assert(rtn == 0, "fegetenv must succeed");
#endif // IA32

void * result= ::dlopen(filename, RTLD_LAZY);

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = ::dlopen(filename, RTLD_LAZY);
if (result == nullptr) {
const char* error_report = ::dlerror();
if (error_report == nullptr) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
::strncpy(ebuf, error_report, ebuflen-1);
ebuf[ebuflen-1]='\0';
}
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
JFR_ONLY(load_event.set_error_msg(error_report);)
} else {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
log_info(os)("shared library load of %s was successful", filename);
#ifndef IA32
if (result != nullptr && ! IEEE_subnormal_handling_OK()) {
// We just dlopen()ed a library that mangled the floating-point
// flags. Silently fix things now.
int rtn = fesetenv(&default_fenv);
assert(rtn == 0, "fesetenv must succeed");
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();

if (ieee_handling_after_issue) {
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
} else {
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
if (! IEEE_subnormal_handling_OK()) {
// We just dlopen()ed a library that mangled the floating-point
// flags. Silently fix things now.
JFR_ONLY(load_event.set_fp_env_correction_attempt(true);)
int rtn = fesetenv(&default_fenv);
assert(rtn == 0, "fesetenv must succeed");

if (IEEE_subnormal_handling_OK()) {
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
JFR_ONLY(load_event.set_fp_env_correction_success(true);)
} else {
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
assert(false, "fesetenv didn't work");
}
}

assert(ieee_handling_after_issue, "fesetenv didn't work");
}
#endif // IA32
}

return result;
}
Expand All @@ -1037,30 +1054,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
#else
log_info(os)("attempting shared library load of %s", filename);

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = os::Bsd::dlopen_helper(filename, RTLD_LAZY);
if (result != nullptr) {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
// Successful loading
log_info(os)("shared library load of %s was successful", filename);
return result;
}

const char* error_report = ::dlerror();
if (error_report == nullptr) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
// Read system error message into ebuf
::strncpy(ebuf, error_report, ebuflen-1);
ebuf[ebuflen-1]='\0';
}
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
JFR_ONLY(load_event.set_error_msg(error_report);)

return nullptr;
return os::Bsd::dlopen_helper(filename, RTLD_LAZY, ebuf, ebuflen);
#endif // STATIC_BUILD
}
#else
Expand All @@ -1071,29 +1065,13 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", filename);

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = os::Bsd::dlopen_helper(filename, RTLD_LAZY);
result = os::Bsd::dlopen_helper(filename, RTLD_LAZY, ebuf, ebuflen);
if (result != nullptr) {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
// Successful loading
log_info(os)("shared library load of %s was successful", filename);
return result;
}

Elf32_Ehdr elf_head;

const char* const error_report = ::dlerror();
if (error_report == nullptr) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
// Read system error message into ebuf
::strncpy(ebuf, error_report, ebuflen-1);
ebuf[ebuflen-1]='\0';
}
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
JFR_ONLY(load_event.set_error_msg(error_report);)
int diag_msg_max_length=ebuflen-strlen(ebuf);
char* diag_msg_buf=ebuf+strlen(ebuf);

Expand All @@ -1102,14 +1080,14 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
return nullptr;
}


int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);

if (file_descriptor < 0) {
// Can't open library, report dlerror() message
return nullptr;
}

Elf32_Ehdr elf_head;
bool failed_to_read_elf_head=
(sizeof(elf_head)!=
(::read(file_descriptor, &elf_head,sizeof(elf_head))));
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/bsd/os_bsd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class os::Bsd {
// Real-time clock functions
static void clock_init(void);

static void *dlopen_helper(const char *path, int mode);
static void *dlopen_helper(const char *path, int mode, char *ebuf, int ebuflen);

// Stack repair handling

Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,18 +1856,19 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
if (! IEEE_subnormal_handling_OK()) {
// We just dlopen()ed a library that mangled the floating-point flags.
// Attempt to fix things now.
JFR_ONLY(load_event.set_fp_env_correction_attempt(true);)
int rtn = fesetenv(&default_fenv);
assert(rtn == 0, "fesetenv must succeed");
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();

if (ieee_handling_after_issue) {
if (IEEE_subnormal_handling_OK()) {
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
JFR_ONLY(load_event.set_fp_env_correction_success(true);)
} else {
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
assert(false, "fesetenv didn't work");
}
assert(ieee_handling_after_issue, "fesetenv didn't work");
}
#endif // IA32
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
CompiledMethod* nm = (cb != nullptr) ? cb->as_compiled_method_or_null() : nullptr;
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
if ((nm != nullptr && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
address next_pc = pc + NativeCall::instruction_size;
address next_pc = Assembler::locate_next_instruction(pc);
if (is_unsafe_arraycopy) {
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
}
Expand Down Expand Up @@ -271,7 +271,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
thread->thread_state() == _thread_in_native) &&
sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
thread->doing_unsafe_access()) {
address next_pc = pc + NativeCall::instruction_size;
address next_pc = Assembler::locate_next_instruction(pc);
if (UnsafeCopyMemory::contains_pc(pc)) {
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
}
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/parallel/gcAdaptivePolicyCounters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class GCAdaptivePolicyCounters : public GCPolicyCounters {
PerfVariable* _decrease_for_footprint_counter;

PerfVariable* _minor_pause_young_slope_counter;
PerfVariable* _major_pause_old_slope_counter;

PerfVariable* _decide_at_full_gc_counter;

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/jfr/metadata/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@
<Field type="string" name="name" label="Name" />
<Field type="boolean" name="success" label="Success" description="Success or failure of the load operation" />
<Field type="string" name="errorMessage" label="Error Message" description="In case of a load error, error description" />
<Field type="boolean" name="fpEnvCorrectionAttempt" label="FPU Environment correction" description="In case of IEEE conformance issues we might reset the FP environment" />
<Field type="boolean" name="fpEnvCorrectionSuccess" label="FPU Environment correction result" description="Stores the result in the case of an FP environment correction" />
</Event>

<Event name="NativeLibraryUnload" category="Java Virtual Machine, Runtime" label="Native Library Unload" thread="true" stackTrace="true" startTime="true"
Expand Down
14 changes: 12 additions & 2 deletions src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static inline JfrTicksWrapper* allocate_start_time() {
return EventType::is_enabled() ? new JfrTicksWrapper() : nullptr;
}

NativeLibraryLoadEvent::NativeLibraryLoadEvent(const char* name, void** result) : JfrNativeLibraryEventBase(name), _result(result) {
NativeLibraryLoadEvent::NativeLibraryLoadEvent(const char* name, void** result) : JfrNativeLibraryEventBase(name), _result(result), _fp_env_correction_attempt(false), _fp_env_correction_success(false) {
assert(_result != nullptr, "invariant");
_start_time = allocate_start_time<EventNativeLibraryLoad>();
}
Expand All @@ -90,8 +90,17 @@ void NativeLibraryUnloadEvent::set_result(bool result) {
_result = result;
}

static void set_additional_data(EventNativeLibraryLoad& event, const NativeLibraryLoadEvent& helper) {
event.set_fpEnvCorrectionAttempt(helper.get_fp_env_correction_attempt());
event.set_fpEnvCorrectionSuccess(helper.get_fp_env_correction_success());
}

static void set_additional_data(EventNativeLibraryUnload& event, const NativeLibraryUnloadEvent& helper) {
// no additional entries atm. for the unload event
}

template <typename EventType, typename HelperType>
static void commit(HelperType& helper) {
static void commit(const HelperType& helper) {
if (!helper.has_start_time()) {
return;
}
Expand All @@ -101,6 +110,7 @@ static void commit(HelperType& helper) {
event.set_name(helper.name());
event.set_errorMessage(helper.error_msg());
event.set_success(helper.success());
set_additional_data(event, helper);
Thread* thread = Thread::current();
assert(thread != nullptr, "invariant");
if (thread->is_Java_thread()) {
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ class JfrNativeLibraryEventBase : public StackObj {
class NativeLibraryLoadEvent : public JfrNativeLibraryEventBase {
private:
void** _result;
bool _fp_env_correction_attempt;
bool _fp_env_correction_success;
public:
NativeLibraryLoadEvent(const char* name, void** result);
~NativeLibraryLoadEvent();
bool success() const;
bool get_fp_env_correction_attempt() const { return _fp_env_correction_attempt; }
bool get_fp_env_correction_success() const { return _fp_env_correction_success; }
void set_fp_env_correction_attempt(bool v) { _fp_env_correction_attempt = v; }
void set_fp_env_correction_success(bool v) { _fp_env_correction_success = v; }
};

class NativeLibraryUnloadEvent : public JfrNativeLibraryEventBase {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void Universe::genesis(TRAPS) {
// Initialization of the fillerArrayKlass must come before regular
// int-TypeArrayKlass so that the int-Array mirror points to the
// int-TypeArrayKlass.
_fillerArrayKlassObj = TypeArrayKlass::create_klass(T_INT, "Ljdk/internal/vm/FillerArray;", CHECK);
_fillerArrayKlassObj = TypeArrayKlass::create_klass(T_INT, "[Ljdk/internal/vm/FillerElement;", CHECK);
for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
_typeArrayKlassObjs[i] = TypeArrayKlass::create_klass((BasicType)i, CHECK);
}
Expand Down
12 changes: 0 additions & 12 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3933,8 +3933,6 @@ JVM_ENTRY(void, JVM_VirtualThreadStart(JNIEnv* env, jobject vthread))
// set VTMS transition bit value in JavaThread and java.lang.VirtualThread object
JvmtiVTMSTransitionDisabler::set_is_in_VTMS_transition(thread, vthread, false);
}
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand All @@ -3950,8 +3948,6 @@ JVM_ENTRY(void, JVM_VirtualThreadEnd(JNIEnv* env, jobject vthread))
// set VTMS transition bit value in JavaThread and java.lang.VirtualThread object
JvmtiVTMSTransitionDisabler::set_is_in_VTMS_transition(thread, vthread, true);
}
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand All @@ -3969,8 +3965,6 @@ JVM_ENTRY(void, JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hi
// set VTMS transition bit value in JavaThread and java.lang.VirtualThread object
JvmtiVTMSTransitionDisabler::set_is_in_VTMS_transition(thread, vthread, hide);
}
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand All @@ -3988,8 +3982,6 @@ JVM_ENTRY(void, JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean
// set VTMS transition bit value in JavaThread and java.lang.VirtualThread object
JvmtiVTMSTransitionDisabler::set_is_in_VTMS_transition(thread, vthread, hide);
}
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand All @@ -4003,8 +3995,6 @@ JVM_ENTRY(void, JVM_VirtualThreadHideFrames(JNIEnv* env, jobject vthread, jboole
assert(!thread->is_in_VTMS_transition(), "sanity check");
assert(thread->is_in_tmp_VTMS_transition() != (bool)hide, "sanity check");
thread->toggle_is_in_tmp_VTMS_transition();
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand All @@ -4019,8 +4009,6 @@ JVM_ENTRY(void, JVM_VirtualThreadDisableSuspend(JNIEnv* env, jobject vthread, jb
assert(thread->is_disable_suspend() != (bool)enter,
"nested or unbalanced monitor enter/exit is not allowed");
thread->toggle_is_disable_suspend();
#else
fatal("Should only be called with JVMTI enabled");
#endif
JVM_END

Expand Down
7 changes: 5 additions & 2 deletions src/java.base/share/classes/java/io/SequenceInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,14 @@ public long transferTo(OutputStream out) throws IOException {
if (getClass() == SequenceInputStream.class) {
long transferred = 0;
while (in != null) {
long numTransferred = in.transferTo(out);
// increment the total transferred byte count
// only if we haven't already reached the Long.MAX_VALUE
if (transferred < Long.MAX_VALUE) {
try {
transferred = Math.addExact(transferred, in.transferTo(out));
transferred = Math.addExact(transferred, numTransferred);
} catch (ArithmeticException ignore) {
return Long.MAX_VALUE;
transferred = Long.MAX_VALUE;
}
}
nextStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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 @@ -636,7 +636,7 @@ public String engineGetCertificateAlias(Certificate cert) {
if (entry.certChain != null &&
entry.certChain.length > 0 &&
entry.certChain[0].equals(cert)) {
return entry.getAlias();
return mapEntry.getKey();
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ gc/epsilon/TestMemoryMXBeans.java 8206434 generic-all
gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all
gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all
gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all
gc/TestAllocHumongousFragment.java#adaptive 8298781 generic-all
gc/TestAllocHumongousFragment.java#aggressive 8298781 generic-all
gc/TestAllocHumongousFragment.java#iu-aggressive 8298781 generic-all
gc/TestAllocHumongousFragment.java#g1 8298781 generic-all
gc/TestAllocHumongousFragment.java#static 8298781 generic-all
gc/stress/gclocker/TestExcessGCLockerCollections.java 8229120 generic-all
gc/stress/gclocker/TestGCLockerWithParallel.java 8180622 generic-all
gc/stress/gclocker/TestGCLockerWithSerial.java 8180622 generic-all
Expand Down
Loading

0 comments on commit f8c8b66

Please sign in to comment.