Skip to content

Commit

Permalink
Move clearing of ->work into unwind
Browse files Browse the repository at this point in the history
We can elide it in the case it is a stack frame, since we're going to be
removing it anyway.
  • Loading branch information
jnthn committed Nov 3, 2021
1 parent b6523de commit 7d4d163
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 15 additions & 4 deletions src/core/callstack.c
Expand Up @@ -617,16 +617,27 @@ MVMFrame * MVM_callstack_unwind_frame(MVMThreadContext *tc, MVMuint8 exceptional
tc->stack_current_region->alloc = (char *)tc->stack_top;
tc->stack_top = tc->stack_top->prev;
break;
case MVM_CALLSTACK_RECORD_HEAP_FRAME:
exit_frame(tc, ((MVMCallStackHeapFrame *)tc->stack_top)->frame);
case MVM_CALLSTACK_RECORD_HEAP_FRAME: {
MVMFrame *frame = ((MVMCallStackHeapFrame *)tc->stack_top)->frame;
/* NULL out ->work, to indicate the frame is no longer in dynamic scope.
* This is used by the GC to avoid marking stuff (this is needed for
* safety as otherwise we'd read freed memory), as well as by exceptions to
* ensure the target of an exception throw is indeed still in dynamic
* scope. */
frame->work = NULL;
exit_frame(tc, frame);
tc->stack_current_region->alloc = (char *)tc->stack_top;
tc->stack_top = tc->stack_top->prev;
break;
case MVM_CALLSTACK_RECORD_PROMOTED_FRAME:
exit_frame(tc, ((MVMCallStackPromotedFrame *)tc->stack_top)->frame);
}
case MVM_CALLSTACK_RECORD_PROMOTED_FRAME: {
MVMFrame *frame = ((MVMCallStackPromotedFrame *)tc->stack_top)->frame;
frame->work = NULL;
exit_frame(tc, frame);
tc->stack_current_region->alloc = (char *)tc->stack_top;
tc->stack_top = tc->stack_top->prev;
break;
}
case MVM_CALLSTACK_RECORD_DEOPT_FRAME:
/* Deopt it, but don't move stack top back, since we're either
* turning the current frame into a deoptimized one or will put
Expand Down
7 changes: 0 additions & 7 deletions src/core/frame.c
Expand Up @@ -875,13 +875,6 @@ static MVMuint64 remove_one_frame(MVMThreadContext *tc, MVMuint8 unwind) {
/* Clean up any allocations for argument working area. */
MVM_args_proc_cleanup(tc, &returner->params);

/* NULL out ->work, to indicate the frame is no longer in dynamic scope.
* This is used by the GC to avoid marking stuff (this is needed for
* safety as otherwise we'd read freed memory), as well as by exceptions to
* ensure the target of an exception throw is indeed still in dynamic
* scope. */
returner->work = NULL;

/* Unwind call stack entries. From this, we find out the caller. This may
* actually *not* be the caller in the frame, because of lazy deopt. Also
* it may invoke something else, in which case we go no further and just
Expand Down

0 comments on commit 7d4d163

Please sign in to comment.