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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 defined_(graph()->NodeCount(), false, zone()), | 25 defined_(graph()->NodeCount(), false, zone()), |
26 used_(graph()->NodeCount(), false, 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, static_cast<int>(block->PredecessorCount())); |
36 DCHECK_NE(1, block->PredecessorCount()); | 36 DCHECK_NE(1, static_cast<int>(block->PredecessorCount())); |
37 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); | 37 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); |
38 ++j) { | 38 ++j) { |
39 Node* phi = *j; | 39 Node* phi = *j; |
40 if (phi->opcode() != IrOpcode::kPhi) continue; | 40 if (phi->opcode() != IrOpcode::kPhi) continue; |
41 | 41 |
42 // Mark all inputs as used. | 42 // Mark all inputs as used. |
43 Node::Inputs inputs = phi->inputs(); | 43 Node::Inputs inputs = phi->inputs(); |
44 for (InputIter k = inputs.begin(); k != inputs.end(); ++k) { | 44 for (InputIter k = inputs.begin(); k != inputs.end(); ++k) { |
45 MarkAsUsed(*k); | 45 MarkAsUsed(*k); |
46 } | 46 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 instruction_args.reserve(input_count() + frame_state_value_count()); | 246 instruction_args.reserve(input_count() + frame_state_value_count()); |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 // TODO(bmeurer): Get rid of the CallBuffer business and make | 250 // TODO(bmeurer): Get rid of the CallBuffer business and make |
251 // InstructionSelector::VisitCall platform independent instead. | 251 // InstructionSelector::VisitCall platform independent instead. |
252 void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, | 252 void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
253 bool call_code_immediate, | 253 bool call_code_immediate, |
254 bool call_address_immediate) { | 254 bool call_address_immediate) { |
255 OperandGenerator g(this); | 255 OperandGenerator g(this); |
256 DCHECK_EQ(call->op()->OutputCount(), buffer->descriptor->ReturnCount()); | 256 DCHECK_EQ(call->op()->OutputCount(), |
257 DCHECK_EQ(OperatorProperties::GetValueInputCount(call->op()), | 257 static_cast<int>(buffer->descriptor->ReturnCount())); |
258 buffer->input_count() + buffer->frame_state_count()); | 258 DCHECK_EQ( |
| 259 OperatorProperties::GetValueInputCount(call->op()), |
| 260 static_cast<int>(buffer->input_count() + buffer->frame_state_count())); |
259 | 261 |
260 if (buffer->descriptor->ReturnCount() > 0) { | 262 if (buffer->descriptor->ReturnCount() > 0) { |
261 // Collect the projections that represent multiple outputs from this call. | 263 // Collect the projections that represent multiple outputs from this call. |
262 if (buffer->descriptor->ReturnCount() == 1) { | 264 if (buffer->descriptor->ReturnCount() == 1) { |
263 buffer->output_nodes.push_back(call); | 265 buffer->output_nodes.push_back(call); |
264 } else { | 266 } else { |
265 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), NULL); | 267 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), NULL); |
266 call->CollectProjections(&buffer->output_nodes); | 268 call->CollectProjections(&buffer->output_nodes); |
267 } | 269 } |
268 | 270 |
(...skipping 27 matching lines...) Expand all Loading... |
296 callee->opcode() == IrOpcode::kInt64Constant)) | 298 callee->opcode() == IrOpcode::kInt64Constant)) |
297 ? g.UseImmediate(callee) | 299 ? g.UseImmediate(callee) |
298 : g.UseRegister(callee)); | 300 : g.UseRegister(callee)); |
299 break; | 301 break; |
300 case CallDescriptor::kCallJSFunction: | 302 case CallDescriptor::kCallJSFunction: |
301 buffer->instruction_args.push_back( | 303 buffer->instruction_args.push_back( |
302 g.UseLocation(callee, buffer->descriptor->GetInputLocation(0), | 304 g.UseLocation(callee, buffer->descriptor->GetInputLocation(0), |
303 buffer->descriptor->GetInputType(0))); | 305 buffer->descriptor->GetInputType(0))); |
304 break; | 306 break; |
305 } | 307 } |
306 DCHECK_EQ(1, buffer->instruction_args.size()); | 308 DCHECK_EQ(1, static_cast<int>(buffer->instruction_args.size())); |
307 | 309 |
308 // If the call needs a frame state, we insert the state information as | 310 // If the call needs a frame state, we insert the state information as |
309 // follows (n is the number of value inputs to the frame state): | 311 // follows (n is the number of value inputs to the frame state): |
310 // arg 1 : deoptimization id. | 312 // arg 1 : deoptimization id. |
311 // arg 2 - arg (n + 1) : value inputs to the frame state. | 313 // arg 2 - arg (n + 1) : value inputs to the frame state. |
312 if (buffer->frame_state_descriptor != NULL) { | 314 if (buffer->frame_state_descriptor != NULL) { |
313 InstructionSequence::StateId state_id = | 315 InstructionSequence::StateId state_id = |
314 sequence()->AddFrameStateDescriptor(buffer->frame_state_descriptor); | 316 sequence()->AddFrameStateDescriptor(buffer->frame_state_descriptor); |
315 buffer->instruction_args.push_back(g.TempImmediate(state_id.ToInt())); | 317 buffer->instruction_args.push_back(g.TempImmediate(state_id.ToInt())); |
316 | 318 |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 | 1054 |
1053 Node* parameters = state->InputAt(0); | 1055 Node* parameters = state->InputAt(0); |
1054 Node* locals = state->InputAt(1); | 1056 Node* locals = state->InputAt(1); |
1055 Node* stack = state->InputAt(2); | 1057 Node* stack = state->InputAt(2); |
1056 Node* context = state->InputAt(3); | 1058 Node* context = state->InputAt(3); |
1057 | 1059 |
1058 DCHECK_EQ(IrOpcode::kStateValues, parameters->op()->opcode()); | 1060 DCHECK_EQ(IrOpcode::kStateValues, parameters->op()->opcode()); |
1059 DCHECK_EQ(IrOpcode::kStateValues, locals->op()->opcode()); | 1061 DCHECK_EQ(IrOpcode::kStateValues, locals->op()->opcode()); |
1060 DCHECK_EQ(IrOpcode::kStateValues, stack->op()->opcode()); | 1062 DCHECK_EQ(IrOpcode::kStateValues, stack->op()->opcode()); |
1061 | 1063 |
1062 DCHECK_EQ(descriptor->parameters_count(), parameters->InputCount()); | 1064 DCHECK_EQ(static_cast<int>(descriptor->parameters_count()), |
1063 DCHECK_EQ(descriptor->locals_count(), locals->InputCount()); | 1065 parameters->InputCount()); |
1064 DCHECK_EQ(descriptor->stack_count(), stack->InputCount()); | 1066 DCHECK_EQ(static_cast<int>(descriptor->locals_count()), locals->InputCount()); |
| 1067 DCHECK_EQ(static_cast<int>(descriptor->stack_count()), stack->InputCount()); |
1065 | 1068 |
1066 OperandGenerator g(this); | 1069 OperandGenerator g(this); |
1067 for (int i = 0; i < static_cast<int>(descriptor->parameters_count()); i++) { | 1070 for (int i = 0; i < static_cast<int>(descriptor->parameters_count()); i++) { |
1068 inputs->push_back(UseOrImmediate(&g, parameters->InputAt(i))); | 1071 inputs->push_back(UseOrImmediate(&g, parameters->InputAt(i))); |
1069 } | 1072 } |
1070 if (descriptor->HasContext()) { | 1073 if (descriptor->HasContext()) { |
1071 inputs->push_back(UseOrImmediate(&g, context)); | 1074 inputs->push_back(UseOrImmediate(&g, context)); |
1072 } | 1075 } |
1073 for (int i = 0; i < static_cast<int>(descriptor->locals_count()); i++) { | 1076 for (int i = 0; i < static_cast<int>(descriptor->locals_count()); i++) { |
1074 inputs->push_back(UseOrImmediate(&g, locals->InputAt(i))); | 1077 inputs->push_back(UseOrImmediate(&g, locals->InputAt(i))); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 | 1120 |
1118 | 1121 |
1119 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, | 1122 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, |
1120 BasicBlock* deoptimization) {} | 1123 BasicBlock* deoptimization) {} |
1121 | 1124 |
1122 #endif // !V8_TURBOFAN_BACKEND | 1125 #endif // !V8_TURBOFAN_BACKEND |
1123 | 1126 |
1124 } // namespace compiler | 1127 } // namespace compiler |
1125 } // namespace internal | 1128 } // namespace internal |
1126 } // namespace v8 | 1129 } // namespace v8 |
OLD | NEW |