Skip to content

Commit

Permalink
Extend vmState to pre/post collect
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dmitripivkine committed Nov 13, 2024
1 parent 3da49aa commit c23b53a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gc/base/Collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,23 +489,21 @@ 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);

/* 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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit c23b53a

Please sign in to comment.