diff --git a/js/src/asmjs/WasmTextToBinary.cpp b/js/src/asmjs/WasmTextToBinary.cpp index ad7672b50a19..1de32a972653 100644 --- a/js/src/asmjs/WasmTextToBinary.cpp +++ b/js/src/asmjs/WasmTextToBinary.cpp @@ -211,8 +211,8 @@ enum class WasmAstExprKind SetLocal, Store, TernaryOperator, - Trap, UnaryOperator, + Unreachable }; class WasmAstExpr : public WasmAstNode @@ -241,10 +241,10 @@ struct WasmAstNop : WasmAstExpr {} }; -struct WasmAstTrap : WasmAstExpr +struct WasmAstUnreachable : WasmAstExpr { - WasmAstTrap() - : WasmAstExpr(WasmAstExprKind::Trap) + WasmAstUnreachable() + : WasmAstExpr(WasmAstExprKind::Unreachable) {} }; @@ -831,9 +831,9 @@ class WasmToken Table, TernaryOpcode, Text, - Trap, Type, UnaryOpcode, + Unreachable, ValueType }; private: @@ -1996,8 +1996,11 @@ WasmTokenStream::next() return WasmToken(WasmToken::Table, begin, cur_); if (consume(MOZ_UTF16("type"))) return WasmToken(WasmToken::Type, begin, cur_); - if (consume(MOZ_UTF16("trap"))) - return WasmToken(WasmToken::Trap, begin, cur_); + break; + + case 'u': + if (consume(MOZ_UTF16("unreachable"))) + return WasmToken(WasmToken::Unreachable, begin, cur_); break; default: @@ -2772,8 +2775,8 @@ ParseExprInsideParens(WasmParseContext& c) switch (token.kind()) { case WasmToken::Nop: return new(c.lifo) WasmAstNop; - case WasmToken::Trap: - return new(c.lifo) WasmAstTrap; + case WasmToken::Unreachable: + return new(c.lifo) WasmAstUnreachable; case WasmToken::BinaryOpcode: return ParseBinaryOperator(c, token.expr()); case WasmToken::Block: @@ -3491,7 +3494,7 @@ ResolveExpr(Resolver& r, WasmAstExpr& expr) { switch (expr.kind()) { case WasmAstExprKind::Nop: - case WasmAstExprKind::Trap: + case WasmAstExprKind::Unreachable: return true; case WasmAstExprKind::BinaryOperator: return ResolveBinaryOperator(r, expr.as()); @@ -3833,7 +3836,7 @@ EncodeExpr(Encoder& e, WasmAstExpr& expr) switch (expr.kind()) { case WasmAstExprKind::Nop: return e.writeExpr(Expr::Nop); - case WasmAstExprKind::Trap: + case WasmAstExprKind::Unreachable: return e.writeExpr(Expr::Unreachable); case WasmAstExprKind::BinaryOperator: return EncodeBinaryOperator(e, expr.as()); diff --git a/js/src/jit-test/tests/wasm/basic-control-flow.js b/js/src/jit-test/tests/wasm/basic-control-flow.js index b1121698fd3b..733d32a4f27c 100644 --- a/js/src/jit-test/tests/wasm/basic-control-flow.js +++ b/js/src/jit-test/tests/wasm/basic-control-flow.js @@ -518,8 +518,8 @@ assertEq(f(3), -1); // unreachable const UNREACHABLE = /unreachable/; -assertErrorMessage(wasmEvalText(`(module (func (trap)) (export "" 0))`), Error, UNREACHABLE); -assertErrorMessage(wasmEvalText(`(module (func (if (trap) (i32.const 0))) (export "" 0))`), Error, UNREACHABLE); -assertErrorMessage(wasmEvalText(`(module (func (block (br_if 0 (trap)))) (export "" 0))`), Error, UNREACHABLE); -assertErrorMessage(wasmEvalText(`(module (func (block (br_table 0 (trap)))) (export "" 0))`), Error, UNREACHABLE); -assertErrorMessage(wasmEvalText(`(module (func (result i32) (i32.add (i32.const 0) (trap))) (export "" 0))`), Error, UNREACHABLE); +assertErrorMessage(wasmEvalText(`(module (func (unreachable)) (export "" 0))`), Error, UNREACHABLE); +assertErrorMessage(wasmEvalText(`(module (func (if (unreachable) (i32.const 0))) (export "" 0))`), Error, UNREACHABLE); +assertErrorMessage(wasmEvalText(`(module (func (block (br_if 0 (unreachable)))) (export "" 0))`), Error, UNREACHABLE); +assertErrorMessage(wasmEvalText(`(module (func (block (br_table 0 (unreachable)))) (export "" 0))`), Error, UNREACHABLE); +assertErrorMessage(wasmEvalText(`(module (func (result i32) (i32.add (i32.const 0) (unreachable))) (export "" 0))`), Error, UNREACHABLE); diff --git a/js/src/jit-test/tests/wasm/random-control-flow.js b/js/src/jit-test/tests/wasm/random-control-flow.js index 693156349985..9f0bbc0a7963 100644 --- a/js/src/jit-test/tests/wasm/random-control-flow.js +++ b/js/src/jit-test/tests/wasm/random-control-flow.js @@ -38,7 +38,7 @@ wasmEvalText(`(module (func (result i32) (param i32) (param i32) (i32.const 0)) (func (result i32) (call 0 (i32.const 1) (call 0 (i32.const 2) (i32.const 3))) - (call 0 (trap) (i32.const 4)) + (call 0 (unreachable) (i32.const 4)) ) )`);