| Index: src/compiler/wasm-compiler.cc
|
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
|
| index b543c80e5722fc7828a65e019371359e0d8a1f01..c985115b8c9e67bdff8e10bc9d7a84d91b878678 100644
|
| --- a/src/compiler/wasm-compiler.cc
|
| +++ b/src/compiler/wasm-compiler.cc
|
| @@ -614,15 +614,20 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
|
| return BuildF32Max(left, right);
|
| case wasm::kExprF64Max:
|
| return BuildF64Max(left, right);
|
| - case wasm::kExprF64Pow: {
|
| + case wasm::kExprF64Pow:
|
| return BuildF64Pow(left, right);
|
| - }
|
| - case wasm::kExprF64Atan2: {
|
| + case wasm::kExprF64Atan2:
|
| return BuildF64Atan2(left, right);
|
| - }
|
| - case wasm::kExprF64Mod: {
|
| + case wasm::kExprF64Mod:
|
| return BuildF64Mod(left, right);
|
| - }
|
| + case wasm::kExprI32AsmjsDivS:
|
| + return BuildI32AsmjsDivS(left, right);
|
| + case wasm::kExprI32AsmjsDivU:
|
| + return BuildI32AsmjsDivU(left, right);
|
| + case wasm::kExprI32AsmjsRemS:
|
| + return BuildI32AsmjsRemS(left, right);
|
| + case wasm::kExprI32AsmjsRemU:
|
| + return BuildI32AsmjsRemU(left, right);
|
| default:
|
| op = UnsupportedOpcode(opcode);
|
| }
|
| @@ -1591,34 +1596,6 @@ Node* WasmGraphBuilder::BuildFloatToIntConversionInstruction(
|
| Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
|
| wasm::WasmCodePosition position) {
|
| MachineOperatorBuilder* m = jsgraph()->machine();
|
| - if (module_ && module_->asm_js()) {
|
| - // asm.js semantics return 0 on divide or mod by zero.
|
| - if (m->Int32DivIsSafe()) {
|
| - // The hardware instruction does the right thing (e.g. arm).
|
| - return graph()->NewNode(m->Int32Div(), left, right, graph()->start());
|
| - }
|
| -
|
| - // Check denominator for zero.
|
| - Diamond z(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| - BranchHint::kFalse);
|
| -
|
| - // Check numerator for -1. (avoid minint / -1 case).
|
| - Diamond n(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
|
| - BranchHint::kFalse);
|
| -
|
| - Node* div = graph()->NewNode(m->Int32Div(), left, right, z.if_false);
|
| - Node* neg =
|
| - graph()->NewNode(m->Int32Sub(), jsgraph()->Int32Constant(0), left);
|
| -
|
| - return n.Phi(MachineRepresentation::kWord32, neg,
|
| - z.Phi(MachineRepresentation::kWord32,
|
| - jsgraph()->Int32Constant(0), div));
|
| - }
|
| -
|
| trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position);
|
| Node* before = *control_;
|
| Node* denom_is_m1;
|
| @@ -1640,26 +1617,6 @@ Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
|
| Node* WasmGraphBuilder::BuildI32RemS(Node* left, Node* right,
|
| wasm::WasmCodePosition position) {
|
| MachineOperatorBuilder* m = jsgraph()->machine();
|
| - if (module_ && module_->asm_js()) {
|
| - // asm.js semantics return 0 on divide or mod by zero.
|
| - // Explicit check for x % 0.
|
| - Diamond z(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| - BranchHint::kFalse);
|
| -
|
| - // Explicit check for x % -1.
|
| - Diamond d(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
|
| - BranchHint::kFalse);
|
| - d.Chain(z.if_false);
|
| -
|
| - return z.Phi(
|
| - MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| - d.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| - graph()->NewNode(m->Int32Mod(), left, right, d.if_false)));
|
| - }
|
|
|
| trap_->ZeroCheck32(wasm::kTrapRemByZero, right, position);
|
|
|
| @@ -1676,23 +1633,6 @@ Node* WasmGraphBuilder::BuildI32RemS(Node* left, Node* right,
|
| Node* WasmGraphBuilder::BuildI32DivU(Node* left, Node* right,
|
| wasm::WasmCodePosition position) {
|
| MachineOperatorBuilder* m = jsgraph()->machine();
|
| - if (module_ && module_->asm_js()) {
|
| - // asm.js semantics return 0 on divide or mod by zero.
|
| - if (m->Uint32DivIsSafe()) {
|
| - // The hardware instruction does the right thing (e.g. arm).
|
| - return graph()->NewNode(m->Uint32Div(), left, right, graph()->start());
|
| - }
|
| -
|
| - // Explicit check for x % 0.
|
| - Diamond z(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| - BranchHint::kFalse);
|
| -
|
| - return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| - graph()->NewNode(jsgraph()->machine()->Uint32Div(), left,
|
| - right, z.if_false));
|
| - }
|
| return graph()->NewNode(
|
| m->Uint32Div(), left, right,
|
| trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position));
|
| @@ -1701,25 +1641,96 @@ Node* WasmGraphBuilder::BuildI32DivU(Node* left, Node* right,
|
| Node* WasmGraphBuilder::BuildI32RemU(Node* left, Node* right,
|
| wasm::WasmCodePosition position) {
|
| MachineOperatorBuilder* m = jsgraph()->machine();
|
| - if (module_ && module_->asm_js()) {
|
| - // asm.js semantics return 0 on divide or mod by zero.
|
| - // Explicit check for x % 0.
|
| - Diamond z(
|
| - graph(), jsgraph()->common(),
|
| - graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| - BranchHint::kFalse);
|
| -
|
| - Node* rem = graph()->NewNode(jsgraph()->machine()->Uint32Mod(), left, right,
|
| - z.if_false);
|
| - return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| - rem);
|
| - }
|
| -
|
| return graph()->NewNode(
|
| m->Uint32Mod(), left, right,
|
| trap_->ZeroCheck32(wasm::kTrapRemByZero, right, position));
|
| }
|
|
|
| +Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
|
| + MachineOperatorBuilder* m = jsgraph()->machine();
|
| + // asm.js semantics return 0 on divide or mod by zero.
|
| + if (m->Int32DivIsSafe()) {
|
| + // The hardware instruction does the right thing (e.g. arm).
|
| + return graph()->NewNode(m->Int32Div(), left, right, graph()->start());
|
| + }
|
| +
|
| + // Check denominator for zero.
|
| + Diamond z(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| + BranchHint::kFalse);
|
| +
|
| + // Check numerator for -1. (avoid minint / -1 case).
|
| + Diamond n(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
|
| + BranchHint::kFalse);
|
| +
|
| + Node* div = graph()->NewNode(m->Int32Div(), left, right, z.if_false);
|
| + Node* neg =
|
| + graph()->NewNode(m->Int32Sub(), jsgraph()->Int32Constant(0), left);
|
| +
|
| + return n.Phi(
|
| + MachineRepresentation::kWord32, neg,
|
| + z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0), div));
|
| +}
|
| +
|
| +Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
|
| + MachineOperatorBuilder* m = jsgraph()->machine();
|
| + // asm.js semantics return 0 on divide or mod by zero.
|
| + // Explicit check for x % 0.
|
| + Diamond z(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| + BranchHint::kFalse);
|
| +
|
| + // Explicit check for x % -1.
|
| + Diamond d(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
|
| + BranchHint::kFalse);
|
| + d.Chain(z.if_false);
|
| +
|
| + return z.Phi(
|
| + MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| + d.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| + graph()->NewNode(m->Int32Mod(), left, right, d.if_false)));
|
| +}
|
| +
|
| +Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
|
| + MachineOperatorBuilder* m = jsgraph()->machine();
|
| + // asm.js semantics return 0 on divide or mod by zero.
|
| + if (m->Uint32DivIsSafe()) {
|
| + // The hardware instruction does the right thing (e.g. arm).
|
| + return graph()->NewNode(m->Uint32Div(), left, right, graph()->start());
|
| + }
|
| +
|
| + // Explicit check for x % 0.
|
| + Diamond z(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| + BranchHint::kFalse);
|
| +
|
| + return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| + graph()->NewNode(jsgraph()->machine()->Uint32Div(), left, right,
|
| + z.if_false));
|
| +}
|
| +
|
| +Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
|
| + MachineOperatorBuilder* m = jsgraph()->machine();
|
| + // asm.js semantics return 0 on divide or mod by zero.
|
| + // Explicit check for x % 0.
|
| + Diamond z(
|
| + graph(), jsgraph()->common(),
|
| + graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(0)),
|
| + BranchHint::kFalse);
|
| +
|
| + Node* rem = graph()->NewNode(jsgraph()->machine()->Uint32Mod(), left, right,
|
| + z.if_false);
|
| + return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
|
| + rem);
|
| +}
|
| +
|
| Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
|
| wasm::WasmCodePosition position) {
|
| if (jsgraph()->machine()->Is32()) {
|
|
|