summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-11-11 15:39:45 -0800
committerGitHub <noreply@github.com>2019-11-11 15:39:45 -0800
commite83a9e2a21b35f19fe56a0d375191369b9b67148 (patch)
tree7a167721fbf38ff6ff8202b9ca900cd2c168529a /test
parent63ddbc04cf75a45a05a2b1f11564563915ebdbec (diff)
downloadbinaryen-e83a9e2a21b35f19fe56a0d375191369b9b67148.tar.gz
binaryen-e83a9e2a21b35f19fe56a0d375191369b9b67148.tar.bz2
binaryen-e83a9e2a21b35f19fe56a0d375191369b9b67148.zip
When legalizing, optionally export the original function too with orig$X (#2427)
The original is necessary if we want to pass it to wasm, where it will be called directly, without JS legalization. For example the JS dynamic loader in emscripten needs this, emscripten-core/emscripten#9562
Diffstat (limited to 'test')
-rw-r--r--test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt27
-rw-r--r--test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast7
2 files changed, 34 insertions, 0 deletions
diff --git a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt
new file mode 100644
index 000000000..bdf304ade
--- /dev/null
+++ b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt
@@ -0,0 +1,27 @@
+(module
+ (type $FUNCSIG$j (func (result i64)))
+ (type $FUNCSIG$vi (func (param i32)))
+ (import "env" "setTempRet0" (func $setTempRet0 (param i32)))
+ (export "func" (func $legalstub$func))
+ (export "orig$func" (func $func))
+ (func $func (; 1 ;) (type $FUNCSIG$j) (result i64)
+ (unreachable)
+ )
+ (func $legalstub$func (; 2 ;) (result i32)
+ (local $0 i64)
+ (local.set $0
+ (call $func)
+ )
+ (call $setTempRet0
+ (i32.wrap_i64
+ (i64.shr_u
+ (local.get $0)
+ (i64.const 32)
+ )
+ )
+ )
+ (i32.wrap_i64
+ (local.get $0)
+ )
+ )
+)
diff --git a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast
new file mode 100644
index 000000000..4b55fa920
--- /dev/null
+++ b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast
@@ -0,0 +1,7 @@
+(module
+ (export "func" (func $func))
+ (func $func (result i64)
+ (unreachable)
+ )
+)
+