summaryrefslogtreecommitdiff
path: root/test/lld/shared_add_to_table.wasm.out
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-03-31 15:20:50 -0700
committerGitHub <noreply@github.com>2020-03-31 15:20:50 -0700
commita32102c7dd7b321330c6cce4d0e3b16e7187a007 (patch)
treea704cc3a77fca9fbde7a2e05de4f2b0d2980a39f /test/lld/shared_add_to_table.wasm.out
parentd8179402b3bb991f336b19bcca8ccbc60c842166 (diff)
downloadbinaryen-a32102c7dd7b321330c6cce4d0e3b16e7187a007.tar.gz
binaryen-a32102c7dd7b321330c6cce4d0e3b16e7187a007.tar.bz2
binaryen-a32102c7dd7b321330c6cce4d0e3b16e7187a007.zip
Avoid unnecessary fp$ in side modules (#2717)
Now that we update the dylink section properly, we can do the same optimization in side modules as in main ones: if the module provides a function, don't call an $fp method during startup, instead add it to the table ourselves and use the relative offset to the table base. Fix an issue when the table has no segments initially: the code just added an offset of 0, but that's not right. Instead, an a __table_base import and use that as the offset. As this is ABI-specific I did it on wasm-emscripten-finalize, leaving TableUtils to just assert on having a singleton segment. Add a test of a wasm file with a dylink section to the lld tests.
Diffstat (limited to 'test/lld/shared_add_to_table.wasm.out')
-rw-r--r--test/lld/shared_add_to_table.wasm.out144
1 files changed, 144 insertions, 0 deletions
diff --git a/test/lld/shared_add_to_table.wasm.out b/test/lld/shared_add_to_table.wasm.out
new file mode 100644
index 000000000..c561a89d3
--- /dev/null
+++ b/test/lld/shared_add_to_table.wasm.out
@@ -0,0 +1,144 @@
+(module
+ (type $none_=>_none (func))
+ (type $none_=>_i32 (func (result i32)))
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
+ (import "env" "memory" (memory $0 0))
+ (data (global.get $gimport$3) "*\00\00\00")
+ (import "env" "table" (table $timport$1 1 funcref))
+ (elem (global.get $gimport$4) $waka_func_mine\28int\29)
+ (import "env" "__memory_base" (global $gimport$3 i32))
+ (import "env" "__table_base" (global $gimport$4 i32))
+ (import "env" "_Z16waka_func_theirsi" (func $waka_func_theirs\28int\29 (param i32) (result i32)))
+ (import "env" "g$waka_mine" (func $g$waka_mine (result i32)))
+ (import "env" "g$waka_others" (func $g$waka_others (result i32)))
+ (import "env" "fp$_Z16waka_func_theirsi$ii" (func $fp$_Z16waka_func_theirsi$ii (result i32)))
+ (global $gimport$6 (mut i32) (i32.const 0))
+ (global $gimport$7 (mut i32) (i32.const 0))
+ (global $gimport$8 (mut i32) (i32.const 0))
+ (global $gimport$9 (mut i32) (i32.const 0))
+ (global $global$0 i32 (i32.const 0))
+ (global $global$1 i32 (i32.const 0))
+ (export "__wasm_apply_relocs" (func $__wasm_apply_relocs))
+ (export "_Z14waka_func_minei" (func $waka_func_mine\28int\29))
+ (export "__original_main" (func $__original_main))
+ (export "waka_mine" (global $global$0))
+ (export "main" (func $main))
+ (export "__dso_handle" (global $global$1))
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "dynCall_ii" (func $dynCall_ii))
+ (func $__wasm_call_ctors (; 4 ;)
+ (call $__wasm_apply_relocs)
+ )
+ (func $__wasm_apply_relocs (; 5 ;)
+ )
+ (func $waka_func_mine\28int\29 (; 6 ;) (param $0 i32) (result i32)
+ (i32.add
+ (local.get $0)
+ (i32.const 1)
+ )
+ )
+ (func $__original_main (; 7 ;) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local.set $0
+ (global.get $gimport$6)
+ )
+ (local.set $1
+ (global.get $gimport$7)
+ )
+ (i32.add
+ (i32.add
+ (i32.load
+ (global.get $gimport$8)
+ )
+ (i32.add
+ (local.get $1)
+ (local.get $0)
+ )
+ )
+ (i32.load
+ (global.get $gimport$9)
+ )
+ )
+ )
+ (func $main (; 8 ;) (param $0 i32) (param $1 i32) (result i32)
+ (call $__original_main)
+ )
+ (func $__post_instantiate (; 9 ;)
+ (call $__assign_got_enties)
+ (call $__wasm_call_ctors)
+ )
+ (func $__assign_got_enties (; 10 ;)
+ (global.set $gimport$8
+ (call $g$waka_mine)
+ )
+ (global.set $gimport$9
+ (call $g$waka_others)
+ )
+ (global.set $gimport$6
+ (call $fp$_Z16waka_func_theirsi$ii)
+ )
+ (global.set $gimport$7
+ (i32.add
+ (global.get $gimport$4)
+ (i32.const 0)
+ )
+ )
+ )
+ (func $dynCall_ii (; 11 ;) (param $fptr i32) (param $0 i32) (result i32)
+ (call_indirect (type $i32_=>_i32)
+ (local.get $0)
+ (local.get $fptr)
+ )
+ )
+ ;; dylink section
+ ;; memorysize: 4
+ ;; memoryalignment: 2
+ ;; tablesize: 1
+ ;; tablealignment: 0
+ ;; custom section "producers", size 157
+)
+(;
+--BEGIN METADATA --
+{
+ "staticBump": 0,
+ "tableSize": 1,
+ "declares": [
+ "_Z16waka_func_theirsi",
+ "g$waka_mine",
+ "g$waka_others",
+ "fp$_Z16waka_func_theirsi$ii"
+ ],
+ "externs": [
+ "___memory_base",
+ "___table_base"
+ ],
+ "implementedFunctions": [
+ "___wasm_apply_relocs",
+ "__Z14waka_func_minei",
+ "___original_main",
+ "_main",
+ "___post_instantiate",
+ "_dynCall_ii"
+ ],
+ "exports": [
+ "__wasm_apply_relocs",
+ "_Z14waka_func_minei",
+ "__original_main",
+ "main",
+ "__post_instantiate",
+ "dynCall_ii"
+ ],
+ "namedGlobals": {
+ "waka_mine" : "0",
+ "__dso_handle" : "0"
+ },
+ "invokeFuncs": [
+ ],
+ "features": [
+ ],
+ "mainReadsParams": 0
+}
+-- END METADATA --
+;)