Skip to content

Commit

Permalink
Save vector/float registers on ARM too.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 20, 2020
1 parent 1011681 commit e40bd97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
22 changes: 15 additions & 7 deletions crates/fiber/src/arch/aarch64.S
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ FUNCTION(wasmtime_fiber_switch):
stp x24, x23, [sp, -16]!
stp x26, x25, [sp, -16]!
stp x28, x27, [sp, -16]!
stp d9, d8, [sp, -16]!
stp d11, d10, [sp, -16]!
stp d13, d12, [sp, -16]!
stp d15, d14, [sp, -16]!

// Load our previously saved stack pointer to resume to, and save off our
// current stack pointer on where to come back to eventually.
Expand All @@ -36,6 +40,10 @@ FUNCTION(wasmtime_fiber_switch):
// Switch to the new stack and restore all our callee-saved registers after
// the switch and return to our new stack.
mov sp, x8
ldp d15, d14, [sp], 16
ldp d13, d12, [sp], 16
ldp d11, d10, [sp], 16
ldp d9, d8, [sp], 16
ldp x28, x27, [sp], 16
ldp x26, x25, [sp], 16
ldp x24, x23, [sp], 16
Expand All @@ -58,9 +66,9 @@ FUNCTION(wasmtime_fiber_init):
stp x0, x8, [x0, -0x28] // x0 => x19, x8 => lr
stp x2, x1, [x0, -0x38] // x1 => x20, x2 => x21

// `wasmtime_fiber_switch` has an 0x60 byte stack, and we add 0x10 more for
// `wasmtime_fiber_switch` has an 0xa0 byte stack, and we add 0x10 more for
// the original reserved 16 bytes.
add x8, x0, -0x70
add x8, x0, -0xb0
str x8, [x0, -0x10]
ret
SIZE(wasmtime_fiber_init)
Expand All @@ -73,11 +81,11 @@ FUNCTION(wasmtime_fiber_start):
// See the x86_64 file for more commentary on what these CFI directives are
// doing. Like over there note that the relative offsets to registers here
// match the frame layout in `wasmtime_fiber_switch`.
.cfi_escape 0x0f, /* DW_CFA_def_cfa_expression */ \
4, /* the byte length of this expression */ \
0x6f, /* DW_OP_reg31(%sp) */ \
0x06, /* DW_OP_deref */ \
0x23, 0x60 /* DW_OP_plus_uconst 0x60 */
.cfi_escape 0x0f, /* DW_CFA_def_cfa_expression */ \
5, /* the byte length of this expression */ \
0x6f, /* DW_OP_reg31(%sp) */ \
0x06, /* DW_OP_deref */ \
0x23, 0xa0, 0x1 /* DW_OP_plus_uconst 0xa0 */

.cfi_rel_offset lr, -0x10
.cfi_rel_offset x19, -0x18
Expand Down
8 changes: 4 additions & 4 deletions crates/fiber/src/arch/x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ FUNCTION(wasmtime_fiber_start):
// the return address of the caller's `call` instruction. Hence we offset
// another 0x38 bytes.
.cfi_escape 0x0f, /* DW_CFA_def_cfa_expression */ \
5, /* the byte length of this expression */ \
0x77, 0x18, /* DW_OP_breg7 (%rsp) + 0x18 */ \
0x06, /* DW_OP_deref */ \
0x23, 0x38 /* DW_OP_plus_uconst 0x38 */
5, /* the byte length of this expression */ \
0x77, 0x18, /* DW_OP_breg7 (%rsp) + 0x18 */ \
0x06, /* DW_OP_deref */ \
0x23, 0x38 /* DW_OP_plus_uconst 0x38 */

// And now after we've indicated where our CFA is for our parent function,
// we can define that where all of the saved registers are located. This
Expand Down

0 comments on commit e40bd97

Please sign in to comment.