From 6cc598496a62ff4dbdb680b400ca26a9b1059e7c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 14 Dec 2018 17:27:29 -0800 Subject: Minimal JS legalization (#1824) Even when we don't want to fully legalize code for JS, we should still legalize things that only JS cares about. In particular, dynCall_* methods are used from JS to call into the wasm table, and if they exist they are only for JS, so we should only legalize them. The use case motivating this is that in dynamic linking you may want to disable legalization, so that wasm=>wasm module calls are fast even with i64s, but you do still need dynCalls to be legalized even in that case, otherwise an invoke with an i64 parameter would fail. --- test/passes/legalize-js-interface-minimally.txt | 39 ++++++++++++++++++++++++ test/passes/legalize-js-interface-minimally.wast | 15 +++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/passes/legalize-js-interface-minimally.txt create mode 100644 test/passes/legalize-js-interface-minimally.wast (limited to 'test') diff --git a/test/passes/legalize-js-interface-minimally.txt b/test/passes/legalize-js-interface-minimally.txt new file mode 100644 index 000000000..6152847f4 --- /dev/null +++ b/test/passes/legalize-js-interface-minimally.txt @@ -0,0 +1,39 @@ +(module + (type $FUNCSIG$j (func (result i64))) + (type $FUNCSIG$vi (func (param i32))) + (import "env" "imported" (func $imported (result i64))) + (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + (export "func" (func $func)) + (export "dynCall_foo" (func $legalstub$dyn)) + (func $func (; 2 ;) (type $FUNCSIG$j) (result i64) + (drop + (call $imported) + ) + (unreachable) + ) + (func $dyn (; 3 ;) (type $FUNCSIG$j) (result i64) + (drop + (call $imported) + ) + (unreachable) + ) + (func $legalstub$dyn (; 4 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $dyn) + ) + (call $setTempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) +(module +) diff --git a/test/passes/legalize-js-interface-minimally.wast b/test/passes/legalize-js-interface-minimally.wast new file mode 100644 index 000000000..2e003a521 --- /dev/null +++ b/test/passes/legalize-js-interface-minimally.wast @@ -0,0 +1,15 @@ +(module + (import "env" "imported" (func $imported (result i64))) + (export "func" (func $func)) + (export "dynCall_foo" (func $dyn)) + (func $func (result i64) + (drop (call $imported)) + (unreachable) + ) + (func $dyn (result i64) + (drop (call $imported)) + (unreachable) + ) +) +(module) + -- cgit v1.2.3