summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/example/module-splitting.cpp101
-rw-r--r--test/example/module-splitting.txt304
2 files changed, 405 insertions, 0 deletions
diff --git a/test/example/module-splitting.cpp b/test/example/module-splitting.cpp
index 50fb0f4c5..bba0bf0a7 100644
--- a/test/example/module-splitting.cpp
+++ b/test/example/module-splitting.cpp
@@ -127,6 +127,17 @@ int main() {
)
))");
+ // Non-deferred function in table at non-const offset
+ do_test({"foo"}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (table $table 1 funcref)
+ (elem (global.get $base) $foo)
+ (func $foo (param i32) (result i32)
+ (local.get 0)
+ )
+ ))");
+
// Non-deferred imported function
do_test({"foo"}, R"(
(module
@@ -142,6 +153,16 @@ int main() {
(export "foo" (func $foo))
))");
+ // Non-deferred exported imported function in table at a non-const offset
+ do_test({"foo"}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (import "env" "foo" (func $foo (param i32) (result i32)))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $foo)
+ (export "foo" (func $foo))
+ ))");
+
// Deferred function
do_test({}, R"(
(module
@@ -180,6 +201,31 @@ int main() {
)
))");
+ // Deferred exported function in table at a non-const offset
+ do_test({}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $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
+ (import "env" "base" (global $base i32))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $null $foo)
+ (export "foo" (func $foo))
+ (func $null)
+ (func $foo (param i32) (result i32)
+ (local.get 0)
+ )
+ ))");
+
// Non-deferred function calling non-deferred function
do_test({"foo", "bar"}, R"(
(module
@@ -255,6 +301,26 @@ int main() {
)
))");
+ // Mixed table 1 with non-const offset
+ do_test({"bar", "quux"}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (table $table 4 funcref)
+ (elem (global.get $base) $foo $bar $baz $quux)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+ ))");
+
// Mixed table 2
do_test({"baz"}, R"(
(module
@@ -274,6 +340,41 @@ int main() {
)
))");
+ // Mixed table 2 with non-const offset
+ do_test({"baz"}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (table $table 4 funcref)
+ (elem (global.get $base) $foo $bar $baz $quux)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+ ))");
+
+ // `foo` is exported both because it is called by `bar` and because it is in a
+ // table gap
+ do_test({"foo"}, R"(
+ (module
+ (import "env" "base" (global $base i32))
+ (table $table 2 funcref)
+ (elem (global.get $base) $foo $bar)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (call $foo)
+ )
+ ))");
+
// Mutual recursion with table growth
do_test({"foo"}, R"(
(module
diff --git a/test/example/module-splitting.txt b/test/example/module-splitting.txt
index 4d79688f7..9b28f31ca 100644
--- a/test/example/module-splitting.txt
+++ b/test/example/module-splitting.txt
@@ -178,6 +178,36 @@ Secondary:
Before:
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (table $table 1 funcref)
+ (elem (global.get $base) $foo)
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+Keeping: foo
+After:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (table $table 1 funcref)
+ (elem (global.get $base) $foo)
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+Secondary:
+(module
+ (import "primary" "%table" (table $table 1 funcref))
+ (import "primary" "%global" (global $base i32))
+)
+
+
+Before:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
(import "env" "foo" (func $foo (param i32) (result i32)))
)
Keeping: foo
@@ -218,6 +248,34 @@ Secondary:
Before:
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (import "env" "foo" (func $foo (param i32) (result i32)))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $foo)
+ (export "foo" (func $foo))
+)
+Keeping: foo
+After:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (import "env" "foo" (func $foo (param i32) (result i32)))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $foo)
+ (export "foo" (func $foo))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+)
+Secondary:
+(module
+ (import "primary" "%table" (table $table 1000 funcref))
+ (import "primary" "%global" (global $base i32))
+)
+
+
+Before:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
(func $foo (param $0 i32) (result i32)
(local.get $0)
)
@@ -338,6 +396,102 @@ Secondary:
Before:
(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $foo)
+ (export "foo" (func $foo))
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+Keeping: <none>
+After:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (import "placeholder" "0" (func $placeholder_0 (param i32) (result i32)))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $placeholder_0)
+ (export "foo" (func $foo))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $foo (param $0 i32) (result i32)
+ (call_indirect (type $i32_=>_i32)
+ (local.get $0)
+ (global.get $base)
+ )
+ )
+)
+Secondary:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "primary" "%table" (table $table 1000 funcref))
+ (elem (global.get $base) $foo)
+ (import "primary" "%global" (global $base i32))
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+
+
+Before:
+(module
+ (type $none_=>_none (func))
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "env" "base" (global $base i32))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $null $foo)
+ (export "foo" (func $foo))
+ (func $null
+ (nop)
+ )
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+Keeping: null
+After:
+(module
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (import "placeholder" "1" (func $placeholder_1 (param i32) (result i32)))
+ (table $table 1000 funcref)
+ (elem (global.get $base) $null $placeholder_1)
+ (export "foo" (func $foo))
+ (export "%null" (func $null))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $null
+ (nop)
+ )
+ (func $foo (param $0 i32) (result i32)
+ (call_indirect (type $i32_=>_i32)
+ (local.get $0)
+ (i32.add
+ (global.get $base)
+ (i32.const 1)
+ )
+ )
+ )
+)
+Secondary:
+(module
+ (type $none_=>_none (func))
+ (type $i32_=>_i32 (func (param i32) (result i32)))
+ (import "primary" "%table" (table $table 1000 funcref))
+ (elem (global.get $base) $null $foo)
+ (import "primary" "%global" (global $base i32))
+ (import "primary" "%null" (func $null))
+ (func $foo (param $0 i32) (result i32)
+ (local.get $0)
+ )
+)
+
+
+Before:
+(module
(type $none_=>_none (func))
(func $foo
(call $bar)
@@ -546,6 +700,60 @@ Secondary:
Before:
(module
(type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (table $table 4 funcref)
+ (elem (global.get $base) $foo $bar $baz $quux)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+)
+Keeping: bar, quux
+After:
+(module
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (import "placeholder" "0" (func $placeholder_0))
+ (import "placeholder" "2" (func $placeholder_2))
+ (table $table 4 funcref)
+ (elem (global.get $base) $placeholder_0 $bar $placeholder_2 $quux)
+ (export "%bar" (func $bar))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $bar
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+)
+Secondary:
+(module
+ (type $none_=>_none (func))
+ (import "primary" "%table" (table $table 4 funcref))
+ (elem (global.get $base) $foo $bar $baz)
+ (import "primary" "%global" (global $base i32))
+ (import "primary" "%bar" (func $bar))
+ (func $baz
+ (nop)
+ )
+ (func $foo
+ (nop)
+ )
+)
+
+
+Before:
+(module
+ (type $none_=>_none (func))
(table $table 4 funcref)
(elem (i32.const 0) $foo $bar $baz $quux)
(func $foo
@@ -595,6 +803,102 @@ Secondary:
Before:
(module
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (table $table 4 funcref)
+ (elem (global.get $base) $foo $bar $baz $quux)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+)
+Keeping: baz
+After:
+(module
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (import "placeholder" "0" (func $placeholder_0))
+ (import "placeholder" "1" (func $placeholder_1))
+ (import "placeholder" "3" (func $placeholder_3))
+ (table $table 4 funcref)
+ (elem (global.get $base) $placeholder_0 $placeholder_1 $baz $placeholder_3)
+ (export "%baz" (func $baz))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $baz
+ (nop)
+ )
+)
+Secondary:
+(module
+ (type $none_=>_none (func))
+ (import "primary" "%table" (table $table 4 funcref))
+ (elem (global.get $base) $foo $bar $baz $quux)
+ (import "primary" "%global" (global $base i32))
+ (import "primary" "%baz" (func $baz))
+ (func $bar
+ (nop)
+ )
+ (func $foo
+ (nop)
+ )
+ (func $quux
+ (nop)
+ )
+)
+
+
+Before:
+(module
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (table $table 2 funcref)
+ (elem (global.get $base) $foo $bar)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (call $foo)
+ )
+)
+Keeping: foo
+After:
+(module
+ (type $none_=>_none (func))
+ (import "env" "base" (global $base i32))
+ (import "placeholder" "1" (func $placeholder_1))
+ (table $table 2 funcref)
+ (elem (global.get $base) $foo $placeholder_1)
+ (export "%foo" (func $foo))
+ (export "%table" (table $table))
+ (export "%global" (global $base))
+ (func $foo
+ (nop)
+ )
+)
+Secondary:
+(module
+ (type $none_=>_none (func))
+ (import "primary" "%table" (table $table 2 funcref))
+ (elem (global.get $base) $foo $bar)
+ (import "primary" "%global" (global $base i32))
+ (import "primary" "%foo" (func $foo))
+ (func $bar
+ (call $foo)
+ )
+)
+
+
+Before:
+(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(table $table 1 1 funcref)
(elem (i32.const 0) $foo)