diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-04-20 12:23:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 12:23:37 -0700 |
commit | 82323064aebfdac2b5b3672faf999cc3b5471fe1 (patch) | |
tree | a62a510956f5877afe111b1d077d638c86037eb2 /test/example/module-splitting.cpp | |
parent | e651186bbdbd36e775236c23f24f0baef1699101 (diff) | |
download | binaryen-82323064aebfdac2b5b3672faf999cc3b5471fe1.tar.gz binaryen-82323064aebfdac2b5b3672faf999cc3b5471fe1.tar.bz2 binaryen-82323064aebfdac2b5b3672faf999cc3b5471fe1.zip |
Minor wasm-split improvements (#3825)
- Support functions appearing more than once in the table. It turns out we
were assuming and asserting that functions would appear at most once, but we
weren't making use of that assumption in any way.
- Make TableSlotManager::getSlot take a function Name rather than a RefFunc
expression to avoid allocating and leaking unnecessary expressions.
- Add and use a Builder interface for building TableElementSegments to make
them more similar to other module-level items.
Diffstat (limited to 'test/example/module-splitting.cpp')
-rw-r--r-- | test/example/module-splitting.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/example/module-splitting.cpp b/test/example/module-splitting.cpp index ab42ff5fd..5391fe584 100644 --- a/test/example/module-splitting.cpp +++ b/test/example/module-splitting.cpp @@ -126,6 +126,16 @@ int main() { ) ))"); + // Non-deferred function in table multiple times + do_test({"foo"}, R"( + (module + (table $table 2 funcref) + (elem (i32.const 0) $foo $foo) + (func $foo (param i32) (result i32) + (local.get 0) + ) + ))"); + // Non-deferred function in table at non-const offset do_test({"foo"}, R"( (module @@ -137,6 +147,17 @@ int main() { ) ))"); + // Non-deferred function in table at non-const offset multiple times + do_test({"foo"}, R"( + (module + (import "env" "base" (global $base i32)) + (table $table 2 funcref) + (elem (global.get $base) $foo $foo) + (func $foo (param i32) (result i32) + (local.get 0) + ) + ))"); + // Non-deferred imported function do_test({"foo"}, R"( (module @@ -189,6 +210,16 @@ int main() { ) ))"); + // Deferred function in table multiple times + do_test({}, R"( + (module + (table $table 2 funcref) + (elem (i32.const 0) $foo $foo) + (func $foo (param i32) (result i32) + (local.get 0) + ) + ))"); + // Deferred exported function in table at a weird offset do_test({}, R"( (module @@ -212,6 +243,18 @@ int main() { ) ))"); + // Deferred exported function in table at a non-const offset multiple times + do_test({}, R"( + (module + (import "env" "base" (global $base i32)) + (table $table 1000 funcref) + (elem (global.get $base) $foo $foo) + (export "foo" (func $foo)) + (func $foo (param i32) (result i32) + (local.get 0) + ) + ))"); + // Deferred exported function in table at an offset from a non-const base do_test({"null"}, R"( (module |