Skip to content

Commit

Permalink
Changes suggested by Coleen
Browse files Browse the repository at this point in the history
  • Loading branch information
fparain committed Jul 9, 2024
1 parent a40efc3 commit 18d7295
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/hotspot/share/runtime/synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,21 +306,8 @@ jlong ObjectSynchronizer::_last_async_deflation_time_ns = 0;
static uintx _no_progress_cnt = 0;
static bool _no_progress_skip_increment = false;

#define CHECK_THROW_NOSYNC_IE(obj) \
if (obj->klass()->is_inline_klass()) { \
ResourceMark rm(THREAD); \
const char* desc = "Cannot synchronize on an instance of value class "; \
const char* className = obj->klass()->external_name(); \
size_t msglen = strlen(desc) + strlen(className) + 1; \
char* message = NEW_RESOURCE_ARRAY(char, msglen); \
if (nullptr == message) { \
THROW_MSG(vmSymbols::java_lang_IdentityException(), className); \
} else { \
jio_snprintf(message, msglen, "%s%s", desc, className); \
THROW_MSG(vmSymbols::java_lang_IdentityException(), message); \
} \
}

// These checks are required for wait, notify and exit to avoid inflating the monitor to
// find out this inline type object cannot be locked.
#define CHECK_THROW_NOSYNC_IMSE(obj) \
if (EnableValhalla && (obj)->mark().is_inline_type()) { \
JavaThread* THREAD = current; \
Expand Down Expand Up @@ -555,10 +542,7 @@ void ObjectSynchronizer::enter_for(Handle obj, BasicLock* lock, JavaThread* lock
// the locking_thread with respect to the current thread. Currently only used when
// deoptimizing and re-locking locks. See Deoptimization::relock_objects
assert(locking_thread == Thread::current() || locking_thread->is_obj_deopt_suspend(), "must be");
if (obj->klass()->is_inline_klass()) {
// JITed code should never have locked an instance of a value class
ShouldNotReachHere();
}
assert(!EnableValhalla || !obj->klass()->is_inline_klass(), "JITed code should never have locked an instance of a value class");
if (!enter_fast_impl(obj, lock, locking_thread)) {
// Inflated ObjectMonitor::enter_for is required

Expand All @@ -578,7 +562,7 @@ void ObjectSynchronizer::enter_for(Handle obj, BasicLock* lock, JavaThread* lock
void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, JavaThread* current) {
assert(current == Thread::current(), "must be");
JavaThread* THREAD = current;
CHECK_THROW_NOSYNC_IE(obj);
assert(!EnableValhalla || !obj->klass()->is_inline_klass(), "This method should never be called on an instance of an inline class");
if (!enter_fast_impl(obj, lock, current)) {
// Inflated ObjectMonitor::enter is required

Expand Down Expand Up @@ -787,7 +771,15 @@ void ObjectSynchronizer::jni_enter(Handle obj, JavaThread* current) {
handle_sync_on_value_based_class(obj, current);
}

CHECK_THROW_NOSYNC_IE(obj);
if (EnableValhalla && obj->klass()->is_inline_klass()) {
ResourceMark rm(THREAD);
const char* desc = "Cannot synchronize on an instance of value class ";
const char* className = obj->klass()->external_name();
size_t msglen = strlen(desc) + strlen(className) + 1;
char* message = NEW_RESOURCE_ARRAY(char, msglen);
assert(message != nullptr, "NEW_RESOURCE_ARRAY should have called vm_exit_out_of_memory and not return nullptr");
THROW_MSG(vmSymbols::java_lang_IdentityException(), className);
}

// the current locking is from JNI instead of Java code
current->set_current_pending_monitor_is_from_java(false);
Expand Down

0 comments on commit 18d7295

Please sign in to comment.