Chromium Code Reviews| Index: src/compiler/x64/instruction-selector-x64.cc |
| diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc |
| index b43d42679e449c9ee7b9f675e123988f9964946c..7a43bf8fa72aab74c24b2c43237f8c42bc9941f0 100644 |
| --- a/src/compiler/x64/instruction-selector-x64.cc |
| +++ b/src/compiler/x64/instruction-selector-x64.cc |
| @@ -5,6 +5,7 @@ |
| #include <algorithm> |
| #include "src/base/adapters.h" |
| +#include "src/compiler/compiler-source-position-table.h" |
| #include "src/compiler/instruction-selector-impl.h" |
| #include "src/compiler/node-matchers.h" |
| #include "src/compiler/node-properties.h" |
| @@ -1687,10 +1688,15 @@ void VisitCompareWithMemoryOperand(InstructionSelector* selector, |
| } else if (cont->IsDeoptimize()) { |
| selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, |
| cont->reason(), cont->frame_state()); |
| - } else { |
| - DCHECK(cont->IsSet()); |
| + } else if (cont->IsSet()) { |
| InstructionOperand output = g.DefineAsRegister(cont->result()); |
| selector->Emit(opcode, 1, &output, input_count, inputs); |
| + } else { |
| + DCHECK(cont->IsTrap()); |
| + inputs[input_count++] = g.UseImmediate(cont->trap_id()); |
| + Instruction* instr = |
| + selector->Emit(opcode, 0, nullptr, input_count, inputs); |
| + selector->SetSourcePosition(instr, *cont->source_position()); |
|
Jarin
2016/12/15 09:06:30
It is strange that the general source position mec
ahaas
2016/12/15 11:35:18
The problem with source positions is that source p
|
| } |
| } |
| @@ -1706,9 +1712,13 @@ 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()); |
| + Instruction* instr = selector->Emit(opcode, g.NoOutput(), left, right, |
| + g.UseImmediate(cont->trap_id())); |
| + selector->SetSourcePosition(instr, *cont->source_position()); |
| } |
| } |
| @@ -1858,9 +1868,13 @@ void VisitWord64Compare(InstructionSelector* selector, Node* node, |
| } else if (cont->IsDeoptimize()) { |
| selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(), |
| cont->frame_state()); |
| - } else { |
| - DCHECK(cont->IsSet()); |
| + } else if (cont->IsSet()) { |
| selector->Emit(opcode, g.DefineAsRegister(cont->result())); |
| + } else { |
| + DCHECK(cont->IsTrap()); |
| + Instruction* instr = selector->Emit(opcode, g.NoOutput(), |
| + g.UseImmediate(cont->trap_id())); |
| + selector->SetSourcePosition(instr, *cont->source_position()); |
| } |
| return; |
| } |
| @@ -2068,6 +2082,22 @@ void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| } |
| +void InstructionSelector::VisitTrapIf(Node* node) { |
| + SourcePosition pos = source_positions_->GetSourcePosition(node); |
| + FlagsContinuation cont = FlagsContinuation::ForTrap( |
| + kNotEqual, OpParameter<Runtime::FunctionId>(node->op()), &pos, |
| + node->InputAt(1)); |
| + VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| +} |
| + |
| +void InstructionSelector::VisitTrapUnless(Node* node) { |
| + SourcePosition pos = source_positions_->GetSourcePosition(node); |
| + FlagsContinuation cont = FlagsContinuation::ForTrap( |
| + kEqual, OpParameter<Runtime::FunctionId>(node->op()), &pos, |
| + node->InputAt(1)); |
| + VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| +} |
| + |
| void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| X64OperandGenerator g(this); |
| InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |