Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0.38) Handle lock reservation in single thread mode #16840

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions runtime/vm/ObjectMonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2022 IBM Corp. and others
* Copyright (c) 2001, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -316,27 +316,30 @@ objectMonitorEnterNonBlocking(J9VMThread *currentThread, j9object_t object)
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) || (JAVA_SPEC_VERSION >= 16)
J9Class * objClass = J9OBJECT_CLAZZ(currentThread, object);
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) || (JAVA_SPEC_VERSION >= 16) */
#if defined(J9VM_OPT_CRIU_SUPPORT)
BOOLEAN retry = FALSE;
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_IS_J9CLASS_VALUETYPE(objClass)) {
result = J9_OBJECT_MONITOR_VALUE_TYPE_IMSE;
goto done;
}
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#if JAVA_SPEC_VERSION >= 16
if (J9_IS_J9CLASS_VALUEBASED(objClass)) {
U_32 runtimeFlags2 = vm->extendedRuntimeFlags2;
if (J9_ARE_ALL_BITS_SET(runtimeFlags2, J9_EXTENDED_RUNTIME2_VALUE_BASED_EXCEPTION)) {
result = J9_OBJECT_MONITOR_VALUE_TYPE_IMSE;
goto done;
goto done;
} else if (J9_ARE_ALL_BITS_SET(runtimeFlags2, J9_EXTENDED_RUNTIME2_VALUE_BASED_WARNING)) {
PORT_ACCESS_FROM_VMC(currentThread);
const J9UTF8* className = J9ROMCLASS_CLASSNAME(J9OBJECT_CLAZZ(currentThread, object)->romClass);
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_BASED, J9UTF8_LENGTH(className), J9UTF8_DATA(className));
}
}
#endif /* JAVA_SPEC_VERSION >= 16 */

restart:
if (NULL == lwEA) {
/* out of memory */
Expand Down Expand Up @@ -493,6 +496,11 @@ objectMonitorEnterNonBlocking(J9VMThread *currentThread, j9object_t object)
J9VMTHREAD_SET_BLOCKINGENTEROBJECT(currentThread, currentThread, object);
#if defined(J9VM_OPT_CRIU_SUPPORT)
if (J9_IS_SINGLE_THREAD_MODE(vm)) {
if (OBJECT_HEADER_LOCK_RESERVED == (J9_LOAD_LOCKWORD(currentThread, lwEA) & (OBJECT_HEADER_LOCK_RESERVED + OBJECT_HEADER_LOCK_INFLATED)) && !retry) {
cancelLockReservation(currentThread);
retry = TRUE;
goto restart;
}
result = J9_OBJECT_MONITOR_CRIU_SINGLE_THREAD_MODE_THROW;
} else
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
Expand Down