Skip to content

Commit e342531

Browse files
committed
New flag
Signed-off-by: Graham Chapman <[email protected]>
1 parent 4df653a commit e342531

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

runtime/jvmti/jvmtiClass.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,9 @@ redefineClassesCommon(jvmtiEnv* env,
12331233
/* Eliminate dark matter so that none will be encountered in prepareToFixMemberNames(). */
12341234
UDATA savedAllowUserHeapWalkFlag = vm->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
12351235
vm->requiredDebugAttributes |= J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1236+
vm->alreadyHaveExclusive = TRUE;
12361237
vm->memoryManagerFunctions->j9gc_modron_global_collect_with_overrides(currentThread, J9MMCONSTANT_EXPLICIT_GC_EXCLUSIVE_VMACCESS_ALREADY_ACQUIRED);
1238+
vm->alreadyHaveExclusive = FALSE;
12371239
if (0 == savedAllowUserHeapWalkFlag) {
12381240
/* Clear the flag to restore its original value. */
12391241
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;

runtime/oti/j9nonbuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5916,6 +5916,7 @@ typedef struct J9JavaVM {
59165916
UDATA addModulesCount;
59175917
UDATA safePointState;
59185918
UDATA safePointResponseCount;
5919+
UDATA alreadyHaveExclusive;
59195920
struct J9VMRuntimeStateListener vmRuntimeStateListener;
59205921
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_USES_FLUSH)
59215922
#if defined(J9UNIX) || defined(AIXPPC)

runtime/vm/VMAccess.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,8 @@ acquireExclusiveVMAccessFromExternalThread(J9JavaVM * vm)
755755
UDATA vmResponsesExpected = 0;
756756
UDATA jniResponsesExpected = 0;
757757

758-
/* If safepoiont exclusive has already been acquired, nothing need be done here */
759-
if (J9_XACCESS_EXCLUSIVE == vm->safePointState) {
758+
/* If exclusive has already been acquired, nothing need be done here */
759+
if (vm->alreadyHaveExclusive) {
760760
return;
761761
}
762762

@@ -842,8 +842,8 @@ releaseExclusiveVMAccessFromExternalThread(J9JavaVM * vm)
842842
{
843843
J9VMThread * currentThread;
844844

845-
/* If safepoiont exclusive has already been acquired, nothing need be done here */
846-
if (J9_XACCESS_EXCLUSIVE == vm->safePointState) {
845+
/* If exclusive has already been acquired, nothing need be done here */
846+
if (vm->alreadyHaveExclusive) {
847847
return;
848848
}
849849

@@ -924,8 +924,8 @@ requestExclusiveVMAccessMetronomeTemp(J9JavaVM *vm, UDATA block, UDATA *vmRespon
924924
UDATA jniResponsesExpected = 0;
925925
*gcPriority = J9THREAD_PRIORITY_MAX;
926926

927-
/* If safepoiont exclusive has already been acquired, nothing need be done here */
928-
if (J9_XACCESS_EXCLUSIVE == vm->safePointState) {
927+
/* If exclusive has already been acquired, nothing need be done here */
928+
if (vm->alreadyHaveExclusive) {
929929
return TRUE;
930930
}
931931

@@ -1028,22 +1028,24 @@ waitForExclusiveVMAccessMetronomeTemp(J9VMThread * vmThread, UDATA vmResponsesRe
10281028
{
10291029
J9JavaVM *vm = vmThread->javaVM;
10301030

1031-
/* No need to wait if we already have safepoint exclusive */
1032-
if (J9_XACCESS_EXCLUSIVE != vm->safePointState) {
1033-
waitForResponseFromExternalThread(vmThread->javaVM, vmResponsesRequired, jniResponsesRequired);
1031+
/* If exclusive has already been acquired, nothing need be done here */
1032+
if (vm->alreadyHaveExclusive) {
1033+
return;
1034+
}
10341035

1035-
VM_VMAccess::backOffFromSafePoint(vmThread);
1036-
1037-
/* Do not wait on JAVA_SUSPEND, since we are not real JAVA thread.
1038-
* This patch was needed for some debug scenarios with JVMTI, that would result in a deadlock otherwise.
1039-
* TODO: re-examine with latest JDWP
1040-
*/
1041-
internalAcquireVMAccessNoMutexWithMask(vmThread, J9_PUBLIC_FLAGS_HALT_THREAD_ANY_NO_JAVA_SUSPEND);
1036+
waitForResponseFromExternalThread(vmThread->javaVM, vmResponsesRequired, jniResponsesRequired);
10421037

1043-
Assert_VM_true(vmThread->omrVMThread->exclusiveCount==0);
1038+
VM_VMAccess::backOffFromSafePoint(vmThread);
10441039

1045-
++(vmThread->omrVMThread->exclusiveCount);
1046-
}
1040+
/* Do not wait on JAVA_SUSPEND, since we are not real JAVA thread.
1041+
* This patch was needed for some debug scenarios with JVMTI, that would result in a deadlock otherwise.
1042+
* TODO: re-examine with latest JDWP
1043+
*/
1044+
internalAcquireVMAccessNoMutexWithMask(vmThread, J9_PUBLIC_FLAGS_HALT_THREAD_ANY_NO_JAVA_SUSPEND);
1045+
1046+
Assert_VM_true(vmThread->omrVMThread->exclusiveCount==0);
1047+
1048+
++(vmThread->omrVMThread->exclusiveCount);
10471049
}
10481050

10491051
void

0 commit comments

Comments
 (0)