Chromium Code Reviews| Index: src/compiler/arm64/instruction-selector-arm64.cc |
| diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc |
| index e15324f6e69091c94090c25c9b3e57d1f779d0b7..3173be7f058e106c40fd5006bf9f25c13a08df1b 100644 |
| --- a/src/compiler/arm64/instruction-selector-arm64.cc |
| +++ b/src/compiler/arm64/instruction-selector-arm64.cc |
| @@ -471,6 +471,9 @@ void VisitBinop(InstructionSelector* selector, Node* node, |
| if (cont->IsDeoptimize()) { |
| selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
| cont->reason(), cont->frame_state()); |
| + } else if (cont->IsTrap()) { |
| + inputs[input_count++] = g.UseImmediate(cont->trap_id()); |
| + selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| } else { |
| selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| } |
| @@ -1384,9 +1387,12 @@ void EmitInt32MulWithOverflow(InstructionSelector* selector, Node* node, |
| InstructionOperand in[] = {result, result}; |
| selector->EmitDeoptimize(opcode, 0, nullptr, 2, in, cont->reason(), |
| cont->frame_state()); |
| - } else { |
| - DCHECK(cont->IsSet()); |
| + } else if (cont->IsSet()) { |
| selector->Emit(opcode, g.DefineAsRegister(cont->result()), result, result); |
| + } else { |
| + DCHECK(cont->IsTrap()); |
| + selector->Emit(opcode, g.NoOutput(), result, result, |
| + g.UseImmediate(cont->trap_id())); |
| } |
| } |
| @@ -2000,9 +2006,12 @@ void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| } else if (cont->IsDeoptimize()) { |
| selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| cont->frame_state()); |
| - } else { |
| - DCHECK(cont->IsSet()); |
| + } else if (cont->IsSet()) { |
| selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| + } else { |
| + DCHECK(cont->IsTrap()); |
| + selector->Emit(opcode, g.NoOutput(), left, right, |
| + g.UseImmediate(cont->trap_id())); |
| } |
| } |
| @@ -2179,7 +2188,7 @@ bool TryEmitCbzOrTbz(InstructionSelector* selector, Node* node, Node* user, |
| USE(m_user); |
| DCHECK(m_user.right().Is(0) || m_user.left().Is(0)); |
| - // Only handle branches and deoptimisations. |
| + // Only handle branches and deoptimisations and traps. |
|
georgia.kouveli
2017/01/10 14:37:52
The code here has not been updated to handle traps
ahaas
2017/01/10 14:44:50
I changed the comment back.
|
| if (!cont->IsBranch() && !cont->IsDeoptimize()) return false; |
| switch (cond) { |
| @@ -2518,11 +2527,15 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user, |
| selector->Emit(cont->Encode(kArm64CompareAndBranch32), g.NoOutput(), |
| g.UseRegister(value), g.Label(cont->true_block()), |
| g.Label(cont->false_block())); |
| - } else { |
| - DCHECK(cont->IsDeoptimize()); |
| + } else if (cont->IsDeoptimize()) { |
| selector->EmitDeoptimize(cont->Encode(kArm64Tst32), g.NoOutput(), |
| g.UseRegister(value), g.UseRegister(value), |
| cont->reason(), cont->frame_state()); |
| + } else { |
| + DCHECK(cont->IsTrap()); |
| + selector->Emit(cont->Encode(kArm64Tst32), g.NoOutput(), |
| + g.UseRegister(value), g.UseRegister(value), |
| + g.UseImmediate(cont->trap_id())); |
| } |
| } |
| @@ -2547,12 +2560,16 @@ void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| } |
| void InstructionSelector::VisitTrapIf(Node* node, Runtime::FunctionId func_id) { |
| - UNREACHABLE(); |
| + FlagsContinuation cont = |
| + FlagsContinuation::ForTrap(kNotEqual, func_id, node->InputAt(1)); |
| + VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| } |
| void InstructionSelector::VisitTrapUnless(Node* node, |
| Runtime::FunctionId func_id) { |
| - UNREACHABLE(); |
| + FlagsContinuation cont = |
| + FlagsContinuation::ForTrap(kEqual, func_id, node->InputAt(1)); |
| + VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| } |
| void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |