Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Sep 22, 2023
2 parents 6342920 + 343cc0c commit c04b6d6
Show file tree
Hide file tree
Showing 74 changed files with 2,615 additions and 435 deletions.
3 changes: 2 additions & 1 deletion make/modules/java.base/Lib.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBNET, \
DISABLED_WARNINGS_microsoft_ResolverConfigurationImpl.c := 4996, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll, \
LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll \
-delayload:winhttp.dll, \
LIBS_unix := -ljvm -ljava, \
LIBS_linux := $(LIBDL), \
LIBS_aix := $(LIBDL),\
Expand Down
3 changes: 1 addition & 2 deletions make/modules/java.base/lib/CoreLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
LDFLAGS_windows := -delayload:shell32.dll, \
LIBS_unix := -ljvm, \
LIBS_linux := $(LIBDL), \
LIBS_aix := $(LIBDL) $(LIBM),\
LIBS_macosx := -framework CoreFoundation \
-framework Foundation \
-framework SystemConfiguration, \
LIBS_windows := jvm.lib \
shell32.lib delayimp.lib \
shell32.lib ole32.lib \
advapi32.lib version.lib, \
))

Expand Down
2 changes: 2 additions & 0 deletions make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,8 @@ else
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCompleteExit += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeGetCreatedJavaVMs := -ljvm -lpthread

BUILD_HOTSPOT_JTREG_EXCLUDE += libNativeException.c
endif

ifeq ($(ASAN_ENABLED), true)
Expand Down
11 changes: 4 additions & 7 deletions src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,6 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// --------------------------------------------------------------------------

if (method->is_synchronized()) {
ConditionRegister r_flag = CCR1;
Register r_oop = r_temp_4;
const Register r_box = r_temp_5;
Label done, locked;
Expand All @@ -2465,8 +2464,8 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,

// Try fastpath for locking.
// fast_lock kills r_temp_1, r_temp_2, r_temp_3.
__ compiler_fast_lock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
__ beq(r_flag, locked);
__ compiler_fast_lock_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
__ beq(CCR0, locked);

// None of the above fast optimizations worked so we have to get into the
// slow case of monitor enter. Inline a special case of call_VM that
Expand Down Expand Up @@ -2659,8 +2658,6 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// --------------------------------------------------------------------------

if (method->is_synchronized()) {

ConditionRegister r_flag = CCR1;
const Register r_oop = r_temp_4;
const Register r_box = r_temp_5;
const Register r_exception = r_temp_6;
Expand All @@ -2677,8 +2674,8 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
__ addi(r_box, R1_SP, lock_offset);

// Try fastpath for unlocking.
__ compiler_fast_unlock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
__ beq(r_flag, done);
__ compiler_fast_unlock_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
__ beq(CCR0, done);

// Save and restore any potential method result value around the unlocking operation.
save_native_result(masm, ret_type, workspace_slot_offset);
Expand Down
11 changes: 7 additions & 4 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4254,9 +4254,12 @@ size_t os::vm_min_address() {
static size_t value = 0;
if (value == 0) {
assert(is_aligned(_vm_min_address_default, os::vm_allocation_granularity()), "Sanity");
FILE* f = fopen("/proc/sys/vm/mmap_min_addr", "r");
if (fscanf(f, "%zu", &value) != 1) {
value = _vm_min_address_default;
FILE* f = os::fopen("/proc/sys/vm/mmap_min_addr", "r");
if (f != nullptr) {
if (fscanf(f, "%zu", &value) != 1) {
value = _vm_min_address_default;
}
fclose(f);
}
value = MAX2(_vm_min_address_default, value);
}
Expand Down Expand Up @@ -4373,7 +4376,7 @@ jlong os::Linux::fast_thread_cpu_time(clockid_t clockid) {
// the number of bytes written to out_fd is returned if transfer was successful
// otherwise, returns -1 that implies an error
jlong os::Linux::sendfile(int out_fd, int in_fd, jlong* offset, jlong count) {
return sendfile64(out_fd, in_fd, (off64_t*)offset, (size_t)count);
return ::sendfile64(out_fd, in_fd, (off64_t*)offset, (size_t)count);
}

// Determine if the vmid is the parent pid for a child in a PID namespace.
Expand Down
57 changes: 35 additions & 22 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ void os::run_periodic_checks(outputStream* st) {
return;
}

#ifndef _WIN64
// previous UnhandledExceptionFilter, if there is one
static LPTOP_LEVEL_EXCEPTION_FILTER prev_uef_handler = nullptr;
#endif

LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo);
static LONG WINAPI Uncaught_Exception_Handler(struct _EXCEPTION_POINTERS* exceptionInfo);

void os::init_system_properties_values() {
// sysclasspath, java_home, dll_dir
Expand Down Expand Up @@ -397,7 +399,7 @@ void os::init_system_properties_values() {

#ifndef _WIN64
// set our UnhandledExceptionFilter and save any previous one
prev_uef_handler = SetUnhandledExceptionFilter(Handle_FLT_Exception);
prev_uef_handler = SetUnhandledExceptionFilter(Uncaught_Exception_Handler);
#endif

// Done
Expand Down Expand Up @@ -2534,9 +2536,7 @@ LONG Handle_IDiv_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {

#if defined(_M_AMD64) || defined(_M_IX86)
//-----------------------------------------------------------------------------
LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
PCONTEXT ctx = exceptionInfo->ContextRecord;
#ifndef _WIN64
static bool handle_FLT_exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
// handle exception caused by native method modifying control word
DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;

Expand All @@ -2547,34 +2547,48 @@ LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_FLT_UNDERFLOW:
case EXCEPTION_FLT_UNDERFLOW: {
PCONTEXT ctx = exceptionInfo->ContextRecord;
#ifndef _WIN64
jint fp_control_word = (* (jint*) StubRoutines::x86::addr_fpu_cntrl_wrd_std());
if (fp_control_word != ctx->FloatSave.ControlWord) {
// Restore FPCW and mask out FLT exceptions
ctx->FloatSave.ControlWord = fp_control_word | 0xffffffc0;
// Mask out pending FLT exceptions
ctx->FloatSave.StatusWord &= 0xffffff00;
return EXCEPTION_CONTINUE_EXECUTION;
return true;
}
#else // !_WIN64
// On Windows, the mxcsr control bits are non-volatile across calls
// See also CR 6192333
//
jint MxCsr = INITIAL_MXCSR;
// we can't use StubRoutines::x86::addr_mxcsr_std()
// because in Win64 mxcsr is not saved there
if (MxCsr != ctx->MxCsr) {
ctx->MxCsr = MxCsr;
return true;
}
#endif // !_WIN64
}
}

return false;
}
#endif

#ifndef _WIN64
static LONG WINAPI Uncaught_Exception_Handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
if (handle_FLT_exception(exceptionInfo)) {
return EXCEPTION_CONTINUE_EXECUTION;
}

// we only override this on 32 bits, so only check it there
if (prev_uef_handler != nullptr) {
// We didn't handle this exception so pass it to the previous
// UnhandledExceptionFilter.
return (prev_uef_handler)(exceptionInfo);
}
#else // !_WIN64
// On Windows, the mxcsr control bits are non-volatile across calls
// See also CR 6192333
//
jint MxCsr = INITIAL_MXCSR;
// we can't use StubRoutines::x86::addr_mxcsr_std()
// because in Win64 mxcsr is not saved there
if (MxCsr != ctx->MxCsr) {
ctx->MxCsr = MxCsr;
return EXCEPTION_CONTINUE_EXECUTION;
}
#endif // !_WIN64

return EXCEPTION_CONTINUE_SEARCH;
}
Expand Down Expand Up @@ -2831,9 +2845,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
}

#if defined(_M_AMD64) || defined(_M_IX86)
if ((in_java || in_native) && exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
LONG result=Handle_FLT_Exception(exceptionInfo);
if (result==EXCEPTION_CONTINUE_EXECUTION) return result;
if ((in_java || in_native) && handle_FLT_exception(exceptionInfo)) {
return EXCEPTION_CONTINUE_EXECUTION;
}
#endif

Expand Down
32 changes: 19 additions & 13 deletions src/hotspot/share/classfile/loaderConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/dictionary.hpp"
#include "classfile/loaderConstraints.hpp"
#include "classfile/placeholders.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "oops/klass.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbolHandle.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
#include "utilities/resourceHash.hpp"

// Overview
Expand Down Expand Up @@ -447,6 +443,23 @@ InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name,
return nullptr;
}

// Removes a class that was added to the table then class loading subsequently failed for this class,
// so we don't have a dangling pointer to InstanceKlass in the LoaderConstraintTable.
void LoaderConstraintTable::remove_failed_loaded_klass(InstanceKlass* klass,
ClassLoaderData* loader) {

Symbol* name = klass->name();
LoaderConstraint *p = find_loader_constraint(name, loader);
if (p != nullptr && p->klass() != nullptr && p->klass() == klass) {
// If this is the klass in the constraint, the error was OOM from the ClassLoader.addClass() call.
// Other errors during loading (eg. constraint violations) will not have added this klass.
log_info(class, loader, constraints)("removing klass %s: failed to load", name->as_C_string());
// We only null out the class, since the constraint for the class name for this loader is still valid as
// it was added when checking signature loaders for a method or field resolution.
p->set_klass(nullptr);
}
}

void LoaderConstraintTable::merge_loader_constraints(Symbol* class_name,
LoaderConstraint* p1,
LoaderConstraint* p2,
Expand Down Expand Up @@ -511,15 +524,8 @@ void LoaderConstraintTable::verify() {
// We found the class in the dictionary, so we should
// make sure that the Klass* matches what we already have.
guarantee(k == probe->klass(), "klass should be in dictionary");
} else {
// If we don't find the class in the dictionary, it
// has to be in the placeholders table.
PlaceholderEntry* entry = PlaceholderTable::get_entry(name, loader_data);

// The InstanceKlass might not be on the entry, so the only
// thing we can check here is whether we were successful in
// finding the class in the placeholders table.
guarantee(entry != nullptr, "klass should be in the placeholders");
// If we don't find the class in the dictionary, it is
// in the process of loading and may or may not be in the placeholder table.
}
}
for (int n = 0; n< probe->num_loaders(); n++) {
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/classfile/loaderConstraints.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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 @@ -59,6 +59,7 @@ class LoaderConstraintTable : public AllStatic {
// Class loader constraints
static bool check_or_update(InstanceKlass* k, ClassLoaderData* loader, Symbol* name);

static void remove_failed_loaded_klass(InstanceKlass* k, ClassLoaderData* loader);
static void purge_loader_constraints();

static void print_table_statistics(outputStream* st);
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,10 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam
} else if (HAS_PENDING_EXCEPTION) {
assert(defined_k == nullptr, "Should not have a klass if there's an exception");
k->class_loader_data()->add_to_deallocate_list(k);

// Also remove this InstanceKlass from the LoaderConstraintTable if added.
MutexLocker ml(SystemDictionary_lock);
LoaderConstraintTable::remove_failed_loaded_klass(k, class_loader_data(class_loader));
}
return defined_k;
}
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/x/xArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ void XArguments::initialize_alignments() {
HeapAlignment = SpaceAlignment;
}

void XArguments::initialize_heap_flags_and_sizes() {
// Nothing extra to do
}

void XArguments::initialize() {
// Check mark stack size
const size_t mark_stack_space_limit = XAddressSpaceLimit::mark_stack();
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/x/xArguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CollectedHeap;
class XArguments : AllStatic {
public:
static void initialize_alignments();
static void initialize_heap_flags_and_sizes();
static void initialize();
static size_t heap_virtual_to_physical_ratio();
static CollectedHeap* create_heap();
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/share/gc/z/shared/zSharedArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ void ZSharedArguments::initialize_alignments() {
}
}

void ZSharedArguments::initialize_heap_flags_and_sizes() {
GCArguments::initialize_heap_flags_and_sizes();

if (ZGenerational) {
ZArguments::initialize_heap_flags_and_sizes();
} else {
XArguments::initialize_heap_flags_and_sizes();
}
}

void ZSharedArguments::initialize() {
GCArguments::initialize();

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/z/shared/zSharedArguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CollectedHeap;
class ZSharedArguments : public GCArguments {
private:
virtual void initialize_alignments();
virtual void initialize_heap_flags_and_sizes();

virtual void initialize();
virtual size_t conservative_max_heap_alignment();
Expand Down
23 changes: 13 additions & 10 deletions src/hotspot/share/gc/z/zArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ void ZArguments::initialize_alignments() {
HeapAlignment = SpaceAlignment;
}

void ZArguments::initialize_heap_flags_and_sizes() {
if (!FLAG_IS_CMDLINE(MaxHeapSize) &&
!FLAG_IS_CMDLINE(MaxRAMFraction) &&
!FLAG_IS_CMDLINE(MaxRAMPercentage) &&
!FLAG_IS_CMDLINE(SoftMaxHeapSize)) {
// We are really just guessing how much memory the program needs.
// When that is the case, we don't want the soft and hard limits to be the same
// as it can cause flakyness in the number of GC threads used, in order to keep
// to a random number we just pulled out of thin air.
FLAG_SET_ERGO(SoftMaxHeapSize, MaxHeapSize * 90 / 100);
}
}

void ZArguments::select_max_gc_threads() {
// Select number of parallel threads
if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
Expand Down Expand Up @@ -126,16 +139,6 @@ void ZArguments::initialize() {
FLAG_SET_ERGO_IF_DEFAULT(ZCollectionIntervalMajor, ZCollectionInterval);
}

if (!FLAG_IS_CMDLINE(MaxHeapSize) &&
!FLAG_IS_CMDLINE(MaxRAMFraction) &&
!FLAG_IS_CMDLINE(MaxRAMPercentage)) {
// We are really just guessing how much memory the program needs.
// When that is the case, we don't want the soft and hard limits to be the same
// as it can cause flakyness in the number of GC threads used, in order to keep
// to a random number we just pulled out of thin air.
FLAG_SET_ERGO_IF_DEFAULT(SoftMaxHeapSize, MaxHeapSize * 90 / 100);
}

if (FLAG_IS_DEFAULT(ZFragmentationLimit)) {
FLAG_SET_DEFAULT(ZFragmentationLimit, 5.0);
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/z/zArguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ZArguments : AllStatic {

public:
static void initialize_alignments();
static void initialize_heap_flags_and_sizes();
static void initialize();
static size_t heap_virtual_to_physical_ratio();
static CollectedHeap* create_heap();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ JVM_ExpandStackFrameInfo(JNIEnv *env, jobject obj);
JNIEXPORT jobject JNICALL
JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jint mode,
jint skip_frames, jobject contScope, jobject cont,
jint frame_count, jint start_index, jobjectArray frames);
jint buffer_size, jint start_index, jobjectArray frames);

JNIEXPORT jint JNICALL
JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jint mode, jlong anchor,
jint frame_count, jint start_index,
jint last_batch_count, jint buffer_size, jint start_index,
jobjectArray frames);

JNIEXPORT void JNICALL
Expand Down
Loading

0 comments on commit c04b6d6

Please sign in to comment.