From c23b53a5d060a69bfb91a49d24dd9340ea23d6db Mon Sep 17 00:00:00 2001 From: Dmitri Pivkine Date: Tue, 12 Nov 2024 14:49:38 -0500 Subject: [PATCH] Extend vmState to pre/post collect Current vmState for Collector does not include pre- and post- collect. If crash occur in pre- or post- collect vmState can be misleading. Signed-off-by: Dmitri Pivkine --- gc/base/Collector.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gc/base/Collector.cpp b/gc/base/Collector.cpp index fa205ccfcb3..c03a3f8dc32 100644 --- a/gc/base/Collector.cpp +++ b/gc/base/Collector.cpp @@ -489,6 +489,8 @@ MM_Collector::garbageCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* calling { Assert_MM_mustHaveExclusiveVMAccess(env->getOmrVMThread()); + uintptr_t vmState = env->pushVMstate(getVMStateID()); + Assert_MM_true(NULL == env->_cycleState); preCollect(env, callingSubSpace, allocateDescription, gcCode); Assert_MM_true(NULL != env->_cycleState); @@ -496,16 +498,12 @@ MM_Collector::garbageCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* calling /* ensure that we aren't trying to collect while in a NoGC allocation */ Assert_MM_false(env->_isInNoGCAllocationCall); - uintptr_t vmState = env->pushVMstate(getVMStateID()); - /* First do any pre-collection initialization of the collector*/ setupForGC(env); /* perform the collection */ _gcCompleted = internalGarbageCollect(env, callingSubSpace, allocateDescription); - env->popVMstate(vmState); - /* now, see if we need to resume an allocation or replenishment attempt */ void* postCollectAllocationResult = NULL; if (NULL != allocateDescription) { @@ -527,6 +525,8 @@ MM_Collector::garbageCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* calling Assert_MM_true(NULL != env->_cycleState); env->_cycleState = NULL; + env->popVMstate(vmState); + return postCollectAllocationResult; }