Skip to content

Commit dfb74f5

Browse files
committed
Eliminate dark matter before determining classes to recreate
Eliminating dark matter before determining classes to recreate prevents dying and unloaded classes to be encountered while recreating RAM classes. Related: #18750 Signed-off-by: Babneet Singh <[email protected]>
1 parent 0cbeed0 commit dfb74f5

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

runtime/jvmti/jvmtiClass.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ redefineClassesCommon(jvmtiEnv* env,
11311131
J9HashTable * methodEquivalences = NULL;
11321132
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
11331133
j9object_t memberNamesToFix = NULL;
1134+
UDATA savedAllowUserHeapWalkFlag = 0;
11341135
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
11351136
#ifdef J9VM_INTERP_NATIVE_SUPPORT
11361137
J9JVMTIHCRJitEventData jitEventData;
@@ -1224,28 +1225,29 @@ redefineClassesCommon(jvmtiEnv* env,
12241225
}
12251226
}
12261227

1227-
/* Determine all ROM classes which need a new RAM class, and pair them with their current RAM class */
1228-
1229-
rc = determineClassesToRecreate(currentThread, class_count, specifiedClasses, &classPairs,
1230-
&methodPairs, jitEventDataPtr, !extensionsEnabled);
1231-
if (rc == JVMTI_ERROR_NONE) {
12321228
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
1233-
/* Eliminate dark matter so that none will be encountered in prepareToFixMemberNames(). */
1234-
UDATA savedAllowUserHeapWalkFlag = vm->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1235-
vm->requiredDebugAttributes |= J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1229+
/* Eliminate dark matter so that none will be encountered in prepareToFixMemberNames(). */
1230+
savedAllowUserHeapWalkFlag = vm->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1231+
vm->requiredDebugAttributes |= J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
12361232

1237-
/* This is to help with Metronome to avoid requesting Exclusive if we already have SafePoint, which may not look as Exclusive to the requester thread */
1238-
vm->alreadyHaveExclusive = TRUE;
1233+
/* This is to help with Metronome to avoid requesting Exclusive if we already have SafePoint, which may not look as Exclusive to the requester thread */
1234+
vm->alreadyHaveExclusive = TRUE;
12391235

1240-
vm->memoryManagerFunctions->j9gc_modron_global_collect_with_overrides(currentThread, J9MMCONSTANT_EXPLICIT_GC_EXCLUSIVE_VMACCESS_ALREADY_ACQUIRED);
1236+
vm->memoryManagerFunctions->j9gc_modron_global_collect_with_overrides(currentThread, J9MMCONSTANT_EXPLICIT_GC_EXCLUSIVE_VMACCESS_ALREADY_ACQUIRED);
12411237

1242-
vm->alreadyHaveExclusive = FALSE;
1238+
vm->alreadyHaveExclusive = FALSE;
12431239

1244-
if (0 == savedAllowUserHeapWalkFlag) {
1245-
/* Clear the flag to restore its original value. */
1246-
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1247-
}
1240+
if (0 == savedAllowUserHeapWalkFlag) {
1241+
/* Clear the flag to restore its original value. */
1242+
vm->requiredDebugAttributes &= ~J9VM_DEBUG_ATTRIBUTE_ALLOW_USER_HEAP_WALK;
1243+
}
1244+
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
12481245

1246+
/* Determine all ROM classes which need a new RAM class, and pair them with their current RAM class. */
1247+
rc = determineClassesToRecreate(currentThread, class_count, specifiedClasses, &classPairs,
1248+
&methodPairs, jitEventDataPtr, !extensionsEnabled);
1249+
if (rc == JVMTI_ERROR_NONE) {
1250+
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
12491251
/* Identify the MemberNames needing fix-up based on classPairs. */
12501252
memberNamesToFix = prepareToFixMemberNames(currentThread, classPairs);
12511253
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */

0 commit comments

Comments
 (0)