summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/emcc_O2_hello_world.fromasm31
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise31
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise.no-opts2
-rw-r--r--test/emcc_O2_hello_world.fromasm.no-opts2
-rw-r--r--test/emcc_hello_world.fromasm31
-rw-r--r--test/emcc_hello_world.fromasm.imprecise31
-rw-r--r--test/emcc_hello_world.fromasm.imprecise.no-opts2
-rw-r--r--test/emcc_hello_world.fromasm.no-opts2
-rw-r--r--test/example/c-api-kitchen-sink.txt2
-rw-r--r--test/example/c-api-kitchen-sink.txt.txt1
-rw-r--r--test/imported_memory.wast1
-rw-r--r--test/imported_memory.wast.fromBinary1
-rw-r--r--test/imported_memory.wast.fromBinary.noDebugInfo1
-rw-r--r--test/imported_memory_growth.wast1
-rw-r--r--test/imported_memory_growth.wast.fromBinary1
-rw-r--r--test/imported_memory_growth.wast.fromBinary.noDebugInfo1
-rw-r--r--test/memorygrowth.fromasm31
-rw-r--r--test/memorygrowth.fromasm.imprecise31
-rw-r--r--test/memorygrowth.fromasm.imprecise.no-opts2
-rw-r--r--test/memorygrowth.fromasm.no-opts2
-rw-r--r--test/min.fromasm33
-rw-r--r--test/min.fromasm.imprecise33
-rw-r--r--test/min.fromasm.imprecise.no-opts31
-rw-r--r--test/min.fromasm.no-opts31
-rw-r--r--test/passes/remove-unused-functions.txt34
-rw-r--r--test/passes/remove-unused-functions.wast49
-rw-r--r--test/passes/remove-unused-module-elements.txt87
-rw-r--r--test/passes/remove-unused-module-elements.wast96
-rw-r--r--test/unit.asm.js24
-rw-r--r--test/unit.fromasm72
-rw-r--r--test/unit.fromasm.imprecise72
-rw-r--r--test/unit.fromasm.imprecise.no-opts98
-rw-r--r--test/unit.fromasm.no-opts98
-rw-r--r--test/wasm-only.asm.js10
-rw-r--r--test/wasm-only.fromasm44
-rw-r--r--test/wasm-only.fromasm.imprecise44
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts54
-rw-r--r--test/wasm-only.fromasm.no-opts54
38 files changed, 838 insertions, 333 deletions
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index ea595e69d..4d3147862 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -8,10 +8,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort (param i32)))
(import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32)))
(import "env" "_pthread_self" (func $_pthread_self (result i32)))
@@ -32,38 +28,13 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(data (i32.const 1024) "emcc_O2_hello_world.asm.js")
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index 3fabf2c9e..8ab35a567 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -8,10 +8,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort (param i32)))
(import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32)))
(import "env" "_pthread_self" (func $_pthread_self (result i32)))
@@ -31,37 +27,12 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
index 56ec1341c..7bc59938d 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
@@ -31,7 +31,7 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts
index 31f96c751..050d0b3f9 100644
--- a/test/emcc_O2_hello_world.fromasm.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.no-opts
@@ -32,7 +32,7 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 06f88befe..85d980069 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -10,10 +10,6 @@
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
(import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "env" "cttz_i8" (global $cttz_i8$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort))
(import "env" "nullFunc_ii" (func $nullFunc_ii (param i32)))
(import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32)))
@@ -41,39 +37,14 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(data (i32.const 1024) "emcc_hello_world.asm.js")
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
- (global $cttz_i8 (mut i32) (get_global $cttz_i8$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 4363dc349..65bd295bc 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -9,10 +9,6 @@
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
(import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
- (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
- (import "env" "cttz_i8" (global $cttz_i8$asm2wasm$import i32))
- (import "global" "NaN" (global $nan$asm2wasm$import f64))
- (import "global" "Infinity" (global $inf$asm2wasm$import f64))
(import "env" "abort" (func $abort))
(import "env" "nullFunc_ii" (func $nullFunc_ii (param i32)))
(import "env" "nullFunc_iiii" (func $nullFunc_iiii (param i32)))
@@ -35,38 +31,13 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
- (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
- (global $cttz_i8 (mut i32) (get_global $cttz_i8$asm2wasm$import))
(global $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
- (global $setjmpId (mut i32) (i32.const 0))
- (global $undef (mut i32) (i32.const 0))
- (global $nan (mut f64) (get_global $nan$asm2wasm$import))
- (global $inf (mut f64) (get_global $inf$asm2wasm$import))
- (global $tempInt (mut i32) (i32.const 0))
- (global $tempBigInt (mut i32) (i32.const 0))
- (global $tempBigIntP (mut i32) (i32.const 0))
- (global $tempBigIntS (mut i32) (i32.const 0))
- (global $tempBigIntR (mut f64) (f64.const 0))
- (global $tempBigIntI (mut i32) (i32.const 0))
- (global $tempBigIntD (mut i32) (i32.const 0))
- (global $tempValue (mut i32) (i32.const 0))
- (global $tempDouble (mut f64) (f64.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
- (global $tempRet1 (mut i32) (i32.const 0))
- (global $tempRet2 (mut i32) (i32.const 0))
- (global $tempRet3 (mut i32) (i32.const 0))
- (global $tempRet4 (mut i32) (i32.const 0))
- (global $tempRet5 (mut i32) (i32.const 0))
- (global $tempRet6 (mut i32) (i32.const 0))
- (global $tempRet7 (mut i32) (i32.const 0))
- (global $tempRet8 (mut i32) (i32.const 0))
- (global $tempRet9 (mut i32) (i32.const 0))
- (global $tempFloat (mut f64) (f64.const 0))
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts
index 9fbc85898..a805b78ae 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -35,7 +35,7 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index 39efb7986..22c1ee5c7 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -41,7 +41,7 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (elem (get_global $tableBase) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 1de260b20..4eee5c0c0 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -1028,7 +1028,6 @@ optimized:
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
module loaded from binary form:
@@ -2886,7 +2885,6 @@ optimized:
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
BinaryenModuleDispose(the_module);
diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt
index 16e4941d3..cbccff232 100644
--- a/test/example/c-api-kitchen-sink.txt.txt
+++ b/test/example/c-api-kitchen-sink.txt.txt
@@ -1021,6 +1021,5 @@
(type $v (func))
(type $vi (func (param i32)))
(type $i (func (result i32)))
- (import "module" "check" (func $check (param i32)))
(memory $0 0)
)
diff --git a/test/imported_memory.wast b/test/imported_memory.wast
index fb3c45f5a..790ffbbfa 100644
--- a/test/imported_memory.wast
+++ b/test/imported_memory.wast
@@ -1,3 +1,4 @@
(module
(import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 256 256 anyfunc))
)
diff --git a/test/imported_memory.wast.fromBinary b/test/imported_memory.wast.fromBinary
index bcbd85473..5df005bc1 100644
--- a/test/imported_memory.wast.fromBinary
+++ b/test/imported_memory.wast.fromBinary
@@ -1,4 +1,5 @@
(module
(import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 256 256 anyfunc))
)
diff --git a/test/imported_memory.wast.fromBinary.noDebugInfo b/test/imported_memory.wast.fromBinary.noDebugInfo
index bcbd85473..5df005bc1 100644
--- a/test/imported_memory.wast.fromBinary.noDebugInfo
+++ b/test/imported_memory.wast.fromBinary.noDebugInfo
@@ -1,4 +1,5 @@
(module
(import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 256 256 anyfunc))
)
diff --git a/test/imported_memory_growth.wast b/test/imported_memory_growth.wast
index d13b95853..a6e99fe85 100644
--- a/test/imported_memory_growth.wast
+++ b/test/imported_memory_growth.wast
@@ -1,3 +1,4 @@
(module
(import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 256 anyfunc))
)
diff --git a/test/imported_memory_growth.wast.fromBinary b/test/imported_memory_growth.wast.fromBinary
index 426313d7f..821aba207 100644
--- a/test/imported_memory_growth.wast.fromBinary
+++ b/test/imported_memory_growth.wast.fromBinary
@@ -1,4 +1,5 @@
(module
(import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 256 anyfunc))
)
diff --git a/test/imported_memory_growth.wast.fromBinary.noDebugInfo b/test/imported_memory_growth.wast.fromBinary.noDebugInfo
index 426313d7f..821aba207 100644
--- a/test/imported_memory_growth.wast.fromBinary.noDebugInfo
+++ b/test/imported_memory_growth.wast.fromBinary.noDebugInfo
@@ -1,4 +1,5 @@
(module
(import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 256 anyfunc))
)
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index 1422a65a9..cfe303d34 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -7,10 +7,6 @@
(type $FUNCSIG$vii (func (param i32 i32)))
(import "env" "STACKTOP" (global $r$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $s$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $t$asm2wasm$import i32))
- (import "env" "ABORT" (global $u$asm2wasm$import i32))
- (import "global" "NaN" (global $z$asm2wasm$import f64))
- (import "global" "Infinity" (global $A$asm2wasm$import f64))
(import "env" "abort" (func $ja (param i32)))
(import "env" "_pthread_cleanup_pop" (func $oa (param i32)))
(import "env" "___lock" (func $pa (param i32)))
@@ -28,38 +24,13 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(data (get_global $memoryBase) "memorygrowth.asm.js")
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
- (global $t (mut i32) (get_global $t$asm2wasm$import))
- (global $u (mut i32) (get_global $u$asm2wasm$import))
(global $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
- (global $x (mut i32) (i32.const 0))
- (global $y (mut i32) (i32.const 0))
- (global $z (mut f64) (get_global $z$asm2wasm$import))
- (global $A (mut f64) (get_global $A$asm2wasm$import))
- (global $B (mut i32) (i32.const 0))
- (global $C (mut i32) (i32.const 0))
- (global $D (mut i32) (i32.const 0))
- (global $E (mut i32) (i32.const 0))
- (global $F (mut f64) (f64.const 0))
- (global $G (mut i32) (i32.const 0))
- (global $H (mut i32) (i32.const 0))
- (global $I (mut i32) (i32.const 0))
- (global $J (mut f64) (f64.const 0))
(global $K (mut i32) (i32.const 0))
- (global $L (mut i32) (i32.const 0))
- (global $M (mut i32) (i32.const 0))
- (global $N (mut i32) (i32.const 0))
- (global $O (mut i32) (i32.const 0))
- (global $P (mut i32) (i32.const 0))
- (global $Q (mut i32) (i32.const 0))
- (global $R (mut i32) (i32.const 0))
- (global $S (mut i32) (i32.const 0))
- (global $T (mut i32) (i32.const 0))
- (global $za (mut f64) (f64.const 0))
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index 4301d1105..c1f308b20 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -7,10 +7,6 @@
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import "env" "STACKTOP" (global $r$asm2wasm$import i32))
(import "env" "STACK_MAX" (global $s$asm2wasm$import i32))
- (import "env" "tempDoublePtr" (global $t$asm2wasm$import i32))
- (import "env" "ABORT" (global $u$asm2wasm$import i32))
- (import "global" "NaN" (global $z$asm2wasm$import f64))
- (import "global" "Infinity" (global $A$asm2wasm$import f64))
(import "env" "abort" (func $ja (param i32)))
(import "env" "_pthread_cleanup_pop" (func $oa (param i32)))
(import "env" "___lock" (func $pa (param i32)))
@@ -27,37 +23,12 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
- (global $t (mut i32) (get_global $t$asm2wasm$import))
- (global $u (mut i32) (get_global $u$asm2wasm$import))
(global $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
- (global $x (mut i32) (i32.const 0))
- (global $y (mut i32) (i32.const 0))
- (global $z (mut f64) (get_global $z$asm2wasm$import))
- (global $A (mut f64) (get_global $A$asm2wasm$import))
- (global $B (mut i32) (i32.const 0))
- (global $C (mut i32) (i32.const 0))
- (global $D (mut i32) (i32.const 0))
- (global $E (mut i32) (i32.const 0))
- (global $F (mut f64) (f64.const 0))
- (global $G (mut i32) (i32.const 0))
- (global $H (mut i32) (i32.const 0))
- (global $I (mut i32) (i32.const 0))
- (global $J (mut f64) (f64.const 0))
(global $K (mut i32) (i32.const 0))
- (global $L (mut i32) (i32.const 0))
- (global $M (mut i32) (i32.const 0))
- (global $N (mut i32) (i32.const 0))
- (global $O (mut i32) (i32.const 0))
- (global $P (mut i32) (i32.const 0))
- (global $Q (mut i32) (i32.const 0))
- (global $R (mut i32) (i32.const 0))
- (global $S (mut i32) (i32.const 0))
- (global $T (mut i32) (i32.const 0))
- (global $za (mut f64) (f64.const 0))
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts
index 579ea01fa..26108171f 100644
--- a/test/memorygrowth.fromasm.imprecise.no-opts
+++ b/test/memorygrowth.fromasm.imprecise.no-opts
@@ -27,7 +27,7 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
(global $t (mut i32) (get_global $t$asm2wasm$import))
diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts
index 7c877fb39..ef9478371 100644
--- a/test/memorygrowth.fromasm.no-opts
+++ b/test/memorygrowth.fromasm.no-opts
@@ -28,7 +28,7 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(global $r (mut i32) (get_global $r$asm2wasm$import))
(global $s (mut i32) (get_global $s$asm2wasm$import))
(global $t (mut i32) (get_global $t$asm2wasm$import))
diff --git a/test/min.fromasm b/test/min.fromasm
index c54c786a6..4287f6259 100644
--- a/test/min.fromasm
+++ b/test/min.fromasm
@@ -1,16 +1,14 @@
(module
- (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(data (get_global $memoryBase) "min.asm.js")
- (global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
- (export "floats" (func $floats))
+ (export "floats" (func $legalstub$floats))
(export "getTempRet0" (func $ub))
- (export "neg" (func $neg))
- (export "bitcasts" (func $bitcasts))
+ (export "neg" (func $legalstub$neg))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "ctzzzz" (func $ctzzzz))
(func $floats (param $0 f32) (result f32)
(local $1 f32)
@@ -42,4 +40,29 @@
)
(get_global $M)
)
+ (func $legalstub$floats (param $0 f64) (result f64)
+ (f64.promote/f32
+ (call $floats
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalstub$neg (param $0 i32) (param $1 i32) (result f64)
+ (f64.promote/f32
+ (call $neg
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
)
diff --git a/test/min.fromasm.imprecise b/test/min.fromasm.imprecise
index d2a09dd4e..302f64c53 100644
--- a/test/min.fromasm.imprecise
+++ b/test/min.fromasm.imprecise
@@ -1,15 +1,13 @@
(module
- (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
- (export "floats" (func $floats))
+ (export "floats" (func $legalstub$floats))
(export "getTempRet0" (func $ub))
- (export "neg" (func $neg))
- (export "bitcasts" (func $bitcasts))
+ (export "neg" (func $legalstub$neg))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "ctzzzz" (func $ctzzzz))
(func $floats (param $0 f32) (result f32)
(local $1 f32)
@@ -41,4 +39,29 @@
)
(get_global $M)
)
+ (func $legalstub$floats (param $0 f64) (result f64)
+ (f64.promote/f32
+ (call $floats
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalstub$neg (param $0 i32) (param $1 i32) (result f64)
+ (f64.promote/f32
+ (call $neg
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
)
diff --git a/test/min.fromasm.imprecise.no-opts b/test/min.fromasm.imprecise.no-opts
index 4bbdeff65..6e8a1c9ea 100644
--- a/test/min.fromasm.imprecise.no-opts
+++ b/test/min.fromasm.imprecise.no-opts
@@ -6,10 +6,10 @@
(import "env" "tableBase" (global $tableBase i32))
(global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
- (export "floats" (func $floats))
+ (export "floats" (func $legalstub$floats))
(export "getTempRet0" (func $ub))
- (export "neg" (func $neg))
- (export "bitcasts" (func $bitcasts))
+ (export "neg" (func $legalstub$neg))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "ctzzzz" (func $ctzzzz))
(func $floats (param $f f32) (result f32)
(local $t f32)
@@ -73,4 +73,29 @@
(get_global $M)
)
)
+ (func $legalstub$floats (param $0 f64) (result f64)
+ (f64.promote/f32
+ (call $floats
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalstub$neg (param $0 i32) (param $1 i32) (result f64)
+ (f64.promote/f32
+ (call $neg
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
)
diff --git a/test/min.fromasm.no-opts b/test/min.fromasm.no-opts
index 4bbdeff65..6e8a1c9ea 100644
--- a/test/min.fromasm.no-opts
+++ b/test/min.fromasm.no-opts
@@ -6,10 +6,10 @@
(import "env" "tableBase" (global $tableBase i32))
(global $tDP (mut i32) (get_global $tDP$asm2wasm$import))
(global $M (mut i32) (i32.const 0))
- (export "floats" (func $floats))
+ (export "floats" (func $legalstub$floats))
(export "getTempRet0" (func $ub))
- (export "neg" (func $neg))
- (export "bitcasts" (func $bitcasts))
+ (export "neg" (func $legalstub$neg))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "ctzzzz" (func $ctzzzz))
(func $floats (param $f f32) (result f32)
(local $t f32)
@@ -73,4 +73,29 @@
(get_global $M)
)
)
+ (func $legalstub$floats (param $0 f64) (result f64)
+ (f64.promote/f32
+ (call $floats
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalstub$neg (param $0 i32) (param $1 i32) (result f64)
+ (f64.promote/f32
+ (call $neg
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
)
diff --git a/test/passes/remove-unused-functions.txt b/test/passes/remove-unused-functions.txt
deleted file mode 100644
index 6e4a452b3..000000000
--- a/test/passes/remove-unused-functions.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-(module
- (type $0 (func))
- (table 1 1 anyfunc)
- (elem (i32.const 0) $called_indirect)
- (memory $0 0)
- (export "memory" (memory $0))
- (export "exported" (func $exported))
- (start $start)
- (func $start (type $0)
- (call $called0)
- )
- (func $called0 (type $0)
- (call $called1)
- )
- (func $called1 (type $0)
- (nop)
- )
- (func $called_indirect (type $0)
- (nop)
- )
- (func $exported (type $0)
- (call $called2)
- )
- (func $called2 (type $0)
- (call $called2)
- (call $called3)
- )
- (func $called3 (type $0)
- (call $called4)
- )
- (func $called4 (type $0)
- (call $called3)
- )
-)
diff --git a/test/passes/remove-unused-functions.wast b/test/passes/remove-unused-functions.wast
deleted file mode 100644
index c3d25d021..000000000
--- a/test/passes/remove-unused-functions.wast
+++ /dev/null
@@ -1,49 +0,0 @@
-(module
- (memory 0)
- (start $start)
- (type $0 (func))
- (export "memory" (memory $0))
- (export "exported" $exported)
- (table 1 1 anyfunc)
- (elem (i32.const 0) $called_indirect)
- (func $start (type $0)
- (call $called0)
- )
- (func $called0 (type $0)
- (call $called1)
- )
- (func $called1 (type $0)
- (nop)
- )
- (func $called_indirect (type $0)
- (nop)
- )
- (func $exported (type $0)
- (call $called2)
- )
- (func $called2 (type $0)
- (call $called2)
- (call $called3)
- )
- (func $called3 (type $0)
- (call $called4)
- )
- (func $called4 (type $0)
- (call $called3)
- )
- (func $remove0 (type $0)
- (call $remove1)
- )
- (func $remove1 (type $0)
- (nop)
- )
- (func $remove2 (type $0)
- (call $remove2)
- )
- (func $remove3 (type $0)
- (call $remove4)
- )
- (func $remove4 (type $0)
- (call $remove3)
- )
-)
diff --git a/test/passes/remove-unused-module-elements.txt b/test/passes/remove-unused-module-elements.txt
new file mode 100644
index 000000000..8b8fd3601
--- /dev/null
+++ b/test/passes/remove-unused-module-elements.txt
@@ -0,0 +1,87 @@
+(module
+ (type $0 (func))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $called_indirect)
+ (memory $0 0)
+ (export "memory" (memory $0))
+ (export "exported" (func $exported))
+ (start $start)
+ (func $start (type $0)
+ (call $called0)
+ )
+ (func $called0 (type $0)
+ (call $called1)
+ )
+ (func $called1 (type $0)
+ (nop)
+ )
+ (func $called_indirect (type $0)
+ (nop)
+ )
+ (func $exported (type $0)
+ (call $called2)
+ )
+ (func $called2 (type $0)
+ (call $called2)
+ (call $called3)
+ )
+ (func $called3 (type $0)
+ (call $called4)
+ )
+ (func $called4 (type $0)
+ (call $called3)
+ )
+)
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+)
+(module
+ (type $0 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $waka)
+ (data (get_global $memoryBase) "hello, world!")
+ (func $waka (type $0)
+ (nop)
+ )
+)
+(module
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (type $1 (func (result i32)))
+ (type $2 (func))
+ (import "env" "imported" (global $imported i32))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (memory $0 0)
+ (global $int (mut i32) (get_global $imported))
+ (global $set (mut i32) (i32.const 100))
+ (global $exp_glob i32 (i32.const 600))
+ (export "one" (func $one))
+ (export "three" (func $three))
+ (export "exp_glob" (global $exp_glob))
+ (start $starter)
+ (func $one (type $1) (result i32)
+ (call $two)
+ )
+ (func $two (type $1) (result i32)
+ (get_global $int)
+ )
+ (func $three (type $2)
+ (call $four)
+ )
+ (func $four (type $2)
+ (set_global $set
+ (i32.const 200)
+ )
+ (drop
+ (call $_puts
+ (i32.const 300)
+ )
+ )
+ )
+ (func $starter (type $2)
+ (nop)
+ )
+)
diff --git a/test/passes/remove-unused-module-elements.wast b/test/passes/remove-unused-module-elements.wast
new file mode 100644
index 000000000..eb071ee66
--- /dev/null
+++ b/test/passes/remove-unused-module-elements.wast
@@ -0,0 +1,96 @@
+(module
+ (memory 0)
+ (start $start)
+ (type $0 (func))
+ (export "memory" (memory $0))
+ (export "exported" $exported)
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $called_indirect)
+ (func $start (type $0)
+ (call $called0)
+ )
+ (func $called0 (type $0)
+ (call $called1)
+ )
+ (func $called1 (type $0)
+ (nop)
+ )
+ (func $called_indirect (type $0)
+ (nop)
+ )
+ (func $exported (type $0)
+ (call $called2)
+ )
+ (func $called2 (type $0)
+ (call $called2)
+ (call $called3)
+ )
+ (func $called3 (type $0)
+ (call $called4)
+ )
+ (func $called4 (type $0)
+ (call $called3)
+ )
+ (func $remove0 (type $0)
+ (call $remove1)
+ )
+ (func $remove1 (type $0)
+ (nop)
+ )
+ (func $remove2 (type $0)
+ (call $remove2)
+ )
+ (func $remove3 (type $0)
+ (call $remove4)
+ )
+ (func $remove4 (type $0)
+ (call $remove3)
+ )
+)
+(module ;; leave the table and memory alone
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+)
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32)) ;; used in init
+ (import "env" "tableBase" (global $tableBase i32)) ;; used in init
+ (data (get_global $memoryBase) "hello, world!")
+ (elem (get_global $tableBase) $waka)
+ (func $waka) ;; used in table
+)
+(module ;; one is exported, and one->two->int global, whose init->imported
+ (import "env" "imported" (global $imported i32))
+ (import "env" "forgetme" (global $forgetme i32))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "forget_puts" (func $forget_puts (param i32) (result i32)))
+ (global $int (mut i32) (get_global $imported))
+ (global $set (mut i32) (i32.const 100))
+ (global $forget_global (mut i32) (i32.const 500))
+ (global $exp_glob i32 (i32.const 600))
+ (export "one" (func $one))
+ (export "three" (func $three))
+ (export "exp_glob" (global $exp_glob))
+ (start $starter)
+ (func $one (result i32)
+ (call $two)
+ )
+ (func $two (result i32)
+ (get_global $int)
+ )
+ (func $three
+ (call $four)
+ )
+ (func $four
+ (set_global $set (i32.const 200))
+ (drop (call $_puts (i32.const 300)))
+ )
+ (func $forget_implemented
+ (nop)
+ )
+ (func $starter
+ (nop)
+ )
+)
+
diff --git a/test/unit.asm.js b/test/unit.asm.js
index 84fb346cc..a865350f6 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -7,6 +7,8 @@ function asm(global, env, buffer) {
var Math_fround = global.Math.fround;
var Math_abs = global.Math.abs;
var Math_ceil = global.Math.ceil;
+ var Math_max = global.Math.max;
+ var Math_min = global.Math.min;
var tempDoublePtr = env.tempDoublePtr | 0;
var n = env.gb | 0;
var STACKTOP = env.STACKTOP | 0;
@@ -158,6 +160,13 @@ function asm(global, env, buffer) {
y = +Math_abs(0.0);
z = Math_fround(Math_abs(Math_fround(0)));
}
+ function minmax() {
+ var x = 0.0, y = 0.0, z = Math_fround(0), w = Math_fround(0);
+ x = +Math_min(+x, +y);
+ y = +Math_max(+x, +y);
+ z = Math_fround(Math_min(Math_fround(z), Math_fround(w)));
+ w = Math_fround(Math_max(Math_fround(z), Math_fround(w)));
+ }
function neg() {
var x = Math_fround(0);
x = Math_fround(-x);
@@ -652,6 +661,19 @@ function asm(global, env, buffer) {
HEAPF64[10] = Math_fround(x|0);
}
+ function relocatableAndModules() {
+ ftCall_v(10); // function table call
+ mftCall_v(20); // possible inter-module function table call
+ return ftCall_idi(30, 1.5, 200) | 0; // with args
+ }
+
+ function exported_f32_user(x, y, z) {
+ x = x | 0;
+ y = Math_fround(y);
+ z = +z;
+ return Math_fround(y);
+ }
+
function v() {
}
function vi(x) {
@@ -663,6 +685,6 @@ function asm(global, env, buffer) {
var FUNCTION_TABLE_c = [ z, cneg, z, z, z, z, z, z ];
var FUNCTION_TABLE_vi = [ vi, vi, vi, vi, vi, vi, vi, vi ];
- return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, big_uint_div_u: big_uint_div_u, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useSetGlobal: useSetGlobal, usesSetGlobal2: usesSetGlobal2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround };
+ return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, big_uint_div_u: big_uint_div_u, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useSetGlobal: useSetGlobal, usesSetGlobal2: usesSetGlobal2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround, exportedNumber: 42, relocatableAndModules: relocatableAndModules, exported_f32_user: exported_f32_user };
}
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 4529af055..e18bfd16a 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -4,14 +4,12 @@
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$idi (func (param f64 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
- (import "global" "NaN" (global $t$asm2wasm$import f64))
- (import "global" "Infinity" (global $u$asm2wasm$import f64))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
(import "env" "gb" (global $n$asm2wasm$import i32))
- (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "setTempRet0" (func $setTempRet0 (param i32) (result i32)))
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
@@ -24,15 +22,12 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
+ (elem (get_global $tableBase) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
(data (get_global $memoryBase) "unit.asm.js")
- (global $t (mut f64) (get_global $t$asm2wasm$import))
- (global $u (mut f64) (get_global $u$asm2wasm$import))
(global $Int (mut i32) (i32.const 0))
(global $Double (mut f64) (f64.const 0))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
- (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $exportedNumber i32 (i32.const 42))
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
@@ -41,16 +36,16 @@
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "big_uint_div_u" (func $big_uint_div_u))
- (export "fr" (func $fr))
+ (export "fr" (func $legalstub$fr))
(export "negZero" (func $negZero))
(export "neg" (func $neg))
(export "smallCompare" (func $smallCompare))
(export "cneg_nosemicolon" (func $cneg_nosemicolon))
(export "forLoop" (func $forLoop))
- (export "ceiling_32_64" (func $ceiling_32_64))
+ (export "ceiling_32_64" (func $legalstub$ceiling_32_64))
(export "aborts" (func $aborts))
(export "continues" (func $continues))
- (export "bitcasts" (func $bitcasts))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "recursiveBlockMerging" (func $recursiveBlockMerging))
(export "lb" (func $lb))
(export "zeroInit" (func $zeroInit))
@@ -76,6 +71,9 @@
(export "dropIgnoredImportsInIf" (func $dropIgnoredImportsInIf))
(export "relooperJumpThreading_irreducible" (func $relooperJumpThreading_irreducible))
(export "store_fround" (func $store_fround))
+ (export "exportedNumber" (global $exportedNumber))
+ (export "relocatableAndModules" (func $relocatableAndModules))
+ (export "exported_f32_user" (func $legalstub$exported_f32_user))
(func $big_negative
(nop)
)
@@ -1136,7 +1134,57 @@
)
)
)
+ (func $relocatableAndModules (result i32)
+ (call_indirect $FUNCSIG$v
+ (i32.const 10)
+ )
+ (call_indirect $FUNCSIG$v
+ (i32.const 20)
+ )
+ (call_indirect $FUNCSIG$idi
+ (f64.const 1.5)
+ (i32.const 200)
+ (i32.const 30)
+ )
+ )
+ (func $exported_f32_user (param $0 i32) (param $1 f32) (param $2 f64) (result f32)
+ (get_local $1)
+ )
(func $vi (param $0 i32)
(nop)
)
+ (func $legalstub$fr (param $0 f64)
+ (call $fr
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ (func $legalstub$ceiling_32_64 (param $0 f64) (param $1 f64)
+ (call $ceiling_32_64
+ (f32.demote/f64
+ (get_local $0)
+ )
+ (get_local $1)
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$exported_f32_user (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
+ (f64.promote/f32
+ (call $exported_f32_user
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ (get_local $2)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index 62c73c681..2ec8b82ff 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -2,14 +2,12 @@
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$idi (func (param f64 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
- (import "global" "NaN" (global $t$asm2wasm$import f64))
- (import "global" "Infinity" (global $u$asm2wasm$import f64))
- (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
(import "env" "gb" (global $n$asm2wasm$import i32))
- (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(import "env" "setTempRet0" (func $setTempRet0 (param i32) (result i32)))
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
@@ -20,14 +18,11 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
- (global $t (mut f64) (get_global $t$asm2wasm$import))
- (global $u (mut f64) (get_global $u$asm2wasm$import))
+ (elem (get_global $tableBase) $big_negative $big_negative $big_negative $big_negative $w $w $importedDoubles $w $fr $cneg $fr $fr $fr $fr $fr $fr $vi $vi $vi $vi $vi $vi $vi $vi)
(global $Int (mut i32) (i32.const 0))
(global $Double (mut f64) (f64.const 0))
- (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
- (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $exportedNumber i32 (i32.const 42))
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
@@ -36,16 +31,16 @@
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "big_uint_div_u" (func $big_uint_div_u))
- (export "fr" (func $fr))
+ (export "fr" (func $legalstub$fr))
(export "negZero" (func $negZero))
(export "neg" (func $neg))
(export "smallCompare" (func $smallCompare))
(export "cneg_nosemicolon" (func $cneg_nosemicolon))
(export "forLoop" (func $forLoop))
- (export "ceiling_32_64" (func $ceiling_32_64))
+ (export "ceiling_32_64" (func $legalstub$ceiling_32_64))
(export "aborts" (func $aborts))
(export "continues" (func $continues))
- (export "bitcasts" (func $bitcasts))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "recursiveBlockMerging" (func $recursiveBlockMerging))
(export "lb" (func $lb))
(export "zeroInit" (func $zeroInit))
@@ -71,6 +66,9 @@
(export "dropIgnoredImportsInIf" (func $dropIgnoredImportsInIf))
(export "relooperJumpThreading_irreducible" (func $relooperJumpThreading_irreducible))
(export "store_fround" (func $store_fround))
+ (export "exportedNumber" (global $exportedNumber))
+ (export "relocatableAndModules" (func $relocatableAndModules))
+ (export "exported_f32_user" (func $legalstub$exported_f32_user))
(func $big_negative
(nop)
)
@@ -1112,7 +1110,57 @@
)
)
)
+ (func $relocatableAndModules (result i32)
+ (call_indirect $FUNCSIG$v
+ (i32.const 10)
+ )
+ (call_indirect $FUNCSIG$v
+ (i32.const 20)
+ )
+ (call_indirect $FUNCSIG$idi
+ (f64.const 1.5)
+ (i32.const 200)
+ (i32.const 30)
+ )
+ )
+ (func $exported_f32_user (param $0 i32) (param $1 f32) (param $2 f64) (result f32)
+ (get_local $1)
+ )
(func $vi (param $0 i32)
(nop)
)
+ (func $legalstub$fr (param $0 f64)
+ (call $fr
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ (func $legalstub$ceiling_32_64 (param $0 f64) (param $1 f64)
+ (call $ceiling_32_64
+ (f32.demote/f64
+ (get_local $0)
+ )
+ (get_local $1)
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$exported_f32_user (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
+ (f64.promote/f32
+ (call $exported_f32_user
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ (get_local $2)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 12fb31212..fe2e7edbd 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -2,6 +2,8 @@
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$idi (func (param f64 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
@@ -20,7 +22,7 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $v $big_negative $v $v $w $w $importedDoubles $w $z $cneg $z $z $z $z $z $z $vi $vi $vi $vi $vi $vi $vi $vi)
+ (elem (get_global $tableBase) $v $big_negative $v $v $w $w $importedDoubles $w $z $cneg $z $z $z $z $z $z $vi $vi $vi $vi $vi $vi $vi $vi)
(global $t (mut f64) (get_global $t$asm2wasm$import))
(global $u (mut f64) (get_global $u$asm2wasm$import))
(global $Int (mut i32) (i32.const 0))
@@ -28,6 +30,7 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $exportedNumber i32 (i32.const 42))
(export "big_negative" (func $big_negative))
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
@@ -36,16 +39,16 @@
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "big_uint_div_u" (func $big_uint_div_u))
- (export "fr" (func $fr))
+ (export "fr" (func $legalstub$fr))
(export "negZero" (func $negZero))
(export "neg" (func $neg))
(export "smallCompare" (func $smallCompare))
(export "cneg_nosemicolon" (func $cneg_nosemicolon))
(export "forLoop" (func $forLoop))
- (export "ceiling_32_64" (func $ceiling_32_64))
+ (export "ceiling_32_64" (func $legalstub$ceiling_32_64))
(export "aborts" (func $aborts))
(export "continues" (func $continues))
- (export "bitcasts" (func $bitcasts))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "recursiveBlockMerging" (func $recursiveBlockMerging))
(export "lb" (func $lb))
(export "zeroInit" (func $zeroInit))
@@ -71,6 +74,9 @@
(export "dropIgnoredImportsInIf" (func $dropIgnoredImportsInIf))
(export "relooperJumpThreading_irreducible" (func $relooperJumpThreading_irreducible))
(export "store_fround" (func $store_fround))
+ (export "exportedNumber" (global $exportedNumber))
+ (export "relocatableAndModules" (func $relocatableAndModules))
+ (export "exported_f32_user" (func $legalstub$exported_f32_user))
(func $big_negative
(local $temp f64)
(set_local $temp
@@ -450,6 +456,36 @@
)
)
)
+ (func $minmax
+ (local $x f64)
+ (local $y f64)
+ (local $z f32)
+ (local $w f32)
+ (set_local $x
+ (f64.min
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (set_local $y
+ (f64.max
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (set_local $z
+ (f32.min
+ (get_local $z)
+ (get_local $w)
+ )
+ )
+ (set_local $w
+ (f32.max
+ (get_local $z)
+ (get_local $w)
+ )
+ )
+ )
(func $neg
(local $x f32)
(set_local $x
@@ -1798,10 +1834,64 @@
)
)
)
+ (func $relocatableAndModules (result i32)
+ (call_indirect $FUNCSIG$v
+ (i32.const 10)
+ )
+ (call_indirect $FUNCSIG$v
+ (i32.const 20)
+ )
+ (return
+ (call_indirect $FUNCSIG$idi
+ (f64.const 1.5)
+ (i32.const 200)
+ (i32.const 30)
+ )
+ )
+ )
+ (func $exported_f32_user (param $x i32) (param $y f32) (param $z f64) (result f32)
+ (return
+ (get_local $y)
+ )
+ )
(func $v
(nop)
)
(func $vi (param $x i32)
(nop)
)
+ (func $legalstub$fr (param $0 f64)
+ (call $fr
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ (func $legalstub$ceiling_32_64 (param $0 f64) (param $1 f64)
+ (call $ceiling_32_64
+ (f32.demote/f64
+ (get_local $0)
+ )
+ (get_local $1)
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$exported_f32_user (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
+ (f64.promote/f32
+ (call $exported_f32_user
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ (get_local $2)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index fead97f27..960ee6c5f 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -4,6 +4,8 @@
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$idi (func (param f64 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
(type $FUNCSIG$i (func (result i32)))
@@ -24,7 +26,7 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $v $big_negative $v $v $w $w $importedDoubles $w $z $cneg $z $z $z $z $z $z $vi $vi $vi $vi $vi $vi $vi $vi)
+ (elem (get_global $tableBase) $v $big_negative $v $v $w $w $importedDoubles $w $z $cneg $z $z $z $z $z $z $vi $vi $vi $vi $vi $vi $vi $vi)
(global $t (mut f64) (get_global $t$asm2wasm$import))
(global $u (mut f64) (get_global $u$asm2wasm$import))
(global $Int (mut i32) (i32.const 0))
@@ -32,6 +34,7 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $exportedNumber i32 (i32.const 42))
(export "big_negative" (func $big_negative))
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
@@ -40,16 +43,16 @@
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "big_uint_div_u" (func $big_uint_div_u))
- (export "fr" (func $fr))
+ (export "fr" (func $legalstub$fr))
(export "negZero" (func $negZero))
(export "neg" (func $neg))
(export "smallCompare" (func $smallCompare))
(export "cneg_nosemicolon" (func $cneg_nosemicolon))
(export "forLoop" (func $forLoop))
- (export "ceiling_32_64" (func $ceiling_32_64))
+ (export "ceiling_32_64" (func $legalstub$ceiling_32_64))
(export "aborts" (func $aborts))
(export "continues" (func $continues))
- (export "bitcasts" (func $bitcasts))
+ (export "bitcasts" (func $legalstub$bitcasts))
(export "recursiveBlockMerging" (func $recursiveBlockMerging))
(export "lb" (func $lb))
(export "zeroInit" (func $zeroInit))
@@ -75,6 +78,9 @@
(export "dropIgnoredImportsInIf" (func $dropIgnoredImportsInIf))
(export "relooperJumpThreading_irreducible" (func $relooperJumpThreading_irreducible))
(export "store_fround" (func $store_fround))
+ (export "exportedNumber" (global $exportedNumber))
+ (export "relocatableAndModules" (func $relocatableAndModules))
+ (export "exported_f32_user" (func $legalstub$exported_f32_user))
(func $big_negative
(local $temp f64)
(set_local $temp
@@ -456,6 +462,36 @@
)
)
)
+ (func $minmax
+ (local $x f64)
+ (local $y f64)
+ (local $z f32)
+ (local $w f32)
+ (set_local $x
+ (f64.min
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (set_local $y
+ (f64.max
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (set_local $z
+ (f32.min
+ (get_local $z)
+ (get_local $w)
+ )
+ )
+ (set_local $w
+ (f32.max
+ (get_local $z)
+ (get_local $w)
+ )
+ )
+ )
(func $neg
(local $x f32)
(set_local $x
@@ -1804,10 +1840,64 @@
)
)
)
+ (func $relocatableAndModules (result i32)
+ (call_indirect $FUNCSIG$v
+ (i32.const 10)
+ )
+ (call_indirect $FUNCSIG$v
+ (i32.const 20)
+ )
+ (return
+ (call_indirect $FUNCSIG$idi
+ (f64.const 1.5)
+ (i32.const 200)
+ (i32.const 30)
+ )
+ )
+ )
+ (func $exported_f32_user (param $x i32) (param $y f32) (param $z f64) (result f32)
+ (return
+ (get_local $y)
+ )
+ )
(func $v
(nop)
)
(func $vi (param $x i32)
(nop)
)
+ (func $legalstub$fr (param $0 f64)
+ (call $fr
+ (f32.demote/f64
+ (get_local $0)
+ )
+ )
+ )
+ (func $legalstub$ceiling_32_64 (param $0 f64) (param $1 f64)
+ (call $ceiling_32_64
+ (f32.demote/f64
+ (get_local $0)
+ )
+ (get_local $1)
+ )
+ )
+ (func $legalstub$bitcasts (param $0 i32) (param $1 f64)
+ (call $bitcasts
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ )
+ )
+ (func $legalstub$exported_f32_user (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
+ (f64.promote/f32
+ (call $exported_f32_user
+ (get_local $0)
+ (f32.demote/f64
+ (get_local $1)
+ )
+ (get_local $2)
+ )
+ )
+ )
)
diff --git a/test/wasm-only.asm.js b/test/wasm-only.asm.js
index eab63ba2b..cf0119cd7 100644
--- a/test/wasm-only.asm.js
+++ b/test/wasm-only.asm.js
@@ -21,6 +21,9 @@ function asm(global, env, buffer) {
var illegalImport = env.illegalImport;
var illegalImportResult = env.illegalImportResult;
+ var _fabsf = env._fabsf;
+ var do_i64 = env.do_i64;
+
function loads() {
var i = 0, f = fround(0), d = +0;
i = load1(100);
@@ -237,6 +240,13 @@ function asm(global, env, buffer) {
switch64(i64(0)) | 0;
}
+ function __emscripten_dceable_type_decls() { // dce-able, but this defines the type of fabsf which has no other use
+ fround(_fabsf(fround(0.0)));
+ i64(do_i64());
+ }
+
+ var FUNCTION_TABLE_X = [illegalImport, _fabsf, do_i64]; // must stay ok in the table, not legalized, as it will be called internally by the true type
+
return { test64: test64, illegalParam : illegalParam, illegalResult: illegalResult, keepAlive: keepAlive };
}
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index adcc66137..ae8bddbbc 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -1,17 +1,26 @@
(module
(type $FUNCSIG$vdji (func (param f64 i64 i32)))
(type $FUNCSIG$j (func (result i64)))
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
+ (type $legaltype$_fabsf (func (param f64) (result f64)))
+ (type $legaltype$do_i64 (func (result i32)))
(import "env" "illegalImport" (func $illegalImport (param f64 i64 i32)))
(import "env" "illegalImportResult" (func $illegalImportResult (result i64)))
+ (import "env" "_fabsf" (func $_fabsf (param f32) (result f32)))
+ (import "env" "do_i64" (func $do_i64 (result i64)))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
+ (import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
+ (import "env" "do_i64" (func $legalimport$do_i64 (result i32)))
(import "env" "memory" (memory $0 256 256))
- (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
(data (get_global $memoryBase) "wasm-only.asm.js")
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$result))
@@ -397,7 +406,14 @@
(set_local $0
(call $result)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -424,7 +440,29 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
+ )
+ (i64.const 32)
+ )
+ )
+ )
+ (func $legalfunc$_fabsf (param $0 f32) (result f32)
+ (f32.demote/f64
+ (call $legalimport$_fabsf
+ (f64.promote/f32
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalfunc$do_i64 (result i64)
+ (i64.or
+ (i64.extend_u/i32
+ (call $legalimport$do_i64)
+ )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index def563598..a6c5b3f50 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -1,16 +1,25 @@
(module
(type $FUNCSIG$vdji (func (param f64 i64 i32)))
(type $FUNCSIG$j (func (result i64)))
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
+ (type $legaltype$_fabsf (func (param f64) (result f64)))
+ (type $legaltype$do_i64 (func (result i32)))
(import "env" "illegalImport" (func $illegalImport (param f64 i64 i32)))
(import "env" "illegalImportResult" (func $illegalImportResult (result i64)))
+ (import "env" "_fabsf" (func $_fabsf (param f32) (result f32)))
+ (import "env" "do_i64" (func $do_i64 (result i64)))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
+ (import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
+ (import "env" "do_i64" (func $legalimport$do_i64 (result i32)))
(import "env" "memory" (memory $0 256 256))
- (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$result))
@@ -325,7 +334,14 @@
(set_local $0
(call $result)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -352,7 +368,29 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
+ )
+ (i64.const 32)
+ )
+ )
+ )
+ (func $legalfunc$_fabsf (param $0 f32) (result f32)
+ (f32.demote/f64
+ (call $legalimport$_fabsf
+ (f64.promote/f32
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalfunc$do_i64 (result i64)
+ (i64.or
+ (i64.extend_u/i32
+ (call $legalimport$do_i64)
+ )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index 1e818877c..d718ccc24 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -1,16 +1,25 @@
(module
(type $FUNCSIG$vdji (func (param f64 i64 i32)))
(type $FUNCSIG$j (func (result i64)))
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
+ (type $legaltype$_fabsf (func (param f64) (result f64)))
+ (type $legaltype$do_i64 (func (result i32)))
(import "env" "illegalImport" (func $illegalImport (param f64 i64 i32)))
(import "env" "illegalImportResult" (func $illegalImportResult (result i64)))
+ (import "env" "_fabsf" (func $_fabsf (param f32) (result f32)))
+ (import "env" "do_i64" (func $do_i64 (result i64)))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
+ (import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
+ (import "env" "do_i64" (func $legalimport$do_i64 (result i32)))
(import "env" "memory" (memory $0 256 256))
- (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
@@ -753,6 +762,16 @@
)
)
)
+ (func $__emscripten_dceable_type_decls
+ (drop
+ (call $legalfunc$_fabsf
+ (f32.const 0)
+ )
+ )
+ (drop
+ (call $legalfunc$do_i64)
+ )
+ )
(func $legalstub$illegalParam (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
@@ -775,7 +794,14 @@
(set_local $0
(call $illegalResult)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -802,7 +828,29 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
+ )
+ (i64.const 32)
+ )
+ )
+ )
+ (func $legalfunc$_fabsf (param $0 f32) (result f32)
+ (f32.demote/f64
+ (call $legalimport$_fabsf
+ (f64.promote/f32
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalfunc$do_i64 (result i64)
+ (i64.or
+ (i64.extend_u/i32
+ (call $legalimport$do_i64)
+ )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_global $tempRet0)
)
(i64.const 32)
)
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index 1c3a0bf5c..e208f870f 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -1,16 +1,25 @@
(module
(type $FUNCSIG$vdji (func (param f64 i64 i32)))
(type $FUNCSIG$j (func (result i64)))
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
+ (type $legaltype$_fabsf (func (param f64) (result f64)))
+ (type $legaltype$do_i64 (func (result i32)))
(import "env" "illegalImport" (func $illegalImport (param f64 i64 i32)))
(import "env" "illegalImportResult" (func $illegalImportResult (result i64)))
+ (import "env" "_fabsf" (func $_fabsf (param f32) (result f32)))
+ (import "env" "do_i64" (func $do_i64 (result i64)))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
+ (import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
+ (import "env" "do_i64" (func $legalimport$do_i64 (result i32)))
(import "env" "memory" (memory $0 256 256))
- (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
+ (global $tempRet0 (mut i32) (i32.const 0))
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
@@ -801,6 +810,16 @@
)
)
)
+ (func $__emscripten_dceable_type_decls
+ (drop
+ (call $legalfunc$_fabsf
+ (f32.const 0)
+ )
+ )
+ (drop
+ (call $legalfunc$do_i64)
+ )
+ )
(func $legalstub$illegalParam (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
@@ -823,7 +842,14 @@
(set_local $0
(call $illegalResult)
)
- (unreachable)
+ (set_global $tempRet0
+ (i32.wrap/i64
+ (i64.shr_u
+ (get_local $0)
+ (i64.const 32)
+ )
+ )
+ )
(i32.wrap/i64
(get_local $0)
)
@@ -850,7 +876,29 @@
)
(i64.shl
(i64.extend_u/i32
- (unreachable)
+ (get_global $tempRet0)
+ )
+ (i64.const 32)
+ )
+ )
+ )
+ (func $legalfunc$_fabsf (param $0 f32) (result f32)
+ (f32.demote/f64
+ (call $legalimport$_fabsf
+ (f64.promote/f32
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $legalfunc$do_i64 (result i64)
+ (i64.or
+ (i64.extend_u/i32
+ (call $legalimport$do_i64)
+ )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_global $tempRet0)
)
(i64.const 32)
)