summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-02-20 19:28:23 -0800
committerGitHub <noreply@github.com>2018-02-20 19:28:23 -0800
commit5578bb58402fde2bb2c932bfa08ab71045854a41 (patch)
treea547cf74eeaa60dd430de091fcae0a3eab8999a9
parenteacd9a987750ae3984c225a73e9567931277d6a0 (diff)
downloadbinaryen-5578bb58402fde2bb2c932bfa08ab71045854a41.tar.gz
binaryen-5578bb58402fde2bb2c932bfa08ab71045854a41.tar.bz2
binaryen-5578bb58402fde2bb2c932bfa08ab71045854a41.zip
wasm2asm fixes (#1436)
* don't look for asm.js compilation message if almost asm * fix wasm2asm f32 operations
-rwxr-xr-xscripts/test/wasm2asm.py18
-rw-r--r--src/wasm2asm.h12
-rw-r--r--test/float-ops.2asm.js12
3 files changed, 16 insertions, 26 deletions
diff --git a/scripts/test/wasm2asm.py b/scripts/test/wasm2asm.py
index 35c0d4b8c..6e6b32c81 100755
--- a/scripts/test/wasm2asm.py
+++ b/scripts/test/wasm2asm.py
@@ -55,14 +55,16 @@ def test_wasm2asm_output():
fail_if_not_identical(out, '')
if MOZJS:
- # verify asm.js validates
- # check only subset of err because mozjs emits timing info
- out = run_command([MOZJS, '-w', 'a.2asm.js'],
- expected_err='Successfully compiled asm.js code',
- err_contains=True)
- fail_if_not_identical(out, '')
- out = run_command([MOZJS, 'a.2asm.asserts.js'], expected_err='')
- fail_if_not_identical(out, '')
+ # verify asm.js validates, if this is asm.js code (we emit
+ # almost-asm instead when we need to)
+ if 'use asm' in open('a.2asm.js').read():
+ # check only subset of err because mozjs emits timing info
+ out = run_command([MOZJS, '-w', 'a.2asm.js'],
+ expected_err='Successfully compiled asm.js code',
+ err_contains=True)
+ fail_if_not_identical(out, '')
+ out = run_command([MOZJS, 'a.2asm.asserts.js'], expected_err='')
+ fail_if_not_identical(out, '')
def test_asserts_output():
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index ca67b0aa8..eded082ad 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -1581,33 +1581,21 @@ Ref Wasm2AsmBuilder::processFunctionBody(Function* func, IString result) {
return makeSigning(ValueBuilder::makeCall(WASM_ROTR32, left, right),
ASM_SIGNED);
case EqFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, EQ, right),
- ASM_FLOAT);
case EqFloat64:
return ValueBuilder::makeBinary(left, EQ, right);
case NeFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, NE, right),
- ASM_FLOAT);
case NeFloat64:
return ValueBuilder::makeBinary(left, NE, right);
case GeFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, GE, right),
- ASM_FLOAT);
case GeFloat64:
return ValueBuilder::makeBinary(left, GE, right);
case GtFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, GT, right),
- ASM_FLOAT);
case GtFloat64:
return ValueBuilder::makeBinary(left, GT, right);
case LeFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, LE, right),
- ASM_FLOAT);
case LeFloat64:
return ValueBuilder::makeBinary(left, LE, right);
case LtFloat32:
- return makeAsmCoercion(ValueBuilder::makeBinary(left, LT, right),
- ASM_FLOAT);
case LtFloat64:
return ValueBuilder::makeBinary(left, LT, right);
default: {
diff --git a/test/float-ops.2asm.js b/test/float-ops.2asm.js
index 5cad310f9..524377aa3 100644
--- a/test/float-ops.2asm.js
+++ b/test/float-ops.2asm.js
@@ -84,7 +84,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 == $$1) | 0;
+ return $$0 == $$1 | 0;
return wasm2asm_i32$0 | 0;
}
@@ -92,7 +92,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 != $$1) | 0;
+ return $$0 != $$1 | 0;
return wasm2asm_i32$0 | 0;
}
@@ -100,7 +100,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 >= $$1) | 0;
+ return $$0 >= $$1 | 0;
return wasm2asm_i32$0 | 0;
}
@@ -108,7 +108,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 > $$1) | 0;
+ return $$0 > $$1 | 0;
return wasm2asm_i32$0 | 0;
}
@@ -116,7 +116,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 <= $$1) | 0;
+ return $$0 <= $$1 | 0;
return wasm2asm_i32$0 | 0;
}
@@ -124,7 +124,7 @@ function asmFunc(global, env, buffer) {
$$0 = Math_fround($$0);
$$1 = Math_fround($$1);
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
- return Math_fround($$0 < $$1) | 0;
+ return $$0 < $$1 | 0;
return wasm2asm_i32$0 | 0;
}