Instead of pushing zero as the fake return address for a set-context call, push an address that points back into the primitive so that callstack walking can match the frame back to the subprimitive.
! Contexts
: jit-switch-context ( reg -- )
- ! Reset return value since its bogus right now, to avoid
- ! confusing the GC
- ESP -4 [+] 0 MOV
+ ! Push a bogus return address so the GC can track this frame back
+ ! to the owner
+ 0 CALL
! Make the new context the current one
ctx-reg swap MOV
! Contexts
: jit-switch-context ( reg -- )
- ! Reset return value since its bogus right now, to avoid
- ! confusing the GC
- RSP -8 [+] 0 MOV
+ ! Push a bogus return address so the GC can track this frame back
+ ! to the owner
+ 0 CALL
! Make the new context the current one
ctx-reg swap MOV