Skip to content

Commit

Permalink
Merge branch 'openjdk:master' into backport-3f1174aa4709aabcfde8b40de…
Browse files Browse the repository at this point in the history
…ec88b8ed466cc06
  • Loading branch information
wkia committed Jun 30, 2023
2 parents fad0a44 + a563c45 commit dd80ef4
Show file tree
Hide file tree
Showing 173 changed files with 10,000 additions and 5,483 deletions.
1 change: 0 additions & 1 deletion make/data/hotspot-symbols/symbols-unix
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ JVM_IsRecord
JVM_IsSameClassPackage
JVM_IsSharingEnabled
JVM_IsSupportedJNIVersion
JVM_IsThreadAlive
JVM_IsVMGeneratedMethodIx
JVM_LatestUserDefinedLoader
JVM_LoadLibrary
Expand Down
2 changes: 1 addition & 1 deletion make/modules/java.desktop/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ endif
################################################################################

# The fast floor code loses precision.
LCMS_CFLAGS=-DCMS_DONT_USE_FAST_FLOOR
LCMS_CFLAGS=-DCMS_DONT_USE_FAST_FLOOR -DCMS_NO_HALF_SUPPORT

ifeq ($(USE_EXTERNAL_LCMS), true)
# If we're using an external library, we'll just need the wrapper part.
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/c1/c1_LIRGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,8 @@ void LIRGenerator::do_Reference_get(Intrinsic* x) {

LIR_Opr result = rlock_result(x, T_OBJECT);
access_load_at(IN_HEAP | ON_WEAK_OOP_REF, T_OBJECT,
reference, LIR_OprFact::intConst(referent_offset), result);
reference, LIR_OprFact::intConst(referent_offset), result,
nullptr, info);
}

// Example: clazz.isInstance(object)
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/classfile/altHashing.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -31,9 +31,7 @@
/*
SipHash reference C implementation
Copyright (c) 2012-2021 Jean-Philippe Aumasson
<[email protected]>
Copyright (c) 2012-2014 Daniel J. Bernstein <[email protected]>
Copyright (c) 2016 Jean-Philippe Aumasson <[email protected]>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
Expand Down
123 changes: 54 additions & 69 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,90 +878,75 @@ void DeoptimizeObjectsALotThread::deoptimize_objects_alot_loop_all() {

JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, JavaThread* THREAD) {
JavaThread* new_thread = NULL;
{
MutexLocker mu(THREAD, Threads_lock);
switch (type) {
case compiler_t:
assert(comp != NULL, "Compiler instance missing.");
if (!InjectCompilerCreationFailure || comp->num_compiler_threads() == 0) {
CompilerCounters* counters = new CompilerCounters();
new_thread = new CompilerThread(queue, counters);
}
break;
case sweeper_t:
new_thread = new CodeCacheSweeperThread();
break;

switch (type) {
case compiler_t:
assert(comp != NULL, "Compiler instance missing.");
if (!InjectCompilerCreationFailure || comp->num_compiler_threads() == 0) {
CompilerCounters* counters = new CompilerCounters();
new_thread = new CompilerThread(queue, counters);
}
break;
case sweeper_t:
new_thread = new CodeCacheSweeperThread();
break;
#if defined(ASSERT) && COMPILER2_OR_JVMCI
case deoptimizer_t:
new_thread = new DeoptimizeObjectsALotThread();
break;
case deoptimizer_t:
new_thread = new DeoptimizeObjectsALotThread();
break;
#endif // ASSERT
default:
ShouldNotReachHere();
}

// At this point the new CompilerThread data-races with this startup
// thread (which I believe is the primoridal thread and NOT the VM
// thread). This means Java bytecodes being executed at startup can
// queue compile jobs which will run at whatever default priority the
// newly created CompilerThread runs at.


// At this point it may be possible that no osthread was created for the
// JavaThread due to lack of memory. We would have to throw an exception
// in that case. However, since this must work and we do not allow
// exceptions anyway, check and abort if this fails. But first release the
// lock.

if (new_thread != NULL && new_thread->osthread() != NULL) {

java_lang_Thread::set_thread(JNIHandles::resolve_non_null(thread_handle), new_thread);
default:
ShouldNotReachHere();
}

// Note that this only sets the JavaThread _priority field, which by
// definition is limited to Java priorities and not OS priorities.
// The os-priority is set in the CompilerThread startup code itself
// At this point the new CompilerThread data-races with this startup
// thread (which is the main thread and NOT the VM thread).
// This means Java bytecodes being executed at startup can
// queue compile jobs which will run at whatever default priority the
// newly created CompilerThread runs at.

java_lang_Thread::set_priority(JNIHandles::resolve_non_null(thread_handle), NearMaxPriority);

// Note that we cannot call os::set_priority because it expects Java
// priorities and we are *explicitly* using OS priorities so that it's
// possible to set the compiler thread priority higher than any Java
// thread.
// At this point it may be possible that no osthread was created for the
// JavaThread due to lack of resources. We will handle that failure below.
// Also check new_thread so that static analysis is happy.
if (new_thread != NULL && new_thread->osthread() != NULL) {
Handle thread_oop(THREAD, JNIHandles::resolve_non_null(thread_handle));

int native_prio = CompilerThreadPriority;
if (native_prio == -1) {
if (UseCriticalCompilerThreadPriority) {
native_prio = os::java_to_os_priority[CriticalPriority];
} else {
native_prio = os::java_to_os_priority[NearMaxPriority];
}
}
os::set_native_priority(new_thread, native_prio);
if (type == compiler_t) {
CompilerThread::cast(new_thread)->set_compiler(comp);
}

java_lang_Thread::set_daemon(JNIHandles::resolve_non_null(thread_handle));
// Note that we cannot call os::set_priority because it expects Java
// priorities and we are *explicitly* using OS priorities so that it's
// possible to set the compiler thread priority higher than any Java
// thread.

new_thread->set_threadObj(JNIHandles::resolve_non_null(thread_handle));
if (type == compiler_t) {
CompilerThread::cast(new_thread)->set_compiler(comp);
int native_prio = CompilerThreadPriority;
if (native_prio == -1) {
if (UseCriticalCompilerThreadPriority) {
native_prio = os::java_to_os_priority[CriticalPriority];
} else {
native_prio = os::java_to_os_priority[NearMaxPriority];
}
Threads::add(new_thread);
Thread::start(new_thread);
}
}
os::set_native_priority(new_thread, native_prio);

// First release lock before aborting VM.
if (new_thread == NULL || new_thread->osthread() == NULL) {
if (UseDynamicNumberOfCompilerThreads && type == compiler_t && comp->num_compiler_threads() > 0) {
if (new_thread != NULL) {
new_thread->smr_delete();
}
// Note that this only sets the JavaThread _priority field, which by
// definition is limited to Java priorities and not OS priorities.
JavaThread::start_internal_daemon(THREAD, new_thread, thread_oop, NearMaxPriority);

} else { // osthread initialization failure
if (UseDynamicNumberOfCompilerThreads && type == compiler_t
&& comp->num_compiler_threads() > 0) {
// The new thread is not known to Thread-SMR yet so we can just delete.
delete new_thread;
return NULL;
} else {
vm_exit_during_initialization("java.lang.OutOfMemoryError",
os::native_thread_creation_failed_msg());
}
vm_exit_during_initialization("java.lang.OutOfMemoryError",
os::native_thread_creation_failed_msg());
}

// Let go of Threads_lock before yielding
os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS)

return new_thread;
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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 @@ -257,9 +257,6 @@ JVM_StartThread(JNIEnv *env, jobject thread);
JNIEXPORT void JNICALL
JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);

JNIEXPORT jboolean JNICALL
JVM_IsThreadAlive(JNIEnv *env, jobject thread);

JNIEXPORT void JNICALL
JVM_SuspendThread(JNIEnv *env, jobject thread);

Expand Down
15 changes: 9 additions & 6 deletions src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,20 +726,21 @@ static bool check_exclusion_state_on_thread_start(JavaThread* jt) {
return true;
}

static JavaThread* get_native(jobject thread) {
ThreadsListHandle tlh;
static JavaThread* get_native(ThreadsListHandle& tlh, jobject thread) {
JavaThread* native_thread = NULL;
(void)tlh.cv_internal_thread_to_JavaThread(thread, &native_thread, NULL);
return native_thread;
}

jlong JfrJavaSupport::jfr_thread_id(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
return native_thread != NULL ? JFR_THREAD_ID(native_thread) : 0;
}

void JfrJavaSupport::exclude(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
if (native_thread != NULL) {
JfrThreadLocal::exclude(native_thread);
} else {
Expand All @@ -749,7 +750,8 @@ void JfrJavaSupport::exclude(jobject thread) {
}

void JfrJavaSupport::include(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
if (native_thread != NULL) {
JfrThreadLocal::include(native_thread);
} else {
Expand All @@ -759,7 +761,8 @@ void JfrJavaSupport::include(jobject thread) {
}

bool JfrJavaSupport::is_excluded(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
return native_thread != NULL ? native_thread->jfr_thread_local()->is_excluded() : is_thread_excluded(thread);
}

Expand Down
33 changes: 11 additions & 22 deletions src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,18 @@ static Thread* start_thread(instanceHandle thread_oop, ThreadFunction proc, TRAP
assert(thread_oop.not_null(), "invariant");
assert(proc != NULL, "invariant");

bool allocation_failed = false;
JavaThread* new_thread = NULL;
{
MutexLocker mu(THREAD, Threads_lock);
new_thread = new JavaThread(proc);
// At this point it may be possible that no
// osthread was created for the JavaThread due to lack of memory.
if (new_thread == NULL || new_thread->osthread() == NULL) {
delete new_thread;
allocation_failed = true;
} else {
java_lang_Thread::set_thread(thread_oop(), new_thread);
java_lang_Thread::set_priority(thread_oop(), NormPriority);
java_lang_Thread::set_daemon(thread_oop());
new_thread->set_threadObj(thread_oop());
Threads::add(new_thread);
}
}
if (allocation_failed) {
JfrJavaSupport::throw_out_of_memory_error("Unable to create native recording thread for JFR", CHECK_NULL);
JavaThread* new_thread = new JavaThread(proc);

// At this point it may be possible that no
// osthread was created for the JavaThread due to lack of resources.
if (new_thread->osthread() == NULL) {
delete new_thread;
JfrJavaSupport::throw_out_of_memory_error("Unable to create native recording thread for JFR", THREAD);
return NULL;
} else {
JavaThread::start_internal_daemon(THREAD, new_thread, thread_oop, NormPriority);
return new_thread;
}
Thread::start(new_thread);
return new_thread;
}

JfrPostBox* JfrRecorderThread::_post_box = NULL;
Expand Down
32 changes: 25 additions & 7 deletions src/hotspot/share/memory/resourceArea.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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 @@ -117,16 +117,34 @@ class ResourceArea: public Arena {
size_in_bytes(), state._size_in_bytes);
set_size_in_bytes(state._size_in_bytes);
state._chunk->next_chop();
assert(_hwm != state._hwm, "Sanity check: HWM moves when we have later chunks");
} else {
assert(size_in_bytes() == state._size_in_bytes, "Sanity check");
}
_chunk = state._chunk; // Roll back to saved chunk.
_hwm = state._hwm;
_max = state._max;

// Clear out this chunk (to detect allocation bugs)
if (ZapResourceArea) {
memset(state._hwm, badResourceValue, state._max - state._hwm);
if (_hwm != state._hwm) {
// HWM moved: resource area was used. Roll back!

char* replaced_hwm = _hwm;

_chunk = state._chunk;
_hwm = state._hwm;
_max = state._max;

// Clear out this chunk (to detect allocation bugs).
// If current chunk contains the replaced HWM, this means we are
// doing the rollback within the same chunk, and we only need to
// clear up to replaced HWM.
if (ZapResourceArea) {
char* limit = _chunk->contains(replaced_hwm) ? replaced_hwm : _max;
assert(limit >= _hwm, "Sanity check: non-negative memset size");
memset(_hwm, badResourceValue, limit - _hwm);
}
} else {
// No allocations. Nothing to rollback. Check it.
assert(_chunk == state._chunk, "Sanity check: idempotence");
assert(_hwm == state._hwm, "Sanity check: idempotence");
assert(_max == state._max, "Sanity check: idempotence");
}
}
};
Expand Down
Loading

0 comments on commit dd80ef4

Please sign in to comment.