Sync minimal to tiny swap_stack
@@ -62,13 +62,12 @@ ___lumen_swap_stack:
# Ensure we never perform initialization twice
mov r13, 0x0
# Store the original base pointer at the top of the stack
+ # And set the current base pointer to %rsp so that the unwinder
+ # knows where to find the caller base pointer
push rcx
- # Followed by the return address
- push rax
- # Finally we store a pointer to the bottom of the stack in the
- # parent call frame. The unwinder will expect to restore rbp
- # from this address
- push r9
+ # Store the current frame pointer
+ push rbp
+ mov rbp, rsp
# These CFI directives inform the unwinder of where it can expect
# to find the CFA relative to rbp. This matches how we've laid out the stack.
@@ -97,13 +96,15 @@ ___lumen_swap_stack:
# NOTE: This call never truly returns, as the exception handler calls __lumen_builtin_exit
# with the return value of the 'real' entry function, or with an exception if one
# is caught. However, swap_stack _does_ return for all other swaps, just not the first.
- jmp [r15]
+ call r14
+ jmp ___lumen_builtin_exit
L_resume:
# We land here only on a context switch, and since the last switch _away_ from
# this process pushed rbp on to the stack, and we don't need that value, we
# adjust the stack pointer accordingly.
add rsp, 8
+ .cfi_def_cfa rsp, 8
L_ret:
# At this point we will return back to where execution left off:
@@ -112,6 +113,6 @@ L_ret:
# it yielded, the address of which is 8 bytes above the current stack pointer.
# We pop and jmp rather than ret to avoid branch mispredictions.
pop rax
- jmp [rax]
+ jmp rax
.cfi_endproc
