summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/asm2wasm.h33
-rw-r--r--src/passes/Print.cpp8
-rw-r--r--test/dynamicLibrary.asm.js136
-rw-r--r--test/dynamicLibrary.fromasm80
-rw-r--r--test/dynamicLibrary.fromasm.imprecise79
-rw-r--r--test/dynamicLibrary.fromasm.imprecise.no-opts191
-rw-r--r--test/dynamicLibrary.fromasm.no-opts191
-rw-r--r--test/emcc_O2_hello_world.fromasm4
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise2
-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.fromasm4
-rw-r--r--test/emcc_hello_world.fromasm.imprecise2
-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/i64-setTempRet0.fromasm2
-rw-r--r--test/memorygrowth.fromasm4
-rw-r--r--test/memorygrowth.fromasm.imprecise2
-rw-r--r--test/memorygrowth.fromasm.imprecise.no-opts2
-rw-r--r--test/memorygrowth.fromasm.no-opts2
-rw-r--r--test/min.fromasm2
-rw-r--r--test/passes/dce.txt2
-rw-r--r--test/passes/print-call-graph.txt4
-rw-r--r--test/passes/remove-unused-module-elements.txt2
-rw-r--r--test/passes/vacuum.txt2
-rw-r--r--test/unit.fromasm4
-rw-r--r--test/unit.fromasm.imprecise2
-rw-r--r--test/unit.fromasm.imprecise.no-opts2
-rw-r--r--test/unit.fromasm.no-opts2
-rw-r--r--test/wasm-only.fromasm2
-rw-r--r--test/wasm-only.fromasm.imprecise2
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts2
-rw-r--r--test/wasm-only.fromasm.no-opts2
33 files changed, 731 insertions, 49 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 6ed13b79a..fe9bd0f3f 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -649,19 +649,24 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
type = WasmType::f64;
}
if (type != WasmType::none) {
- // we need imported globals to be mutable, but wasm doesn't support that yet, so we must
- // import an immutable and create a mutable global initialized to its value
- import->name = Name(std::string(import->name.str) + "$asm2wasm$import");
+ // this is a global
import->kind = ExternalKind::Global;
import->globalType = type;
mappedGlobals.emplace(name, type);
- {
- auto global = new Global();
- global->name = name;
- global->type = type;
- global->init = builder.makeGetGlobal(import->name, type);
- global->mutable_ = true;
- wasm.addGlobal(global);
+ // tableBase and memoryBase are used as segment/element offsets, and must be constant;
+ // otherwise, an asm.js import of a constant is mutable, e.g. STACKTOP
+ if (name != "tableBase" && name != "memoryBase") {
+ // we need imported globals to be mutable, but wasm doesn't support that yet, so we must
+ // import an immutable and create a mutable global initialized to its value
+ import->name = Name(std::string(import->name.str) + "$asm2wasm$import");
+ {
+ auto global = new Global();
+ global->name = name;
+ global->type = type;
+ global->init = builder.makeGetGlobal(import->name, type);
+ global->mutable_ = true;
+ wasm.addGlobal(global);
+ }
}
} else {
import->kind = ExternalKind::Function;
@@ -1059,8 +1064,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
wasm.table.exists = true;
wasm.table.imported = true;
- // Import memory offset
- {
+ // Import memory offset, if not already there
+ if (!wasm.checkImport("memoryBase") && !wasm.checkGlobal("memoryBase")) {
auto* import = new Import;
import->name = Name("memoryBase");
import->module = Name("env");
@@ -1070,8 +1075,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
wasm.addImport(import);
}
- // Import table offset
- {
+ // Import table offset, if not already there
+ if (!wasm.checkImport("tableBase") && !wasm.checkGlobal("tableBase")) {
auto* import = new Import;
import->name = Name("tableBase");
import->module = Name("env");
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index c6fca0256..3c847809f 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -698,15 +698,15 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
visitImport(child.get());
o << maybeNewLine;
}
- if (curr->table.exists) {
- visitTable(&curr->table); // Prints its own newlines
- }
- visitMemory(&curr->memory);
for (auto& child : curr->globals) {
doIndent(o, indent);
visitGlobal(child.get());
o << maybeNewLine;
}
+ if (curr->table.exists) {
+ visitTable(&curr->table); // Prints its own newlines
+ }
+ visitMemory(&curr->memory);
for (auto& child : curr->exports) {
doIndent(o, indent);
visitExport(child.get());
diff --git a/test/dynamicLibrary.asm.js b/test/dynamicLibrary.asm.js
new file mode 100644
index 000000000..142fd7c98
--- /dev/null
+++ b/test/dynamicLibrary.asm.js
@@ -0,0 +1,136 @@
+Module["asm"] = (function(global, env, buffer) {
+ 'almost asm';
+
+
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+
+ var DYNAMICTOP_PTR=env.DYNAMICTOP_PTR|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+ var memoryBase=env.memoryBase|0;
+ var tableBase=env.tableBase|0;
+
+ var STACKTOP = 0, STACK_MAX = 0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = global.NaN, inf = global.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+ var tempRet0 = 0;
+
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var Math_min=global.Math.min;
+ var Math_max=global.Math.max;
+ var Math_clz32=global.Math.clz32;
+ var Math_fround=global.Math.fround;
+ var abort=env.abort;
+ var assert=env.assert;
+ var enlargeMemory=env.enlargeMemory;
+ var getTotalMemory=env.getTotalMemory;
+ var abortOnCannotGrowMemory=env.abortOnCannotGrowMemory;
+ var abortStackOverflow=env.abortStackOverflow;
+ var setTempRet0=env.setTempRet0;
+ var getTempRet0=env.getTempRet0;
+ var _puts=env._puts;
+ var tempFloat = Math_fround(0);
+ const f0 = Math_fround(0);
+
+// EMSCRIPTEN_START_FUNCS
+
+function stackAlloc(size) {
+ size = size|0;
+ var ret = 0;
+ ret = STACKTOP;
+ STACKTOP = (STACKTOP + size)|0;
+ STACKTOP = (STACKTOP + 15)&-16;
+ if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(size|0);
+
+ return ret|0;
+}
+function stackSave() {
+ return STACKTOP|0;
+}
+function stackRestore(top) {
+ top = top|0;
+ STACKTOP = top;
+}
+function establishStackSpace(stackBase, stackMax) {
+ stackBase = stackBase|0;
+ stackMax = stackMax|0;
+ STACKTOP = stackBase;
+ STACK_MAX = stackMax;
+}
+
+function setThrew(threw, value) {
+ threw = threw|0;
+ value = value|0;
+ if ((__THREW__|0) == 0) {
+ __THREW__ = threw;
+ threwValue = value;
+ }
+}
+
+function ___cxx_global_var_init() {
+ var label = 0, sp = 0;
+ sp = STACKTOP;
+ __ZN3FooC2Ev((memoryBase + (5242912) | 0));
+ return;
+}
+function __ZN3FooC2Ev($0) {
+ $0 = $0|0;
+ var $1 = 0, label = 0, sp = 0;
+ sp = STACKTOP;
+ STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(16|0);
+ $1 = $0;
+ (_puts(((memoryBase + (0) | 0)|0))|0);
+ STACKTOP = sp;return;
+}
+function __GLOBAL__sub_I_liblib_cpp() {
+ var label = 0, sp = 0;
+ sp = STACKTOP;
+ ___cxx_global_var_init();
+ return;
+}
+function runPostSets() {
+ var temp = 0;
+}
+function __post_instantiate() {
+ STACKTOP = (memoryBase + (32) | 0);
+ STACK_MAX = STACKTOP + 5242880 | 0;
+ runPostSets();
+ __GLOBAL__sub_I_liblib_cpp();
+}
+
+
+
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { __ZN3FooC2Ev: __ZN3FooC2Ev, __post_instantiate: __post_instantiate, runPostSets: runPostSets, _global: 5242912 };
+})
+; \ No newline at end of file
diff --git a/test/dynamicLibrary.fromasm b/test/dynamicLibrary.fromasm
new file mode 100644
index 000000000..df7825187
--- /dev/null
+++ b/test/dynamicLibrary.fromasm
@@ -0,0 +1,80 @@
+(module
+ (type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "abortStackOverflow" (func $abortStackOverflow (param i32)))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "tableBase" (global $tableBase i32))
+ (global $STACKTOP (mut i32) (i32.const 0))
+ (global $STACK_MAX (mut i32) (i32.const 0))
+ (global $_global i32 (i32.const 5242912))
+ (data (get_global $memoryBase) "dynamicLibrary.asm.js")
+ (export "__ZN3FooC2Ev" (func $__ZN3FooC2Ev))
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "runPostSets" (func $runPostSets))
+ (export "_global" (global $_global))
+ (func $___cxx_global_var_init
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
+ )
+ (func $__ZN3FooC2Ev (param $0 i32)
+ (local $1 i32)
+ (set_local $1
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (i32.const 16)
+ )
+ )
+ (drop
+ (call $_puts
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 0)
+ )
+ )
+ )
+ (set_global $STACKTOP
+ (get_local $1)
+ )
+ )
+ (func $__GLOBAL__sub_I_liblib_cpp
+ (call $___cxx_global_var_init)
+ )
+ (func $runPostSets
+ (nop)
+ )
+ (func $__post_instantiate
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 32)
+ )
+ )
+ (set_global $STACK_MAX
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 5242880)
+ )
+ )
+ (call $runPostSets)
+ (call $__GLOBAL__sub_I_liblib_cpp)
+ )
+)
diff --git a/test/dynamicLibrary.fromasm.imprecise b/test/dynamicLibrary.fromasm.imprecise
new file mode 100644
index 000000000..357d324cd
--- /dev/null
+++ b/test/dynamicLibrary.fromasm.imprecise
@@ -0,0 +1,79 @@
+(module
+ (type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "abortStackOverflow" (func $abortStackOverflow (param i32)))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "tableBase" (global $tableBase i32))
+ (global $STACKTOP (mut i32) (i32.const 0))
+ (global $STACK_MAX (mut i32) (i32.const 0))
+ (global $_global i32 (i32.const 5242912))
+ (export "__ZN3FooC2Ev" (func $__ZN3FooC2Ev))
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "runPostSets" (func $runPostSets))
+ (export "_global" (global $_global))
+ (func $___cxx_global_var_init
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
+ )
+ (func $__ZN3FooC2Ev (param $0 i32)
+ (local $1 i32)
+ (set_local $1
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (i32.const 16)
+ )
+ )
+ (drop
+ (call $_puts
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 0)
+ )
+ )
+ )
+ (set_global $STACKTOP
+ (get_local $1)
+ )
+ )
+ (func $__GLOBAL__sub_I_liblib_cpp
+ (call $___cxx_global_var_init)
+ )
+ (func $runPostSets
+ (nop)
+ )
+ (func $__post_instantiate
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 32)
+ )
+ )
+ (set_global $STACK_MAX
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 5242880)
+ )
+ )
+ (call $runPostSets)
+ (call $__GLOBAL__sub_I_liblib_cpp)
+ )
+)
diff --git a/test/dynamicLibrary.fromasm.imprecise.no-opts b/test/dynamicLibrary.fromasm.imprecise.no-opts
new file mode 100644
index 000000000..c29478fdb
--- /dev/null
+++ b/test/dynamicLibrary.fromasm.imprecise.no-opts
@@ -0,0 +1,191 @@
+(module
+ (type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (import "env" "DYNAMICTOP_PTR" (global $DYNAMICTOP_PTR$asm2wasm$import i32))
+ (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
+ (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "global" "NaN" (global $nan$asm2wasm$import f64))
+ (import "global" "Infinity" (global $inf$asm2wasm$import f64))
+ (import "env" "abortStackOverflow" (func $abortStackOverflow (param i32)))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (global $DYNAMICTOP_PTR (mut i32) (get_global $DYNAMICTOP_PTR$asm2wasm$import))
+ (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
+ (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
+ (global $STACKTOP (mut i32) (i32.const 0))
+ (global $STACK_MAX (mut i32) (i32.const 0))
+ (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 $tempFloat (mut f32) (f32.const 0))
+ (global $f0 (mut f32) (f32.const 0))
+ (global $_global i32 (i32.const 5242912))
+ (export "__ZN3FooC2Ev" (func $__ZN3FooC2Ev))
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "runPostSets" (func $runPostSets))
+ (export "_global" (global $_global))
+ (func $stackAlloc (param $size i32) (result i32)
+ (local $ret i32)
+ (set_local $ret
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (get_local $size)
+ )
+ )
+ (set_global $STACKTOP
+ (i32.and
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 15)
+ )
+ (i32.const -16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (get_local $size)
+ )
+ )
+ (return
+ (get_local $ret)
+ )
+ )
+ (func $stackSave (result i32)
+ (return
+ (get_global $STACKTOP)
+ )
+ )
+ (func $stackRestore (param $top i32)
+ (set_global $STACKTOP
+ (get_local $top)
+ )
+ )
+ (func $establishStackSpace (param $stackBase i32) (param $stackMax i32)
+ (set_global $STACKTOP
+ (get_local $stackBase)
+ )
+ (set_global $STACK_MAX
+ (get_local $stackMax)
+ )
+ )
+ (func $setThrew (param $threw i32) (param $value i32)
+ (if
+ (i32.eq
+ (get_global $__THREW__)
+ (i32.const 0)
+ )
+ (block
+ (set_global $__THREW__
+ (get_local $threw)
+ )
+ (set_global $threwValue
+ (get_local $value)
+ )
+ )
+ )
+ )
+ (func $___cxx_global_var_init
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
+ (return)
+ )
+ (func $__ZN3FooC2Ev (param $$0 i32)
+ (local $$1 i32)
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (i32.const 16)
+ )
+ )
+ (set_local $$1
+ (get_local $$0)
+ )
+ (drop
+ (call $_puts
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 0)
+ )
+ )
+ )
+ (set_global $STACKTOP
+ (get_local $sp)
+ )
+ (return)
+ )
+ (func $__GLOBAL__sub_I_liblib_cpp
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (call $___cxx_global_var_init)
+ (return)
+ )
+ (func $runPostSets
+ (local $temp i32)
+ (nop)
+ )
+ (func $__post_instantiate
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 32)
+ )
+ )
+ (set_global $STACK_MAX
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 5242880)
+ )
+ )
+ (call $runPostSets)
+ (call $__GLOBAL__sub_I_liblib_cpp)
+ )
+)
diff --git a/test/dynamicLibrary.fromasm.no-opts b/test/dynamicLibrary.fromasm.no-opts
new file mode 100644
index 000000000..c29478fdb
--- /dev/null
+++ b/test/dynamicLibrary.fromasm.no-opts
@@ -0,0 +1,191 @@
+(module
+ (type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$ii (func (param i32) (result i32)))
+ (import "env" "DYNAMICTOP_PTR" (global $DYNAMICTOP_PTR$asm2wasm$import i32))
+ (import "env" "tempDoublePtr" (global $tempDoublePtr$asm2wasm$import i32))
+ (import "env" "ABORT" (global $ABORT$asm2wasm$import i32))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "global" "NaN" (global $nan$asm2wasm$import f64))
+ (import "global" "Infinity" (global $inf$asm2wasm$import f64))
+ (import "env" "abortStackOverflow" (func $abortStackOverflow (param i32)))
+ (import "env" "_puts" (func $_puts (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (global $DYNAMICTOP_PTR (mut i32) (get_global $DYNAMICTOP_PTR$asm2wasm$import))
+ (global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
+ (global $ABORT (mut i32) (get_global $ABORT$asm2wasm$import))
+ (global $STACKTOP (mut i32) (i32.const 0))
+ (global $STACK_MAX (mut i32) (i32.const 0))
+ (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 $tempFloat (mut f32) (f32.const 0))
+ (global $f0 (mut f32) (f32.const 0))
+ (global $_global i32 (i32.const 5242912))
+ (export "__ZN3FooC2Ev" (func $__ZN3FooC2Ev))
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "runPostSets" (func $runPostSets))
+ (export "_global" (global $_global))
+ (func $stackAlloc (param $size i32) (result i32)
+ (local $ret i32)
+ (set_local $ret
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (get_local $size)
+ )
+ )
+ (set_global $STACKTOP
+ (i32.and
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 15)
+ )
+ (i32.const -16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (get_local $size)
+ )
+ )
+ (return
+ (get_local $ret)
+ )
+ )
+ (func $stackSave (result i32)
+ (return
+ (get_global $STACKTOP)
+ )
+ )
+ (func $stackRestore (param $top i32)
+ (set_global $STACKTOP
+ (get_local $top)
+ )
+ )
+ (func $establishStackSpace (param $stackBase i32) (param $stackMax i32)
+ (set_global $STACKTOP
+ (get_local $stackBase)
+ )
+ (set_global $STACK_MAX
+ (get_local $stackMax)
+ )
+ )
+ (func $setThrew (param $threw i32) (param $value i32)
+ (if
+ (i32.eq
+ (get_global $__THREW__)
+ (i32.const 0)
+ )
+ (block
+ (set_global $__THREW__
+ (get_local $threw)
+ )
+ (set_global $threwValue
+ (get_local $value)
+ )
+ )
+ )
+ )
+ (func $___cxx_global_var_init
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
+ (return)
+ )
+ (func $__ZN3FooC2Ev (param $$0 i32)
+ (local $$1 i32)
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 16)
+ )
+ )
+ (if
+ (i32.ge_s
+ (get_global $STACKTOP)
+ (get_global $STACK_MAX)
+ )
+ (call $abortStackOverflow
+ (i32.const 16)
+ )
+ )
+ (set_local $$1
+ (get_local $$0)
+ )
+ (drop
+ (call $_puts
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 0)
+ )
+ )
+ )
+ (set_global $STACKTOP
+ (get_local $sp)
+ )
+ (return)
+ )
+ (func $__GLOBAL__sub_I_liblib_cpp
+ (local $label i32)
+ (local $sp i32)
+ (set_local $sp
+ (get_global $STACKTOP)
+ )
+ (call $___cxx_global_var_init)
+ (return)
+ )
+ (func $runPostSets
+ (local $temp i32)
+ (nop)
+ )
+ (func $__post_instantiate
+ (set_global $STACKTOP
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 32)
+ )
+ )
+ (set_global $STACK_MAX
+ (i32.add
+ (get_global $STACKTOP)
+ (i32.const 5242880)
+ )
+ )
+ (call $runPostSets)
+ (call $__GLOBAL__sub_I_liblib_cpp)
+ )
+)
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index 4d3147862..5ac3b57bb 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -28,13 +28,13 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
+ (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")
(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 8ab35a567..901414958 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -27,12 +27,12 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
+ (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)
(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 7bc59938d..f973ac7d1 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
@@ -31,7 +31,6 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -62,6 +61,7 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
+ (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)
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts
index 050d0b3f9..80801ea2d 100644
--- a/test/emcc_O2_hello_world.fromasm.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.no-opts
@@ -32,7 +32,6 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -63,6 +62,7 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
+ (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)
(export "_free" (func $_free))
(export "_main" (func $_main))
(export "_memset" (func $_memset))
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 85d980069..1971f0c3b 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -37,14 +37,14 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
+ (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")
(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 65bd295bc..4b429163d 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -31,13 +31,13 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $__THREW__ (mut i32) (i32.const 0))
(global $threwValue (mut i32) (i32.const 0))
(global $tempRet0 (mut i32) (i32.const 0))
+ (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)
(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 a805b78ae..9488b62c2 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -35,7 +35,6 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -67,6 +66,7 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
+ (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)
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index 22c1ee5c7..e12ecdb96 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -41,7 +41,6 @@
(import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -73,6 +72,7 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
+ (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)
(export "_i64Subtract" (func $_i64Subtract))
(export "_free" (func $_free))
(export "_main" (func $_main))
diff --git a/test/i64-setTempRet0.fromasm b/test/i64-setTempRet0.fromasm
index c0fe551c8..48337119c 100644
--- a/test/i64-setTempRet0.fromasm
+++ b/test/i64-setTempRet0.fromasm
@@ -7,8 +7,8 @@
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (data (get_global $memoryBase) "i64-setTempRet0.asm.js")
(global $tempRet0 (mut i32) (i32.const 0))
+ (data (get_global $memoryBase) "i64-setTempRet0.asm.js")
(export "illegalResult" (func $legalstub$illegalResult))
(export "imports" (func $imports))
(func $illegalResult (result i64)
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index cfe303d34..d6800684d 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -24,13 +24,13 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
(global $K (mut i32) (i32.const 0))
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (data (get_global $memoryBase) "memorygrowth.asm.js")
(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 c1f308b20..d0f3405d5 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -23,12 +23,12 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $v (mut i32) (i32.const 0))
(global $w (mut i32) (i32.const 0))
(global $K (mut i32) (i32.const 0))
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(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 26108171f..2d65caa7d 100644
--- a/test/memorygrowth.fromasm.imprecise.no-opts
+++ b/test/memorygrowth.fromasm.imprecise.no-opts
@@ -27,7 +27,6 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -58,6 +57,7 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts
index ef9478371..a27f419ae 100644
--- a/test/memorygrowth.fromasm.no-opts
+++ b/test/memorygrowth.fromasm.no-opts
@@ -28,7 +28,6 @@
(import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -59,6 +58,7 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
+ (elem (get_global $tableBase) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(export "_free" (func $fb))
(export "_main" (func $Na))
(export "_pthread_self" (func $ib))
diff --git a/test/min.fromasm b/test/min.fromasm
index 4287f6259..8f4ccbf4b 100644
--- a/test/min.fromasm
+++ b/test/min.fromasm
@@ -3,8 +3,8 @@
(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 $M (mut i32) (i32.const 0))
+ (data (get_global $memoryBase) "min.asm.js")
(export "floats" (func $legalstub$floats))
(export "getTempRet0" (func $ub))
(export "neg" (func $legalstub$neg))
diff --git a/test/passes/dce.txt b/test/passes/dce.txt
index feb0715b7..71b46bd94 100644
--- a/test/passes/dce.txt
+++ b/test/passes/dce.txt
@@ -3,10 +3,10 @@
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32) (result i32)))
+ (global $x (mut i32) (i32.const 0))
(table 1 1 anyfunc)
(elem (i32.const 0) $call-me)
(memory $0 10)
- (global $x (mut i32) (i32.const 0))
(func $call-me (type $ii) (param $0 i32) (param $1 i32)
(nop)
)
diff --git a/test/passes/print-call-graph.txt b/test/passes/print-call-graph.txt
index b12b95828..6e4af209c 100644
--- a/test/passes/print-call-graph.txt
+++ b/test/passes/print-call-graph.txt
@@ -141,8 +141,6 @@ digraph call {
(import "env" "table" (table 9 9 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (elem (i32.const 0) $b0 $___stdio_close $b1 $___stdout_write $___stdio_seek $___stdio_write $b2 $_cleanup_387 $b3)
- (data (get_global $memoryBase) "\05\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\b0\04\00\00\00\04\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\n\ff\ff\ff\ff\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\04")
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
(global $DYNAMICTOP_PTR (mut i32) (get_global $DYNAMICTOP_PTR$asm2wasm$import))
@@ -166,6 +164,8 @@ digraph call {
(global $tempRet0 (mut i32) (i32.const 0))
(global $tempFloat (mut f32) (f32.const 0))
(global $f0 (mut f32) (f32.const 0))
+ (elem (i32.const 0) $b0 $___stdio_close $b1 $___stdout_write $___stdio_seek $___stdio_write $b2 $_cleanup_387 $b3)
+ (data (get_global $memoryBase) "\05\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\b0\04\00\00\00\04\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\n\ff\ff\ff\ff\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\04")
(export "_fflush" (func $_fflush))
(export "_main" (func $_main))
(export "_pthread_self" (func $_pthread_self))
diff --git a/test/passes/remove-unused-module-elements.txt b/test/passes/remove-unused-module-elements.txt
index 8b8fd3601..4627cce5f 100644
--- a/test/passes/remove-unused-module-elements.txt
+++ b/test/passes/remove-unused-module-elements.txt
@@ -54,10 +54,10 @@
(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))
+ (memory $0 0)
(export "one" (func $one))
(export "three" (func $three))
(export "exp_glob" (global $exp_glob))
diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt
index e89321f74..bc3cbfda3 100644
--- a/test/passes/vacuum.txt
+++ b/test/passes/vacuum.txt
@@ -6,8 +6,8 @@
(type $4 (func (param i32 f64 i32 i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "int" (func $int (result i32)))
- (memory $0 256 256)
(global $Int i32 (i32.const 0))
+ (memory $0 256 256)
(func $b (type $0)
(nop)
)
diff --git a/test/unit.fromasm b/test/unit.fromasm
index e18bfd16a..4f7b2c6a9 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -22,12 +22,12 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $Int (mut i32) (i32.const 0))
(global $Double (mut f64) (f64.const 0))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $exportedNumber i32 (i32.const 42))
+ (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")
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index 2ec8b82ff..caa8e4f33 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -18,11 +18,11 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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 $n (mut i32) (get_global $n$asm2wasm$import))
(global $exportedNumber i32 (i32.const 42))
+ (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)
(export "big_negative" (func $big_negative))
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index fe2e7edbd..0dbdd7b50 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -22,7 +22,6 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -31,6 +30,7 @@
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $exportedNumber i32 (i32.const 42))
+ (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)
(export "big_negative" (func $big_negative))
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index 960ee6c5f..af5daebe0 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -26,7 +26,6 @@
(import "env" "table" (table 24 24 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (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))
@@ -35,6 +34,7 @@
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
(global $exportedNumber i32 (i32.const 42))
+ (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)
(export "big_negative" (func $big_negative))
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index ae8bddbbc..86c9cfad9 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -18,9 +18,9 @@
(import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
+ (global $tempRet0 (mut i32) (i32.const 0))
(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))
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index a6c5b3f50..227ab430d 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -18,8 +18,8 @@
(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))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$result))
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index d718ccc24..2f891e715 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -18,8 +18,8 @@
(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))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index e208f870f..e8e2785d5 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -18,8 +18,8 @@
(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))
+ (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64)
(export "test64" (func $test64))
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))