summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xauto_update_tests.py26
-rwxr-xr-xcheck.py8
-rw-r--r--scripts/test/shared.py1
-rw-r--r--src/asm2wasm.h8
-rw-r--r--src/tools/asm2wasm.cpp7
-rw-r--r--src/wasm-js.cpp2
-rw-r--r--test/noffi_f32.asm.js21
-rw-r--r--test/noffi_f32.fromasm25
-rw-r--r--test/noffi_f32.fromasm.clamp25
-rw-r--r--test/noffi_f32.fromasm.clamp.no-opts28
-rw-r--r--test/noffi_f32.fromasm.imprecise24
-rw-r--r--test/noffi_f32.fromasm.imprecise.no-opts28
-rw-r--r--test/noffi_f32.fromasm.no-opts28
-rw-r--r--test/noffi_i64.asm.js21
-rw-r--r--test/noffi_i64.fromasm25
-rw-r--r--test/noffi_i64.fromasm.clamp25
-rw-r--r--test/noffi_i64.fromasm.clamp.no-opts32
-rw-r--r--test/noffi_i64.fromasm.imprecise24
-rw-r--r--test/noffi_i64.fromasm.imprecise.no-opts32
-rw-r--r--test/noffi_i64.fromasm.no-opts32
20 files changed, 404 insertions, 18 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index 9eb0fb50c..0c07001e2 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -3,6 +3,8 @@
import os, sys, subprocess, difflib
from scripts.test.support import run_command, split_wast
+from scripts.test.shared import (
+ ASM2WASM, S2WASM, WASM_SHELL, WASM_OPT, WASM_AS, WASM_DIS)
print '[ processing and updating testcases... ]\n'
@@ -10,7 +12,7 @@ for asm in sorted(os.listdir('test')):
if asm.endswith('.asm.js'):
for precise in [0, 1, 2]:
for opts in [1, 0]:
- cmd = [os.path.join('bin', 'asm2wasm'), os.path.join('test', asm)]
+ cmd = ASM2WASM + [os.path.join('test', asm)]
wasm = asm.replace('.asm.js', '.fromasm')
if not precise:
cmd += ['--emit-potential-traps', '--ignore-implicit-traps']
@@ -26,13 +28,15 @@ for asm in sorted(os.listdir('test')):
cmd += ['-O']
if 'debugInfo' in asm:
cmd += ['-g']
+ if 'noffi' in asm:
+ cmd += ['--no-legalize-javascript-ffi']
if precise and opts:
# test mem init importing
open('a.mem', 'wb').write(asm)
cmd += ['--mem-init=a.mem']
if asm[0] == 'e':
cmd += ['--mem-base=1024']
- if 'i64' in asm or 'wasm-only' in asm:
+ if 'i64' in asm or 'wasm-only' in asm or 'noffi' in asm:
cmd += ['--wasm-only']
print ' '.join(cmd)
actual = run_command(cmd)
@@ -45,7 +49,7 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']:
wasm = s.replace('.s', '.wast')
full = os.path.join('test', dot_s_dir, s)
stack_alloc = ['--allocate-stack=1024'] if dot_s_dir == 'llvm_autogenerated' else []
- cmd = [os.path.join('bin', 's2wasm'), full, '--emscripten-glue'] + stack_alloc
+ cmd = S2WASM + [full, '--emscripten-glue'] + stack_alloc
if s.startswith('start_'):
cmd.append('--start')
actual = run_command(cmd, stderr=subprocess.PIPE, expected_err='')
@@ -70,11 +74,11 @@ for t in sorted(os.listdir(os.path.join('test', 'print'))):
if t.endswith('.wast'):
print '..', t
wasm = os.path.basename(t).replace('.wast', '')
- cmd = [os.path.join('bin', 'wasm-shell'), os.path.join('test', 'print', t), '--print']
+ cmd = WASM_SHELL + [os.path.join('test', 'print', t), '--print']
print ' ', ' '.join(cmd)
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
with open(os.path.join('test', 'print', wasm + '.txt'), 'w') as o: o.write(actual)
- cmd = [os.path.join('bin', 'wasm-shell'), os.path.join('test', 'print', t), '--print-minified']
+ cmd = WASM_SHELL + [os.path.join('test', 'print', t), '--print-minified']
print ' ', ' '.join(cmd)
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w') as o: o.write(actual)
@@ -89,14 +93,14 @@ for t in sorted(os.listdir(os.path.join('test', 'passes'))):
for module, asserts in split_wast(t):
assert len(asserts) == 0
with open('split.wast', 'w') as o: o.write(module)
- cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print']
+ cmd = WASM_OPT + opts + ['split.wast', '--print']
actual += run_command(cmd)
with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual)
print '\n[ checking wasm-opt -o notation... ]\n'
wast = os.path.join('test', 'hello_world.wast')
-cmd = [os.path.join('bin', 'wasm-opt'), wast, '-o', 'a.wast', '-S']
+cmd = WASM_OPT + [wast, '-o', 'a.wast', '-S']
run_command(cmd)
open(wast, 'w').write(open('a.wast').read())
@@ -105,14 +109,14 @@ print '\n[ checking binary format testcases... ]\n'
for wast in sorted(os.listdir('test')):
if wast.endswith('.wast') and not wast in []: # blacklist some known failures
for debug_info in [0, 1]:
- cmd = [os.path.join('bin', 'wasm-as'), os.path.join('test', wast), '-o', 'a.wasm']
+ cmd = WASM_AS + [os.path.join('test', wast), '-o', 'a.wasm']
if debug_info: cmd += ['-g']
print ' '.join(cmd)
if os.path.exists('a.wasm'): os.unlink('a.wasm')
subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert os.path.exists('a.wasm')
- cmd = [os.path.join('bin', 'wasm-dis'), 'a.wasm', '-o', 'a.wast']
+ cmd = WASM_DIS + ['a.wasm', '-o', 'a.wast']
print ' '.join(cmd)
if os.path.exists('a.wast'): os.unlink('a.wast')
subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -177,7 +181,7 @@ for t in os.listdir('test'):
print '..', t
t = os.path.join('test', t)
f = t + '.from-wast'
- cmd = [os.path.join('bin', 'wasm-opt'), t, '--print']
+ cmd = WASM_OPT + [t, '--print']
actual = run_command(cmd)
actual = actual.replace('printing before:\n', '')
open(f, 'w').write(actual)
@@ -188,7 +192,7 @@ for t in os.listdir('test'):
if t.endswith('.wasm') and not t.startswith('spec'):
print '..', t
t = os.path.join('test', t)
- cmd = [os.path.join('bin', 'wasm-dis'), t]
+ cmd = WASM_DIS + [t]
actual = run_command(cmd)
open(t + '.fromBinary', 'w').write(actual)
diff --git a/check.py b/check.py
index 8f5d473ca..3989c1a2c 100755
--- a/check.py
+++ b/check.py
@@ -23,7 +23,7 @@ import sys
from scripts.test.support import run_command, split_wast
from scripts.test.shared import (
ASM2WASM, BIN_DIR, EMCC, MOZJS, NATIVECC, NATIVEXX, NODEJS, S2WASM_EXE,
- WASM_AS, WASM_OPT, WASM_SHELL, WASM_SHELL_EXE, WASM_DIS,
+ WASM_AS, WASM_OPT, WASM_SHELL, WASM_MERGE, WASM_SHELL_EXE, WASM_DIS,
binary_format_check, delete_from_orbit, fail, fail_with_error,
fail_if_not_identical, fail_if_not_contained, has_vanilla_emcc,
has_vanilla_llvm, minify_check, num_failures, options, tests,
@@ -112,13 +112,15 @@ for asm in tests:
cmd += ['-O']
if 'debugInfo' in asm:
cmd += ['-g']
+ if 'noffi' in asm:
+ cmd += ['--no-legalize-javascript-ffi']
if precise and opts:
# test mem init importing
open('a.mem', 'wb').write(asm)
cmd += ['--mem-init=a.mem']
if asm[0] == 'e':
cmd += ['--mem-base=1024']
- if 'i64' in asm or 'wasm-only' in asm:
+ if 'i64' in asm or 'wasm-only' in asm or 'noffi' in asm:
cmd += ['--wasm-only']
wasm = os.path.join(options.binaryen_test, wasm)
print '..', asm, wasm
@@ -224,7 +226,7 @@ for t in os.listdir(os.path.join('test', 'merge')):
u = t + '.toMerge'
for finalize in [0, 1]:
for opt in [0, 1]:
- cmd = [os.path.join('bin', 'wasm-merge'), t, u, '-o', 'a.wast', '-S', '--verbose']
+ cmd = WASM_MERGE + [t, u, '-o', 'a.wast', '-S', '--verbose']
if finalize: cmd += ['--finalize-memory-base=1024', '--finalize-table-base=8']
if opt: cmd += ['-O']
stdout = run_command(cmd)
diff --git a/scripts/test/shared.py b/scripts/test/shared.py
index d899cc1de..f6f06722c 100644
--- a/scripts/test/shared.py
+++ b/scripts/test/shared.py
@@ -156,6 +156,7 @@ WASM_AS = [os.path.join(options.binaryen_bin, 'wasm-as')]
WASM_DIS = [os.path.join(options.binaryen_bin, 'wasm-dis')]
ASM2WASM = [os.path.join(options.binaryen_bin, 'asm2wasm')]
WASM_SHELL = [os.path.join(options.binaryen_bin, 'wasm-shell')]
+WASM_MERGE = [os.path.join(options.binaryen_bin, 'wasm-merge')]
S2WASM = [os.path.join(options.binaryen_bin, 's2wasm')]
S2WASM_EXE = S2WASM[0]
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index f78b9df55..00481c9bd 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -380,6 +380,7 @@ public:
TrapMode trapMode;
PassOptions passOptions;
+ bool legalizeJavaScriptFFI;
bool runOptimizationPasses;
bool wasmOnly;
@@ -483,7 +484,7 @@ private:
}
public:
- Asm2WasmBuilder(Module& wasm, Asm2WasmPreProcessor& preprocessor, bool debug, TrapMode trapMode, PassOptions passOptions, bool runOptimizationPasses, bool wasmOnly)
+ Asm2WasmBuilder(Module& wasm, Asm2WasmPreProcessor& preprocessor, bool debug, TrapMode trapMode, PassOptions passOptions, bool legalizeJavaScriptFFI, bool runOptimizationPasses, bool wasmOnly)
: wasm(wasm),
allocator(wasm.allocator),
builder(wasm),
@@ -491,6 +492,7 @@ public:
debug(debug),
trapMode(trapMode),
passOptions(passOptions),
+ legalizeJavaScriptFFI(legalizeJavaScriptFFI),
runOptimizationPasses(runOptimizationPasses),
wasmOnly(wasmOnly) {}
@@ -1395,7 +1397,9 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
passRunner.add<FinalizeCalls>(this);
passRunner.add<ReFinalize>(); // FinalizeCalls changes call types, need to percolate
passRunner.add<AutoDrop>(); // FinalizeCalls may cause us to require additional drops
- passRunner.add("legalize-js-interface");
+ if (legalizeJavaScriptFFI) {
+ passRunner.add("legalize-js-interface");
+ }
if (runOptimizationPasses) {
// autodrop can add some garbage
passRunner.add("vacuum");
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp
index 4ad5a5814..dd2b6a791 100644
--- a/src/tools/asm2wasm.cpp
+++ b/src/tools/asm2wasm.cpp
@@ -32,6 +32,7 @@ using namespace wasm;
int main(int argc, const char *argv[]) {
PassOptions passOptions;
+ bool legalizeJavaScriptFFI = true;
bool runOptimizationPasses = false;
Asm2WasmBuilder::TrapMode trapMode = Asm2WasmBuilder::TrapMode::JS;
bool wasmOnly = false;
@@ -95,6 +96,10 @@ int main(int argc, const char *argv[]) {
[&wasmOnly](Options *o, const std::string &) {
wasmOnly = true;
})
+ .add("--no-legalize-javascript-ffi", "-nj", "Do not legalize (i64->i32, f32->f64) the imports and exports for interfacing with JS", Options::Arguments::Zero,
+ [&legalizeJavaScriptFFI](Options *o, const std::string &) {
+ legalizeJavaScriptFFI = false;
+ })
.add("--debuginfo", "-g", "Emit names section and debug info (for debug info you must emit text, -S, for this to work)",
Options::Arguments::Zero,
[&](Options *o, const std::string &arguments) { passOptions.debugInfo = true; })
@@ -139,7 +144,7 @@ int main(int argc, const char *argv[]) {
if (options.debug) std::cerr << "wasming..." << std::endl;
Module wasm;
wasm.memory.initial = wasm.memory.max = totalMemory / Memory::kPageSize;
- Asm2WasmBuilder asm2wasm(wasm, pre, options.debug, trapMode, passOptions, runOptimizationPasses, wasmOnly);
+ Asm2WasmBuilder asm2wasm(wasm, pre, options.debug, trapMode, passOptions, legalizeJavaScriptFFI, runOptimizationPasses, wasmOnly);
asm2wasm.processAsm(asmjs);
// import mem init file, if provided
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 94404aeb9..dba194ee2 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -80,7 +80,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) {
module->memory.max = pre.memoryGrowth ? Address(Memory::kMaxSize) : module->memory.initial;
if (wasmJSDebug) std::cerr << "wasming...\n";
- asm2wasm = new Asm2WasmBuilder(*module, pre, debug, Asm2WasmBuilder::TrapMode::JS, PassOptions(), false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */);
+ asm2wasm = new Asm2WasmBuilder(*module, pre, debug, Asm2WasmBuilder::TrapMode::JS, PassOptions(), true /* runJSFFIPass */, false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */);
asm2wasm->processAsm(asmjs);
}
diff --git a/test/noffi_f32.asm.js b/test/noffi_f32.asm.js
new file mode 100644
index 000000000..cc7a47972
--- /dev/null
+++ b/test/noffi_f32.asm.js
@@ -0,0 +1,21 @@
+function(global, env, buffer) {
+ "use asm";
+ var Math_fround=global.Math.fround;
+ var importf=env._importf;
+
+ function exportf(a){
+ a=Math_fround(a);
+ return Math_fround(a+Math_fround(1.0))
+ }
+ function main(){
+ Math_fround(importf(Math_fround(3.4000000953674316)));
+ return 0
+ }
+
+ return{
+ main:main,
+ exportf:exportf}
+}
+
+;
+
diff --git a/test/noffi_f32.fromasm b/test/noffi_f32.fromasm
new file mode 100644
index 000000000..4236c215f
--- /dev/null
+++ b/test/noffi_f32.fromasm
@@ -0,0 +1,25 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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) "noffi_f32.asm.js")
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $0 f32) (result f32)
+ (f32.add
+ (get_local $0)
+ (f32.const 1)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_f32.fromasm.clamp b/test/noffi_f32.fromasm.clamp
new file mode 100644
index 000000000..4236c215f
--- /dev/null
+++ b/test/noffi_f32.fromasm.clamp
@@ -0,0 +1,25 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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) "noffi_f32.asm.js")
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $0 f32) (result f32)
+ (f32.add
+ (get_local $0)
+ (f32.const 1)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_f32.fromasm.clamp.no-opts b/test/noffi_f32.fromasm.clamp.no-opts
new file mode 100644
index 000000000..3e6d142c0
--- /dev/null
+++ b/test/noffi_f32.fromasm.clamp.no-opts
@@ -0,0 +1,28 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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))
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $a f32) (result f32)
+ (return
+ (f32.add
+ (get_local $a)
+ (f32.const 1)
+ )
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/noffi_f32.fromasm.imprecise b/test/noffi_f32.fromasm.imprecise
new file mode 100644
index 000000000..5553a036a
--- /dev/null
+++ b/test/noffi_f32.fromasm.imprecise
@@ -0,0 +1,24 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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))
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $0 f32) (result f32)
+ (f32.add
+ (get_local $0)
+ (f32.const 1)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_f32.fromasm.imprecise.no-opts b/test/noffi_f32.fromasm.imprecise.no-opts
new file mode 100644
index 000000000..3e6d142c0
--- /dev/null
+++ b/test/noffi_f32.fromasm.imprecise.no-opts
@@ -0,0 +1,28 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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))
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $a f32) (result f32)
+ (return
+ (f32.add
+ (get_local $a)
+ (f32.const 1)
+ )
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/noffi_f32.fromasm.no-opts b/test/noffi_f32.fromasm.no-opts
new file mode 100644
index 000000000..3e6d142c0
--- /dev/null
+++ b/test/noffi_f32.fromasm.no-opts
@@ -0,0 +1,28 @@
+(module
+ (type $FUNCSIG$ff (func (param f32) (result f32)))
+ (import "env" "_importf" (func $importf (param f32) (result f32)))
+ (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))
+ (export "main" (func $main))
+ (export "exportf" (func $exportf))
+ (func $exportf (param $a f32) (result f32)
+ (return
+ (f32.add
+ (get_local $a)
+ (f32.const 1)
+ )
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importf
+ (f32.const 3.4000000953674316)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/noffi_i64.asm.js b/test/noffi_i64.asm.js
new file mode 100644
index 000000000..304d70fc0
--- /dev/null
+++ b/test/noffi_i64.asm.js
@@ -0,0 +1,21 @@
+function(global, env, buffer) {
+ "use asm";
+ var importll=env._importll;
+
+ function add(a,b) {
+ a = i64(a);
+ b = i64(b);
+ var c = i64();
+ c = i64_add(b,a);
+ return (i64(c));
+ }
+ function main() {
+ (i64(importll(i64_const(2,0))));
+ return 0;
+ }
+
+ return {
+ _add: add,
+ _main: main };
+}
+;
diff --git a/test/noffi_i64.fromasm b/test/noffi_i64.fromasm
new file mode 100644
index 000000000..65aacd9d3
--- /dev/null
+++ b/test/noffi_i64.fromasm
@@ -0,0 +1,25 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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) "noffi_i64.asm.js")
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $0 i64) (param $1 i64) (result i64)
+ (i64.add
+ (get_local $1)
+ (get_local $0)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_i64.fromasm.clamp b/test/noffi_i64.fromasm.clamp
new file mode 100644
index 000000000..65aacd9d3
--- /dev/null
+++ b/test/noffi_i64.fromasm.clamp
@@ -0,0 +1,25 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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) "noffi_i64.asm.js")
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $0 i64) (param $1 i64) (result i64)
+ (i64.add
+ (get_local $1)
+ (get_local $0)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_i64.fromasm.clamp.no-opts b/test/noffi_i64.fromasm.clamp.no-opts
new file mode 100644
index 000000000..f6fd65454
--- /dev/null
+++ b/test/noffi_i64.fromasm.clamp.no-opts
@@ -0,0 +1,32 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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))
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $a i64) (param $b i64) (result i64)
+ (local $c i64)
+ (set_local $c
+ (i64.add
+ (get_local $b)
+ (get_local $a)
+ )
+ )
+ (return
+ (get_local $c)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/noffi_i64.fromasm.imprecise b/test/noffi_i64.fromasm.imprecise
new file mode 100644
index 000000000..925e29862
--- /dev/null
+++ b/test/noffi_i64.fromasm.imprecise
@@ -0,0 +1,24 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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))
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $0 i64) (param $1 i64) (result i64)
+ (i64.add
+ (get_local $1)
+ (get_local $0)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (i32.const 0)
+ )
+)
diff --git a/test/noffi_i64.fromasm.imprecise.no-opts b/test/noffi_i64.fromasm.imprecise.no-opts
new file mode 100644
index 000000000..f6fd65454
--- /dev/null
+++ b/test/noffi_i64.fromasm.imprecise.no-opts
@@ -0,0 +1,32 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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))
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $a i64) (param $b i64) (result i64)
+ (local $c i64)
+ (set_local $c
+ (i64.add
+ (get_local $b)
+ (get_local $a)
+ )
+ )
+ (return
+ (get_local $c)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/noffi_i64.fromasm.no-opts b/test/noffi_i64.fromasm.no-opts
new file mode 100644
index 000000000..f6fd65454
--- /dev/null
+++ b/test/noffi_i64.fromasm.no-opts
@@ -0,0 +1,32 @@
+(module
+ (type $FUNCSIG$jj (func (param i64) (result i64)))
+ (import "env" "_importll" (func $importll (param i64) (result i64)))
+ (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))
+ (export "_add" (func $add))
+ (export "_main" (func $main))
+ (func $add (param $a i64) (param $b i64) (result i64)
+ (local $c i64)
+ (set_local $c
+ (i64.add
+ (get_local $b)
+ (get_local $a)
+ )
+ )
+ (return
+ (get_local $c)
+ )
+ )
+ (func $main (result i32)
+ (drop
+ (call $importll
+ (i64.const 2)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)