Path: blob/main/crates/fiber/src/stackswitch/arm.rs
1692 views
// A WORD OF CAUTION1//2// This entire file basically needs to be kept in sync with itself. It's not3// really possible to modify just one bit of this file without understanding4// all the other bits. Documentation tries to reference various bits here and5// there but try to make sure to read over everything before tweaking things!6//7// Also at this time this file is heavily based off the x86_64 file, so you'll8// probably want to read that one as well.910use wasmtime_asm_macros::asm_func;1112// fn(top_of_stack(%r0): *mut u8)13asm_func!(14wasmtime_versioned_export_macros::versioned_stringify_ident!(wasmtime_fiber_switch),15"16// Save callee-saved registers17push {{r4-r11,lr}}1819// Swap stacks, recording our current stack pointer20ldr r4, [r0, #-0x08]21str sp, [r0, #-0x08]22mov sp, r42324// Restore and return25pop {{r4-r11,lr}}26bx lr27",28);2930// fn(31// top_of_stack(%r0): *mut u8,32// entry_point(%r1): extern fn(*mut u8, *mut u8),33// entry_arg0(%r2): *mut u8,34// )35asm_func!(36wasmtime_versioned_export_macros::versioned_stringify_ident!(wasmtime_fiber_init),37"38adr r3, {start}39str r3, [r0, #-0x0c] // => lr40str r0, [r0, #-0x10] // => r1141str r1, [r0, #-0x14] // => r1042str r2, [r0, #-0x18] // => r94344add r3, r0, #-0x2c45str r3, [r0, #-0x08]46bx lr47",48start = sym super::wasmtime_fiber_start,49);5051asm_func!(52wasmtime_versioned_export_macros::versioned_stringify_ident!(wasmtime_fiber_start),53"54.cfi_startproc simple55.cfi_def_cfa_offset 056// See the x86_64 file for more commentary on what these CFI directives57// are doing. Like over there note that the relative offsets to58// registers here match the frame layout in `wasmtime_fiber_switch`.59//60// TODO: this is only lightly tested. This gets backtraces in gdb but61// not at runtime. Perhaps the libgcc at runtime was too old? Doesn't62// support something here? Unclear. Will need investigation if someone63// ends up needing this and it still doesn't work.64.cfi_escape 0x0f, /* DW_CFA_def_cfa_expression */ \655, /* the byte length of this expression */ \660x7d, 0x00, /* DW_OP_breg14(%sp) + 0 */ \670x06, /* DW_OP_deref */ \680x23, 0x24 /* DW_OP_plus_uconst 0x24 */6970.cfi_rel_offset lr, -0x0471.cfi_rel_offset r11, -0x0872.cfi_rel_offset r10, -0x0c73.cfi_rel_offset r9, -0x1074.cfi_rel_offset r8, -0x1475.cfi_rel_offset r7, -0x1876.cfi_rel_offset r6, -0x1c77.cfi_rel_offset r5, -0x2078.cfi_rel_offset r4, -0x247980mov r1, r1181mov r0, r982blx r1083.cfi_endproc84",85);868788