| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
| 6 | 6 |
| 7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace compiler { | 14 namespace compiler { |
| 15 | 15 |
| 16 InstructionSelector::InstructionSelector(InstructionSequence* sequence, | 16 InstructionSelector::InstructionSelector(InstructionSequence* sequence, |
| 17 SourcePositionTable* source_positions, | 17 SourcePositionTable* source_positions, |
| 18 Features features) | 18 Features features) |
| 19 : zone_(sequence->isolate()), | 19 : zone_(sequence->isolate()), |
| 20 sequence_(sequence), | 20 sequence_(sequence), |
| 21 source_positions_(source_positions), | 21 source_positions_(source_positions), |
| 22 features_(features), | 22 features_(features), |
| 23 current_block_(NULL), | 23 current_block_(NULL), |
| 24 instructions_(InstructionDeque::allocator_type(zone())), | 24 instructions_(zone()), |
| 25 defined_(graph()->NodeCount(), false, BoolVector::allocator_type(zone())), | 25 defined_(graph()->NodeCount(), false, zone()), |
| 26 used_(graph()->NodeCount(), false, BoolVector::allocator_type(zone())) {} | 26 used_(graph()->NodeCount(), false, zone()) {} |
| 27 | 27 |
| 28 | 28 |
| 29 void InstructionSelector::SelectInstructions() { | 29 void InstructionSelector::SelectInstructions() { |
| 30 // Mark the inputs of all phis in loop headers as used. | 30 // Mark the inputs of all phis in loop headers as used. |
| 31 BasicBlockVector* blocks = schedule()->rpo_order(); | 31 BasicBlockVector* blocks = schedule()->rpo_order(); |
| 32 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) { | 32 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) { |
| 33 BasicBlock* block = *i; | 33 BasicBlock* block = *i; |
| 34 if (!block->IsLoopHeader()) continue; | 34 if (!block->IsLoopHeader()) continue; |
| 35 DCHECK_NE(0, block->PredecessorCount()); | 35 DCHECK_NE(0, block->PredecessorCount()); |
| 36 DCHECK_NE(1, block->PredecessorCount()); | 36 DCHECK_NE(1, block->PredecessorCount()); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (RepresentationOf(rep) == kRepTagged) MarkAsReference(node); | 248 if (RepresentationOf(rep) == kRepTagged) MarkAsReference(node); |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 // TODO(bmeurer): Get rid of the CallBuffer business and make | 252 // TODO(bmeurer): Get rid of the CallBuffer business and make |
| 253 // InstructionSelector::VisitCall platform independent instead. | 253 // InstructionSelector::VisitCall platform independent instead. |
| 254 CallBuffer::CallBuffer(Zone* zone, CallDescriptor* d, | 254 CallBuffer::CallBuffer(Zone* zone, CallDescriptor* d, |
| 255 FrameStateDescriptor* frame_desc) | 255 FrameStateDescriptor* frame_desc) |
| 256 : descriptor(d), | 256 : descriptor(d), |
| 257 frame_state_descriptor(frame_desc), | 257 frame_state_descriptor(frame_desc), |
| 258 output_nodes(NodeVector::allocator_type(zone)), | 258 output_nodes(zone), |
| 259 outputs(InstructionOperandVector::allocator_type(zone)), | 259 outputs(zone), |
| 260 instruction_args(InstructionOperandVector::allocator_type(zone)), | 260 instruction_args(zone), |
| 261 pushed_nodes(NodeVector::allocator_type(zone)) { | 261 pushed_nodes(zone) { |
| 262 output_nodes.reserve(d->ReturnCount()); | 262 output_nodes.reserve(d->ReturnCount()); |
| 263 outputs.reserve(d->ReturnCount()); | 263 outputs.reserve(d->ReturnCount()); |
| 264 pushed_nodes.reserve(input_count()); | 264 pushed_nodes.reserve(input_count()); |
| 265 instruction_args.reserve(input_count() + control_count() + | 265 instruction_args.reserve(input_count() + control_count() + |
| 266 frame_state_value_count()); | 266 frame_state_value_count()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 | 269 |
| 270 // TODO(bmeurer): Get rid of the CallBuffer business and make | 270 // TODO(bmeurer): Get rid of the CallBuffer business and make |
| 271 // InstructionSelector::VisitCall platform independent instead. | 271 // InstructionSelector::VisitCall platform independent instead. |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 inputs->push_back(UseOrImmediate(&g, stack->InputAt(i))); | 1067 inputs->push_back(UseOrImmediate(&g, stack->InputAt(i))); |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 void InstructionSelector::VisitDeoptimize(Node* deopt) { | 1072 void InstructionSelector::VisitDeoptimize(Node* deopt) { |
| 1073 DCHECK(deopt->op()->opcode() == IrOpcode::kDeoptimize); | 1073 DCHECK(deopt->op()->opcode() == IrOpcode::kDeoptimize); |
| 1074 Node* state = deopt->InputAt(0); | 1074 Node* state = deopt->InputAt(0); |
| 1075 FrameStateDescriptor* descriptor = GetFrameStateDescriptor(state); | 1075 FrameStateDescriptor* descriptor = GetFrameStateDescriptor(state); |
| 1076 | 1076 |
| 1077 InstructionOperandVector inputs( | 1077 InstructionOperandVector inputs(zone()); |
| 1078 (InstructionOperandVector::allocator_type(zone()))); | |
| 1079 inputs.reserve(descriptor->size()); | 1078 inputs.reserve(descriptor->size()); |
| 1080 | 1079 |
| 1081 AddFrameStateInputs(state, &inputs, descriptor); | 1080 AddFrameStateInputs(state, &inputs, descriptor); |
| 1082 | 1081 |
| 1083 DCHECK_EQ(descriptor->size(), inputs.size()); | 1082 DCHECK_EQ(descriptor->size(), inputs.size()); |
| 1084 | 1083 |
| 1085 int deoptimization_id = sequence()->AddDeoptimizationEntry(descriptor); | 1084 int deoptimization_id = sequence()->AddDeoptimizationEntry(descriptor); |
| 1086 Emit(kArchDeoptimize | MiscField::encode(deoptimization_id), 0, NULL, | 1085 Emit(kArchDeoptimize | MiscField::encode(deoptimization_id), 0, NULL, |
| 1087 inputs.size(), &inputs.front(), 0, NULL); | 1086 inputs.size(), &inputs.front(), 0, NULL); |
| 1088 } | 1087 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 | 1125 |
| 1127 | 1126 |
| 1128 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, | 1127 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, |
| 1129 BasicBlock* deoptimization) {} | 1128 BasicBlock* deoptimization) {} |
| 1130 | 1129 |
| 1131 #endif // !V8_TURBOFAN_BACKEND | 1130 #endif // !V8_TURBOFAN_BACKEND |
| 1132 | 1131 |
| 1133 } // namespace compiler | 1132 } // namespace compiler |
| 1134 } // namespace internal | 1133 } // namespace internal |
| 1135 } // namespace v8 | 1134 } // namespace v8 |
| OLD | NEW |