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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // TODO(bmeurer): Get rid of the CallBuffer business and make | 274 // TODO(bmeurer): Get rid of the CallBuffer business and make |
275 // InstructionSelector::VisitCall platform independent instead. | 275 // InstructionSelector::VisitCall platform independent instead. |
276 void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, | 276 void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
277 bool call_code_immediate, | 277 bool call_code_immediate, |
278 bool call_address_immediate) { | 278 bool call_address_immediate) { |
279 OperandGenerator g(this); | 279 OperandGenerator g(this); |
280 DCHECK_LE(call->op()->ValueOutputCount(), | 280 DCHECK_LE(call->op()->ValueOutputCount(), |
281 static_cast<int>(buffer->descriptor->ReturnCount())); | 281 static_cast<int>(buffer->descriptor->ReturnCount())); |
282 DCHECK_EQ( | 282 DCHECK_EQ( |
283 call->op()->ValueInputCount(), | 283 call->op()->ValueInputCount(), |
284 static_cast<int>(buffer->input_count() + buffer->frame_state_count())); | 284 static_cast<int>(buffer->input_count() + buffer->frame_state_count() + |
| 285 buffer->non_argument_input_count())); |
285 | 286 |
286 if (buffer->descriptor->ReturnCount() > 0) { | 287 if (buffer->descriptor->ReturnCount() > 0) { |
287 // Collect the projections that represent multiple outputs from this call. | 288 // Collect the projections that represent multiple outputs from this call. |
288 if (buffer->descriptor->ReturnCount() == 1) { | 289 if (buffer->descriptor->ReturnCount() == 1) { |
289 buffer->output_nodes.push_back(call); | 290 buffer->output_nodes.push_back(call); |
290 } else { | 291 } else { |
291 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), nullptr); | 292 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), nullptr); |
292 for (auto use : call->uses()) { | 293 for (auto use : call->uses()) { |
293 if (use->opcode() != IrOpcode::kProjection) continue; | 294 if (use->opcode() != IrOpcode::kProjection) continue; |
294 size_t const index = ProjectionIndexOf(use->op()); | 295 size_t const index = ProjectionIndexOf(use->op()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 // Generate code for this node "top down", but schedule the code "bottom | 417 // Generate code for this node "top down", but schedule the code "bottom |
417 // up". | 418 // up". |
418 size_t current_node_end = instructions_.size(); | 419 size_t current_node_end = instructions_.size(); |
419 VisitNode(node); | 420 VisitNode(node); |
420 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); | 421 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); |
421 if (instructions_.size() == current_node_end) continue; | 422 if (instructions_.size() == current_node_end) continue; |
422 // Mark source position on first instruction emitted. | 423 // Mark source position on first instruction emitted. |
423 SourcePosition source_position = source_positions_->GetSourcePosition(node); | 424 SourcePosition source_position = source_positions_->GetSourcePosition(node); |
424 if (source_position.IsKnown() && | 425 if (source_position.IsKnown() && |
425 (source_position_mode_ == kAllSourcePositions || | 426 (source_position_mode_ == kAllSourcePositions || |
426 node->opcode() == IrOpcode::kCall)) { | 427 node->opcode() == IrOpcode::kCall || |
| 428 node->opcode() == IrOpcode::kCallVarArgs)) { |
427 sequence()->SetSourcePosition(instructions_[current_node_end], | 429 sequence()->SetSourcePosition(instructions_[current_node_end], |
428 source_position); | 430 source_position); |
429 } | 431 } |
430 } | 432 } |
431 | 433 |
432 // We're done with the block. | 434 // We're done with the block. |
433 InstructionBlock* instruction_block = | 435 InstructionBlock* instruction_block = |
434 sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number())); | 436 sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number())); |
435 instruction_block->set_code_start(static_cast<int>(instructions_.size())); | 437 instruction_block->set_code_start(static_cast<int>(instructions_.size())); |
436 instruction_block->set_code_end(current_block_end); | 438 instruction_block->set_code_end(current_block_end); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 return MarkAsFloat64(node), VisitConstant(node); | 578 return MarkAsFloat64(node), VisitConstant(node); |
577 case IrOpcode::kHeapConstant: | 579 case IrOpcode::kHeapConstant: |
578 return MarkAsReference(node), VisitConstant(node); | 580 return MarkAsReference(node), VisitConstant(node); |
579 case IrOpcode::kNumberConstant: { | 581 case IrOpcode::kNumberConstant: { |
580 double value = OpParameter<double>(node); | 582 double value = OpParameter<double>(node); |
581 if (!IsSmiDouble(value)) MarkAsReference(node); | 583 if (!IsSmiDouble(value)) MarkAsReference(node); |
582 return VisitConstant(node); | 584 return VisitConstant(node); |
583 } | 585 } |
584 case IrOpcode::kCall: | 586 case IrOpcode::kCall: |
585 return VisitCall(node); | 587 return VisitCall(node); |
| 588 case IrOpcode::kCallVarArgs: |
| 589 return VisitCallVarArgs(node); |
586 case IrOpcode::kFrameState: | 590 case IrOpcode::kFrameState: |
587 case IrOpcode::kStateValues: | 591 case IrOpcode::kStateValues: |
588 return; | 592 return; |
589 case IrOpcode::kLoad: { | 593 case IrOpcode::kLoad: { |
590 LoadRepresentation rep = OpParameter<LoadRepresentation>(node); | 594 LoadRepresentation rep = OpParameter<LoadRepresentation>(node); |
591 MarkAsRepresentation(rep, node); | 595 MarkAsRepresentation(rep, node); |
592 return VisitLoad(node); | 596 return VisitLoad(node); |
593 } | 597 } |
594 case IrOpcode::kStore: | 598 case IrOpcode::kStore: |
595 return VisitStore(node); | 599 return VisitStore(node); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { | 1130 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { |
1127 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); | 1131 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); |
1128 descriptor->SetType(value_index++, input_node.type); | 1132 descriptor->SetType(value_index++, input_node.type); |
1129 } | 1133 } |
1130 DCHECK(value_index == descriptor->GetSize()); | 1134 DCHECK(value_index == descriptor->GetSize()); |
1131 } | 1135 } |
1132 | 1136 |
1133 } // namespace compiler | 1137 } // namespace compiler |
1134 } // namespace internal | 1138 } // namespace internal |
1135 } // namespace v8 | 1139 } // namespace v8 |
OLD | NEW |