diff options
author | Alon Zakai <azakai@google.com> | 2020-03-27 17:25:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 17:25:49 -0700 |
commit | d595a45b66cbb4d59472d2954131ee1f4cf6ad8e (patch) | |
tree | aa4c8116f9d57d8b1018b77b1db7ad7e3018ccc4 /test/lld/main_module_table.wat | |
parent | 9101f65c7b18ab607c472a3d50b52db66497402f (diff) | |
download | binaryen-d595a45b66cbb4d59472d2954131ee1f4cf6ad8e.tar.gz binaryen-d595a45b66cbb4d59472d2954131ee1f4cf6ad8e.tar.bz2 binaryen-d595a45b66cbb4d59472d2954131ee1f4cf6ad8e.zip |
Avoid fp$ access in MAIN_MODULES (#2704)
Depends on emscripten-core/emscripten#10741
which ensures that table indexes are unique. With that guarantee,
a main module can just add its function pointers into the table, and
use them based on that index. The loader will then see them in the
table and then give other modules the identical function pointer for
a function, ensuring function pointer equality.
This avoids calling fp$ functions during startup for the main
module's own functions (which are slow). We do still call fp$s
of things we import from outside, as we don't have anything to
put in the table for them, we depend on the loader for that.
I suspect this can also be done with SIDE_MODULES, but did not
want to try too much at once.
Diffstat (limited to 'test/lld/main_module_table.wat')
-rw-r--r-- | test/lld/main_module_table.wat | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lld/main_module_table.wat b/test/lld/main_module_table.wat new file mode 100644 index 000000000..b63b4d8fe --- /dev/null +++ b/test/lld/main_module_table.wat @@ -0,0 +1,9 @@ +(module + (import "env" "__stack_pointer" (global $sp (mut i32))) + (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) + (global $global i32 (i32.const 42)) + (export "__stdio_write" (func $__stdio_write)) + (export "__data_end" (global $global)) + (func $__stdio_write + ) +) |