1# Test that wasm-binaryen-finalize --check-stack-overflow correctly 2# inserts stack chekc handlers. 3 4.globl stackRestore 5.globl stackAlloc 6 7.globaltype __stack_pointer, i32 8 9stackRestore: 10 .functype stackRestore(i32) -> () 11 local.get 0 12 global.set __stack_pointer 13 end_function 14 15stackAlloc: 16 .functype stackAlloc(i32) -> (i32) 17 .local i32, i32 18 global.get __stack_pointer 19 # Get arg 0 -> number of bytes to allocate 20 local.get 0 21 # Stack grows down. Subtract arg0 from __stack_pointer 22 i32.sub 23 # Align result by anding with ~15 24 i32.const 0xfffffff0 25 i32.and 26 local.tee 1 27 global.set __stack_pointer 28 local.get 1 29 end_function 30 31.globl main 32main: 33 .functype main () -> () 34 end_function 35 36.export_name stackAlloc, stackAlloc 37.export_name stackSave, stackSave 38.export_name stackRestore, stackRestore 39