Skip to content

Commit 5578bb5

Browse files
authored
wasm2asm fixes (WebAssembly#1436)
* don't look for asm.js compilation message if almost asm * fix wasm2asm f32 operations
1 parent eacd9a9 commit 5578bb5

3 files changed

Lines changed: 16 additions & 26 deletions

File tree

scripts/test/wasm2asm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,16 @@ def test_wasm2asm_output():
5555
fail_if_not_identical(out, '')
5656

5757
if MOZJS:
58-
# verify asm.js validates
59-
# check only subset of err because mozjs emits timing info
60-
out = run_command([MOZJS, '-w', 'a.2asm.js'],
61-
expected_err='Successfully compiled asm.js code',
62-
err_contains=True)
63-
fail_if_not_identical(out, '')
64-
out = run_command([MOZJS, 'a.2asm.asserts.js'], expected_err='')
65-
fail_if_not_identical(out, '')
58+
# verify asm.js validates, if this is asm.js code (we emit
59+
# almost-asm instead when we need to)
60+
if 'use asm' in open('a.2asm.js').read():
61+
# check only subset of err because mozjs emits timing info
62+
out = run_command([MOZJS, '-w', 'a.2asm.js'],
63+
expected_err='Successfully compiled asm.js code',
64+
err_contains=True)
65+
fail_if_not_identical(out, '')
66+
out = run_command([MOZJS, 'a.2asm.asserts.js'], expected_err='')
67+
fail_if_not_identical(out, '')
6668

6769

6870
def test_asserts_output():

src/wasm2asm.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,33 +1581,21 @@ Ref Wasm2AsmBuilder::processFunctionBody(Function* func, IString result) {
15811581
return makeSigning(ValueBuilder::makeCall(WASM_ROTR32, left, right),
15821582
ASM_SIGNED);
15831583
case EqFloat32:
1584-
return makeAsmCoercion(ValueBuilder::makeBinary(left, EQ, right),
1585-
ASM_FLOAT);
15861584
case EqFloat64:
15871585
return ValueBuilder::makeBinary(left, EQ, right);
15881586
case NeFloat32:
1589-
return makeAsmCoercion(ValueBuilder::makeBinary(left, NE, right),
1590-
ASM_FLOAT);
15911587
case NeFloat64:
15921588
return ValueBuilder::makeBinary(left, NE, right);
15931589
case GeFloat32:
1594-
return makeAsmCoercion(ValueBuilder::makeBinary(left, GE, right),
1595-
ASM_FLOAT);
15961590
case GeFloat64:
15971591
return ValueBuilder::makeBinary(left, GE, right);
15981592
case GtFloat32:
1599-
return makeAsmCoercion(ValueBuilder::makeBinary(left, GT, right),
1600-
ASM_FLOAT);
16011593
case GtFloat64:
16021594
return ValueBuilder::makeBinary(left, GT, right);
16031595
case LeFloat32:
1604-
return makeAsmCoercion(ValueBuilder::makeBinary(left, LE, right),
1605-
ASM_FLOAT);
16061596
case LeFloat64:
16071597
return ValueBuilder::makeBinary(left, LE, right);
16081598
case LtFloat32:
1609-
return makeAsmCoercion(ValueBuilder::makeBinary(left, LT, right),
1610-
ASM_FLOAT);
16111599
case LtFloat64:
16121600
return ValueBuilder::makeBinary(left, LT, right);
16131601
default: {

test/float-ops.2asm.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,47 +84,47 @@ function asmFunc(global, env, buffer) {
8484
$$0 = Math_fround($$0);
8585
$$1 = Math_fround($$1);
8686
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
87-
return Math_fround($$0 == $$1) | 0;
87+
return $$0 == $$1 | 0;
8888
return wasm2asm_i32$0 | 0;
8989
}
9090

9191
function $$10($$0, $$1) {
9292
$$0 = Math_fround($$0);
9393
$$1 = Math_fround($$1);
9494
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
95-
return Math_fround($$0 != $$1) | 0;
95+
return $$0 != $$1 | 0;
9696
return wasm2asm_i32$0 | 0;
9797
}
9898

9999
function $$11($$0, $$1) {
100100
$$0 = Math_fround($$0);
101101
$$1 = Math_fround($$1);
102102
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
103-
return Math_fround($$0 >= $$1) | 0;
103+
return $$0 >= $$1 | 0;
104104
return wasm2asm_i32$0 | 0;
105105
}
106106

107107
function $$12($$0, $$1) {
108108
$$0 = Math_fround($$0);
109109
$$1 = Math_fround($$1);
110110
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
111-
return Math_fround($$0 > $$1) | 0;
111+
return $$0 > $$1 | 0;
112112
return wasm2asm_i32$0 | 0;
113113
}
114114

115115
function $$13($$0, $$1) {
116116
$$0 = Math_fround($$0);
117117
$$1 = Math_fround($$1);
118118
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
119-
return Math_fround($$0 <= $$1) | 0;
119+
return $$0 <= $$1 | 0;
120120
return wasm2asm_i32$0 | 0;
121121
}
122122

123123
function $$14($$0, $$1) {
124124
$$0 = Math_fround($$0);
125125
$$1 = Math_fround($$1);
126126
var $$2 = Math_fround(0), $$3 = Math_fround(0), $$4 = 0, wasm2asm_i32$0 = 0;
127-
return Math_fround($$0 < $$1) | 0;
127+
return $$0 < $$1 | 0;
128128
return wasm2asm_i32$0 | 0;
129129
}
130130

0 commit comments

Comments
 (0)