diff options
26 files changed, 214 insertions, 183 deletions
diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index 00d5ae026..1867d1d7b 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -67,6 +67,8 @@ def generate_wat_files(llvm_bin, emscripten_root): obj_path, '-o', wasm_path, '--allow-undefined', '--export', '__wasm_call_ctors', + '--export', '__start_em_asm', + '--export', '__stop_em_asm', '--global-base=568', ] # We had a regression where this test only worked if debug names diff --git a/test/lld/basic_safe_stack.wat b/test/lld/basic_safe_stack.wat index 4b8853f15..9d1009529 100644 --- a/test/lld/basic_safe_stack.wat +++ b/test/lld/basic_safe_stack.wat @@ -3,8 +3,7 @@ (type $i32_=>_none (func (param i32))) (type $i32_=>_i32 (func (param i32) (result i32))) (memory $0 2) - (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "stackRestore" (func $stackRestore)) @@ -13,18 +12,18 @@ (func $__wasm_call_ctors ) (func $stackRestore (param $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.get $0) ) ) (func $stackAlloc (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $1 (i32.and (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (local.get $0) ) (i32.const -16) diff --git a/test/lld/basic_safe_stack.wat.out b/test/lld/basic_safe_stack.wat.out index 15f108a3e..09c440ece 100644 --- a/test/lld/basic_safe_stack.wat.out +++ b/test/lld/basic_safe_stack.wat.out @@ -5,8 +5,7 @@ (type $i32_=>_i32 (func (param i32) (result i32))) (import "env" "__handle_stack_overflow" (func $__handle_stack_overflow)) (memory $0 2) - (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (global $__stack_base (mut i32) (i32.const 0)) (global $__stack_limit (mut i32) (i32.const 0)) (export "memory" (memory $0)) @@ -35,7 +34,7 @@ ) (call $__handle_stack_overflow) ) - (global.set $global$0 + (global.set $__stack_pointer (local.get $1) ) ) @@ -51,7 +50,7 @@ (local.tee $1 (i32.and (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (local.get $0) ) (i32.const -16) @@ -67,7 +66,7 @@ ) (call $__handle_stack_overflow) ) - (global.set $global$0 + (global.set $__stack_pointer (local.get $3) ) ) @@ -88,7 +87,7 @@ (; --BEGIN METADATA -- { - "tableSize": 1, + "tableSize": 0, "declares": [ "__handle_stack_overflow" ], diff --git a/test/lld/em_asm.wat b/test/lld/em_asm.wat index 41d4d127b..0d035496a 100644 --- a/test/lld/em_asm.wat +++ b/test/lld/em_asm.wat @@ -5,28 +5,33 @@ (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (data $.rodata (i32.const 568) "\00ii\00i\00") + (data $em_asm (i32.const 574) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66208)) + (global $__stack_pointer (mut i32) (i32.const 66208)) + (global $global$1 i32 (i32.const 574)) + (global $global$2 i32 (i32.const 658)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) + (export "__start_em_asm" (global $global$1)) + (export "__stop_em_asm" (global $global$2)) (func $__wasm_call_ctors ) (func $__original_main (result i32) (local $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 32) ) ) ) (drop (call $emscripten_asm_const_int + (i32.const 574) (i32.const 568) - (i32.const 601) (i32.const 0) ) ) @@ -37,8 +42,8 @@ (i32.store (local.get $0) (call $emscripten_asm_const_int - (i32.const 602) - (i32.const 622) + (i32.const 607) + (i32.const 569) (i32.add (local.get $0) (i32.const 16) @@ -47,12 +52,12 @@ ) (drop (call $emscripten_asm_const_int - (i32.const 625) - (i32.const 656) + (i32.const 627) + (i32.const 572) (local.get $0) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 32) diff --git a/test/lld/em_asm.wat.mem.mem b/test/lld/em_asm.wat.mem.mem Binary files differindex e06dbba87..0059fdcca 100644 --- a/test/lld/em_asm.wat.mem.mem +++ b/test/lld/em_asm.wat.mem.mem diff --git a/test/lld/em_asm.wat.mem.out b/test/lld/em_asm.wat.mem.out index ca85963ad..22d0fdc5c 100644 --- a/test/lld/em_asm.wat.mem.out +++ b/test/lld/em_asm.wat.mem.out @@ -6,7 +6,9 @@ (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) (memory $0 2) (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66208)) + (global $__stack_pointer (mut i32) (i32.const 66208)) + (global $global$1 i32 (i32.const 574)) + (global $global$2 i32 (i32.const 658)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -15,18 +17,18 @@ ) (func $__original_main (result i32) (local $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 32) ) ) ) (drop (call $emscripten_asm_const_int + (i32.const 574) (i32.const 568) - (i32.const 601) (i32.const 0) ) ) @@ -37,8 +39,8 @@ (i32.store (local.get $0) (call $emscripten_asm_const_int - (i32.const 602) - (i32.const 622) + (i32.const 607) + (i32.const 569) (i32.add (local.get $0) (i32.const 16) @@ -47,12 +49,12 @@ ) (drop (call $emscripten_asm_const_int - (i32.const 625) - (i32.const 656) + (i32.const 627) + (i32.const 572) (local.get $0) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 32) @@ -68,9 +70,9 @@ --BEGIN METADATA -- { "asmConsts": { - "568": "{ Module.print(\"Hello world\"); }", - "602": "{ return $0 + $1; }", - "625": "{ Module.print(\"Got \" + $0); }" + "574": "{ Module.print(\"Hello world\"); }", + "607": "{ return $0 + $1; }", + "627": "{ Module.print(\"Got \" + $0); }" }, "tableSize": 1, "declares": [ diff --git a/test/lld/em_asm.wat.out b/test/lld/em_asm.wat.out index 487f51c14..167baddde 100644 --- a/test/lld/em_asm.wat.out +++ b/test/lld/em_asm.wat.out @@ -5,9 +5,12 @@ (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (data $.rodata (i32.const 568) "\00ii\00i\00") + (data $em_asm (i32.const 574) "") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66208)) + (global $__stack_pointer (mut i32) (i32.const 66208)) + (global $global$1 i32 (i32.const 574)) + (global $global$2 i32 (i32.const 658)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -16,18 +19,18 @@ ) (func $__original_main (result i32) (local $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 32) ) ) ) (drop (call $emscripten_asm_const_int + (i32.const 574) (i32.const 568) - (i32.const 601) (i32.const 0) ) ) @@ -38,8 +41,8 @@ (i32.store (local.get $0) (call $emscripten_asm_const_int - (i32.const 602) - (i32.const 622) + (i32.const 607) + (i32.const 569) (i32.add (local.get $0) (i32.const 16) @@ -48,12 +51,12 @@ ) (drop (call $emscripten_asm_const_int - (i32.const 625) - (i32.const 656) + (i32.const 627) + (i32.const 572) (local.get $0) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 32) @@ -69,9 +72,9 @@ --BEGIN METADATA -- { "asmConsts": { - "568": "{ Module.print(\"Hello world\"); }", - "602": "{ return $0 + $1; }", - "625": "{ Module.print(\"Got \" + $0); }" + "574": "{ Module.print(\"Hello world\"); }", + "607": "{ return $0 + $1; }", + "627": "{ Module.print(\"Got \" + $0); }" }, "tableSize": 1, "declares": [ diff --git a/test/lld/em_asm64.wat b/test/lld/em_asm64.wat index 2c41c31b7..c2e14e3fa 100644 --- a/test/lld/em_asm64.wat +++ b/test/lld/em_asm64.wat @@ -5,12 +5,17 @@ (type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32))) (memory $0 i64 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (data $.rodata (i64.const 568) "\00ii\00i\00") + (data $em_asm (i64.const 574) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") (table $0 1 1 funcref) (global $__stack_pointer (mut i64) (i64.const 66208)) + (global $global$1 i32 (i32.const 574)) + (global $global$2 i32 (i32.const 658)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) + (export "__start_em_asm" (global $global$1)) + (export "__stop_em_asm" (global $global$2)) (func $__wasm_call_ctors ) (func $__original_main (result i32) @@ -25,8 +30,8 @@ ) (drop (call $emscripten_asm_const_int + (i64.const 574) (i64.const 568) - (i64.const 601) (i64.const 0) ) ) @@ -37,8 +42,8 @@ (i32.store (local.get $0) (call $emscripten_asm_const_int - (i64.const 602) - (i64.const 622) + (i64.const 607) + (i64.const 569) (i64.add (local.get $0) (i64.const 16) @@ -47,8 +52,8 @@ ) (drop (call $emscripten_asm_const_int - (i64.const 625) - (i64.const 656) + (i64.const 627) + (i64.const 572) (local.get $0) ) ) diff --git a/test/lld/em_asm64.wat.out b/test/lld/em_asm64.wat.out index 13a279cd4..1678b83f2 100644 --- a/test/lld/em_asm64.wat.out +++ b/test/lld/em_asm64.wat.out @@ -5,9 +5,12 @@ (type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32))) (memory $0 i64 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (data $.rodata (i64.const 568) "\00ii\00i\00") + (data $em_asm (i64.const 574) "") (table $0 1 1 funcref) (global $__stack_pointer (mut i64) (i64.const 66208)) + (global $global$1 i32 (i32.const 574)) + (global $global$2 i32 (i32.const 658)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -26,8 +29,8 @@ ) (drop (call $emscripten_asm_const_int + (i64.const 574) (i64.const 568) - (i64.const 601) (i64.const 0) ) ) @@ -38,8 +41,8 @@ (i32.store (local.get $0) (call $emscripten_asm_const_int - (i64.const 602) - (i64.const 622) + (i64.const 607) + (i64.const 569) (i64.add (local.get $0) (i64.const 16) @@ -48,8 +51,8 @@ ) (drop (call $emscripten_asm_const_int - (i64.const 625) - (i64.const 656) + (i64.const 627) + (i64.const 572) (local.get $0) ) ) @@ -69,9 +72,9 @@ --BEGIN METADATA -- { "asmConsts": { - "568": "{ Module.print(\"Hello world\"); }", - "602": "{ return $0 + $1; }", - "625": "{ Module.print(\"Got \" + $0); }" + "574": "{ Module.print(\"Hello world\"); }", + "607": "{ return $0 + $1; }", + "627": "{ Module.print(\"Got \" + $0); }" }, "tableSize": 1, "declares": [ diff --git a/test/lld/em_asm_O0.wat b/test/lld/em_asm_O0.wat index e9185afad..f96564c54 100644 --- a/test/lld/em_asm_O0.wat +++ b/test/lld/em_asm_O0.wat @@ -4,21 +4,24 @@ (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") - (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66192)) + (data $em_asm (i32.const 568) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") + (global $__stack_pointer (mut i32) (i32.const 66192)) + (global $global$1 i32 (i32.const 568)) + (global $global$2 i32 (i32.const 652)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) + (export "__start_em_asm" (global $global$1)) + (export "__stop_em_asm" (global $global$2)) (func $__wasm_call_ctors ) (func $main (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $2 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 32) ) ) @@ -80,7 +83,7 @@ (local.get $2) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $2) (i32.const 32) diff --git a/test/lld/em_asm_O0.wat.out b/test/lld/em_asm_O0.wat.out index be664978c..b1765812c 100644 --- a/test/lld/em_asm_O0.wat.out +++ b/test/lld/em_asm_O0.wat.out @@ -4,9 +4,10 @@ (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") - (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66192)) + (data $em_asm (i32.const 568) "") + (global $__stack_pointer (mut i32) (i32.const 66192)) + (global $global$1 i32 (i32.const 568)) + (global $global$2 i32 (i32.const 652)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -16,10 +17,10 @@ (func $main (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $2 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 32) ) ) @@ -81,7 +82,7 @@ (local.get $2) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $2) (i32.const 32) @@ -98,7 +99,7 @@ "601": "{ return $0 + $1; }", "621": "{ Module.print(\"Got \" + $0); }" }, - "tableSize": 1, + "tableSize": 0, "declares": [ "emscripten_asm_const_int" ], diff --git a/test/lld/em_asm_shared.wat b/test/lld/em_asm_shared.wat index f4e9380a2..3f9a5680b 100644 --- a/test/lld/em_asm_shared.wat +++ b/test/lld/em_asm_shared.wat @@ -3,37 +3,41 @@ (type $none_=>_i32 (func (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) - (data (global.get $gimport$1) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (import "env" "memory" (memory $mimport$0 1)) + (data $.data (global.get $__memory_base) "\00ii\00i\00{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) - (import "env" "__stack_pointer" (global $gimport$0 (mut i32))) - (import "env" "__memory_base" (global $gimport$1 i32)) - (import "env" "__table_base" (global $gimport$2 i32)) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $gimport$3 (mut i32))) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $gimport$4 (mut i32))) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $gimport$5 (mut i32))) + (import "env" "__stack_pointer" (global $__stack_pointer (mut i32))) + (import "env" "__memory_base" (global $__memory_base i32)) + (import "env" "__table_base" (global $__table_base i32)) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<>\20>::buffer (mut i32))) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<int\2c\20int>\20>::buffer (mut i32))) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<int>\20>::buffer (mut i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) - (global $global$0 i32 (i32.const 33)) - (global $global$1 i32 (i32.const 54)) - (global $global$2 i32 (i32.const 88)) + (global $global$0 i32 (i32.const 0)) + (global $global$1 i32 (i32.const 1)) + (global $global$2 i32 (i32.const 4)) + (global $global$3 i32 (i32.const 6)) + (global $global$4 i32 (i32.const 90)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "__original_main" (func $__original_main)) (export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $global$0)) (export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $global$1)) (export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $global$2)) (export "main" (func $main)) + (export "__start_em_asm" (global $global$3)) + (export "__stop_em_asm" (global $global$4)) (func $__wasm_call_ctors - (call $__wasm_apply_relocs) + (call $__wasm_apply_data_relocs) ) - (func $__wasm_apply_relocs + (func $__wasm_apply_data_relocs ) (func $__original_main (result i32) (local $0 i32) (local $1 i32) - (global.set $gimport$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $gimport$0) + (global.get $__stack_pointer) (i32.const 32) ) ) @@ -42,11 +46,11 @@ (call $emscripten_asm_const_int (i32.add (local.tee $1 - (global.get $gimport$1) + (global.get $__memory_base) ) - (i32.const 0) + (i32.const 6) ) - (global.get $gimport$3) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<>\20>::buffer) (i32.const 0) ) ) @@ -59,9 +63,9 @@ (call $emscripten_asm_const_int (i32.add (local.get $1) - (i32.const 34) + (i32.const 39) ) - (global.get $gimport$4) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<int\2c\20int>\20>::buffer) (i32.add (local.get $0) (i32.const 16) @@ -72,13 +76,13 @@ (call $emscripten_asm_const_int (i32.add (local.get $1) - (i32.const 57) + (i32.const 59) ) - (global.get $gimport$5) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<int>\20>::buffer) (local.get $0) ) ) - (global.set $gimport$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 32) @@ -95,5 +99,6 @@ ;; tablesize: 0 ;; tablealignment: 0 ;; custom section "producers", size 112 + ;; features section: mutable-globals ) diff --git a/test/lld/em_asm_shared.wat.out b/test/lld/em_asm_shared.wat.out index fd143a016..dac8a31e2 100644 --- a/test/lld/em_asm_shared.wat.out +++ b/test/lld/em_asm_shared.wat.out @@ -3,19 +3,21 @@ (type $none_=>_i32 (func (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) - (data (global.get $gimport$1) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00") + (import "env" "memory" (memory $mimport$0 1)) + (data $.data (global.get $__memory_base) "\00ii\00i\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) - (import "env" "__stack_pointer" (global $gimport$0 (mut i32))) - (import "env" "__memory_base" (global $gimport$1 i32)) - (import "env" "__table_base" (global $gimport$2 i32)) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $gimport$3 (mut i32))) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $gimport$4 (mut i32))) - (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $gimport$5 (mut i32))) + (import "env" "__stack_pointer" (global $__stack_pointer (mut i32))) + (import "env" "__memory_base" (global $__memory_base i32)) + (import "env" "__table_base" (global $__table_base i32)) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<>\20>::buffer (mut i32))) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<int\2c\20int>\20>::buffer (mut i32))) + (import "GOT.mem" "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $__em_asm_sig_builder<__em_asm_type_tuple<int>\20>::buffer (mut i32))) (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) - (global $global$0 i32 (i32.const 33)) - (global $global$1 i32 (i32.const 54)) - (global $global$2 i32 (i32.const 88)) + (global $global$0 i32 (i32.const 0)) + (global $global$1 i32 (i32.const 1)) + (global $global$2 i32 (i32.const 4)) + (global $global$3 i32 (i32.const 6)) + (global $global$4 i32 (i32.const 90)) (export "__post_instantiate" (func $__wasm_call_ctors)) (export "__original_main" (func $__original_main)) (export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $global$0)) @@ -23,18 +25,18 @@ (export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" (global $global$2)) (export "main" (func $main)) (func $__wasm_call_ctors - (call $__wasm_apply_relocs) + (call $__wasm_apply_data_relocs) ) - (func $__wasm_apply_relocs + (func $__wasm_apply_data_relocs (nop) ) (func $__original_main (result i32) (local $0 i32) (local $1 i32) - (global.set $gimport$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $gimport$0) + (global.get $__stack_pointer) (i32.const 32) ) ) @@ -43,11 +45,11 @@ (call $emscripten_asm_const_int (i32.add (local.tee $1 - (global.get $gimport$1) + (global.get $__memory_base) ) - (i32.const 0) + (i32.const 6) ) - (global.get $gimport$3) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<>\20>::buffer) (i32.const 0) ) ) @@ -60,9 +62,9 @@ (call $emscripten_asm_const_int (i32.add (local.get $1) - (i32.const 34) + (i32.const 39) ) - (global.get $gimport$4) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<int\2c\20int>\20>::buffer) (i32.add (local.get $0) (i32.const 16) @@ -73,13 +75,13 @@ (call $emscripten_asm_const_int (i32.add (local.get $1) - (i32.const 57) + (i32.const 59) ) - (global.get $gimport$5) + (global.get $__em_asm_sig_builder<__em_asm_type_tuple<int>\20>::buffer) (local.get $0) ) ) - (global.set $gimport$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 32) @@ -95,9 +97,9 @@ --BEGIN METADATA -- { "asmConsts": { - "0": "{ Module.print(\"Hello world\"); }", - "34": "{ return $0 + $1; }", - "57": "{ Module.print(\"Got \" + $0); }" + "6": "{ Module.print(\"Hello world\"); }", + "39": "{ return $0 + $1; }", + "59": "{ Module.print(\"Got \" + $0); }" }, "tableSize": 0, "declares": [ @@ -117,9 +119,9 @@ "main" ], "namedGlobals": { - "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" : "33", - "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" : "54", - "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" : "88" + "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" : "0", + "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" : "1", + "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiEEE6bufferE" : "4" }, "invokeFuncs": [ ], diff --git a/test/lld/hello_world.wat b/test/lld/hello_world.wat index b04e08cc3..71f464ae6 100644 --- a/test/lld/hello_world.wat +++ b/test/lld/hello_world.wat @@ -5,9 +5,9 @@ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (import "env" "puts" (func $puts (param i32) (result i32))) (memory $0 2) - (data (i32.const 568) "Hello, world\00") + (data $.rodata (i32.const 568) "Hello, world\00") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66128)) + (global $__stack_pointer (mut i32) (i32.const 66128)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/hello_world.wat.mem.out b/test/lld/hello_world.wat.mem.out index 3c25ea313..6a002d7b2 100644 --- a/test/lld/hello_world.wat.mem.out +++ b/test/lld/hello_world.wat.mem.out @@ -6,7 +6,7 @@ (import "env" "puts" (func $puts (param i32) (result i32))) (memory $0 2) (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66128)) + (global $__stack_pointer (mut i32) (i32.const 66128)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/hello_world.wat.out b/test/lld/hello_world.wat.out index dd94495c2..8783b5662 100644 --- a/test/lld/hello_world.wat.out +++ b/test/lld/hello_world.wat.out @@ -5,9 +5,9 @@ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (import "env" "puts" (func $puts (param i32) (result i32))) (memory $0 2) - (data (i32.const 568) "Hello, world\00") + (data $.rodata (i32.const 568) "Hello, world\00") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66128)) + (global $__stack_pointer (mut i32) (i32.const 66128)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/init.wat b/test/lld/init.wat index 9d25485c4..3d088e743 100644 --- a/test/lld/init.wat +++ b/test/lld/init.wat @@ -4,7 +4,7 @@ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (memory $0 2) (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/init.wat.out b/test/lld/init.wat.out index a9b66987c..4ec84de43 100644 --- a/test/lld/init.wat.out +++ b/test/lld/init.wat.out @@ -4,7 +4,7 @@ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (memory $0 2) (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/recursive.wat b/test/lld/recursive.wat index 53bf110e6..96be1d10c 100644 --- a/test/lld/recursive.wat +++ b/test/lld/recursive.wat @@ -4,9 +4,9 @@ (type $none_=>_i32 (func (result i32))) (import "env" "iprintf" (func $iprintf (param i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "%d:%d\n\00Result: %d\n\00") + (data $.rodata (i32.const 568) "%d:%d\n\00Result: %d\n\00") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66128)) + (global $__stack_pointer (mut i32) (i32.const 66128)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -14,10 +14,10 @@ ) (func $foo (param $0 i32) (param $1 i32) (result i32) (local $2 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $2 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 16) ) ) @@ -36,7 +36,7 @@ (local.get $2) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $2) (i32.const 16) @@ -49,10 +49,10 @@ ) (func $__original_main (result i32) (local $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 16) ) ) @@ -70,7 +70,7 @@ (local.get $0) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 16) diff --git a/test/lld/recursive.wat.out b/test/lld/recursive.wat.out index e51c9f525..f47981a47 100644 --- a/test/lld/recursive.wat.out +++ b/test/lld/recursive.wat.out @@ -4,9 +4,9 @@ (type $none_=>_i32 (func (result i32))) (import "env" "iprintf" (func $iprintf (param i32 i32) (result i32))) (memory $0 2) - (data (i32.const 568) "%d:%d\n\00Result: %d\n\00") + (data $.rodata (i32.const 568) "%d:%d\n\00Result: %d\n\00") (table $0 1 1 funcref) - (global $global$0 (mut i32) (i32.const 66128)) + (global $__stack_pointer (mut i32) (i32.const 66128)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) @@ -15,10 +15,10 @@ ) (func $foo (param $0 i32) (param $1 i32) (result i32) (local $2 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $2 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 16) ) ) @@ -37,7 +37,7 @@ (local.get $2) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $2) (i32.const 16) @@ -50,10 +50,10 @@ ) (func $__original_main (result i32) (local $0 i32) - (global.set $global$0 + (global.set $__stack_pointer (local.tee $0 (i32.sub - (global.get $global$0) + (global.get $__stack_pointer) (i32.const 16) ) ) @@ -71,7 +71,7 @@ (local.get $0) ) ) - (global.set $global$0 + (global.set $__stack_pointer (i32.add (local.get $0) (i32.const 16) diff --git a/test/lld/reserved_func_ptr.wat b/test/lld/reserved_func_ptr.wat index dd519d4e7..cee65a380 100644 --- a/test/lld/reserved_func_ptr.wat +++ b/test/lld/reserved_func_ptr.wat @@ -10,7 +10,7 @@ (memory $0 2) (table $0 3 3 funcref) (elem (i32.const 1) $address_taken_func\28int\2c\20int\2c\20int\29 $address_taken_func2\28int\2c\20int\2c\20int\29) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/reserved_func_ptr.wat.out b/test/lld/reserved_func_ptr.wat.out index 7dbd69c87..5b4fc2447 100644 --- a/test/lld/reserved_func_ptr.wat.out +++ b/test/lld/reserved_func_ptr.wat.out @@ -11,7 +11,7 @@ (memory $0 2) (table $0 3 3 funcref) (elem (i32.const 1) $address_taken_func\28int\2c\20int\2c\20int\29 $address_taken_func2\28int\2c\20int\2c\20int\29) - (global $global$0 (mut i32) (i32.const 66112)) + (global $__stack_pointer (mut i32) (i32.const 66112)) (export "memory" (memory $0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) diff --git a/test/lld/shared.wat b/test/lld/shared.wat index bde9f920e..15700f1f9 100644 --- a/test/lld/shared.wat +++ b/test/lld/shared.wat @@ -2,14 +2,14 @@ (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) - (data (global.get $gimport$0) "Hello, world\00\00\00\00\00\00\00\00\00\00\00\00") + (import "env" "memory" (memory $mimport$0 1)) + (data $.data (global.get $__memory_base) "Hello, world\00\00\00\00\00\00\00\00\00\00\00\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) - (import "env" "__memory_base" (global $gimport$0 i32)) - (import "env" "__table_base" (global $gimport$1 i32)) - (import "GOT.mem" "external_var" (global $gimport$2 (mut i32))) - (import "GOT.func" "puts" (global $gimport$3 (mut i32))) - (import "GOT.func" "_Z13print_messagev" (global $gimport$4 (mut i32))) + (import "env" "__memory_base" (global $__memory_base i32)) + (import "env" "__table_base" (global $__table_base i32)) + (import "GOT.mem" "external_var" (global $external_var (mut i32))) + (import "GOT.func" "puts" (global $puts (mut i32))) + (import "GOT.func" "_Z13print_messagev" (global $print_message\28\29 (mut i32))) (import "env" "puts" (func $puts (param i32) (result i32))) (global $global$0 i32 (i32.const 16)) (global $global$1 i32 (i32.const 20)) @@ -18,35 +18,35 @@ (export "ptr_puts" (global $global$0)) (export "ptr_local_func" (global $global$1)) (func $__wasm_call_ctors - (call $__wasm_apply_relocs) + (call $__wasm_apply_data_relocs) ) - (func $__wasm_apply_relocs + (func $__wasm_apply_data_relocs (i32.store (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 16) ) - (global.get $gimport$3) + (global.get $puts) ) (i32.store (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 20) ) - (global.get $gimport$4) + (global.get $print_message\28\29) ) ) (func $print_message\28\29 (result i32) (drop (call $puts (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 0) ) ) ) (i32.load - (global.get $gimport$2) + (global.get $external_var) ) ) ;; dylink section @@ -55,5 +55,6 @@ ;; tablesize: 0 ;; tablealignment: 0 ;; custom section "producers", size 112 + ;; features section: mutable-globals ) diff --git a/test/lld/shared.wat.out b/test/lld/shared.wat.out index 141347595..dd98de549 100644 --- a/test/lld/shared.wat.out +++ b/test/lld/shared.wat.out @@ -2,14 +2,14 @@ (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) - (data (global.get $gimport$0) "Hello, world\00\00\00\00\00\00\00\00\00\00\00\00") + (import "env" "memory" (memory $mimport$0 1)) + (data $.data (global.get $__memory_base) "Hello, world\00\00\00\00\00\00\00\00\00\00\00\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) - (import "env" "__memory_base" (global $gimport$0 i32)) - (import "env" "__table_base" (global $gimport$1 i32)) - (import "GOT.mem" "external_var" (global $gimport$2 (mut i32))) - (import "GOT.func" "puts" (global $gimport$3 (mut i32))) - (import "GOT.func" "_Z13print_messagev" (global $gimport$4 (mut i32))) + (import "env" "__memory_base" (global $__memory_base i32)) + (import "env" "__table_base" (global $__table_base i32)) + (import "GOT.mem" "external_var" (global $external_var (mut i32))) + (import "GOT.func" "puts" (global $puts (mut i32))) + (import "GOT.func" "_Z13print_messagev" (global $print_message\28\29 (mut i32))) (import "env" "puts" (func $puts (param i32) (result i32))) (global $global$0 i32 (i32.const 16)) (global $global$1 i32 (i32.const 20)) @@ -18,35 +18,35 @@ (export "ptr_puts" (global $global$0)) (export "ptr_local_func" (global $global$1)) (func $__wasm_call_ctors - (call $__wasm_apply_relocs) + (call $__wasm_apply_data_relocs) ) - (func $__wasm_apply_relocs + (func $__wasm_apply_data_relocs (i32.store (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 16) ) - (global.get $gimport$3) + (global.get $puts) ) (i32.store (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 20) ) - (global.get $gimport$4) + (global.get $print_message\28\29) ) ) (func $print_message\28\29 (result i32) (drop (call $puts (i32.add - (global.get $gimport$0) + (global.get $__memory_base) (i32.const 0) ) ) ) (i32.load - (global.get $gimport$2) + (global.get $external_var) ) ) ) diff --git a/test/lld/shared_longjmp.wat b/test/lld/shared_longjmp.wat index 83d7fca49..9da190016 100644 --- a/test/lld/shared_longjmp.wat +++ b/test/lld/shared_longjmp.wat @@ -7,7 +7,7 @@ (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) + (import "env" "memory" (memory $mimport$0 1)) (data (global.get $gimport$0) "\00\00\00\00\00\00\00\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) (import "env" "__memory_base" (global $gimport$0 i32)) @@ -143,5 +143,6 @@ ;; tablesize: 0 ;; tablealignment: 0 ;; custom section "producers", size 112 + ;; features section: mutable-globals ) diff --git a/test/lld/shared_longjmp.wat.out b/test/lld/shared_longjmp.wat.out index 7928c8d21..b657d6c46 100644 --- a/test/lld/shared_longjmp.wat.out +++ b/test/lld/shared_longjmp.wat.out @@ -7,7 +7,7 @@ (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) - (import "env" "memory" (memory $mimport$0 0)) + (import "env" "memory" (memory $mimport$0 1)) (data (global.get $gimport$0) "\00\00\00\00\00\00\00\00") (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) (import "env" "__memory_base" (global $gimport$0 i32)) |