| 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/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
| 6 #include "src/compiler/scheduler.h" | 6 #include "src/compiler/scheduler.h" |
| 7 #include "test/cctest/compiler/structured-machine-assembler.h" | 7 #include "test/cctest/compiler/structured-machine-assembler.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace compiler { | 11 namespace compiler { |
| 12 | 12 |
| 13 Node* Variable::Get() const { return smasm_->GetVariable(offset_); } | 13 Node* Variable::Get() const { return smasm_->GetVariable(offset_); } |
| 14 | 14 |
| 15 | 15 |
| 16 void Variable::Set(Node* value) const { smasm_->SetVariable(offset_, value); } | 16 void Variable::Set(Node* value) const { smasm_->SetVariable(offset_, value); } |
| 17 | 17 |
| 18 | 18 |
| 19 StructuredMachineAssembler::StructuredMachineAssembler( | 19 StructuredMachineAssembler::StructuredMachineAssembler( |
| 20 Graph* graph, MachineSignature* machine_sig, MachineType word) | 20 Graph* graph, MachineSignature* machine_sig, MachineType word) |
| 21 : GraphBuilder(graph), | 21 : RawMachineAssembler(graph, machine_sig, word), |
| 22 schedule_(new (zone()) Schedule(zone())), | |
| 23 machine_(zone(), word), | |
| 24 common_(zone()), | |
| 25 machine_sig_(machine_sig), | |
| 26 call_descriptor_( | |
| 27 Linkage::GetSimplifiedCDescriptor(graph->zone(), machine_sig)), | |
| 28 parameters_(NULL), | |
| 29 current_environment_(new (zone()) | 22 current_environment_(new (zone()) |
| 30 Environment(zone(), schedule()->start(), false)), | 23 Environment(zone(), schedule()->start(), false)), |
| 31 number_of_variables_(0) { | 24 number_of_variables_(0) {} |
| 32 int param_count = static_cast<int>(parameter_count()); | |
| 33 Node* s = graph->NewNode(common_.Start(param_count)); | |
| 34 graph->SetStart(s); | |
| 35 if (parameter_count() == 0) return; | |
| 36 parameters_ = zone()->NewArray<Node*>(param_count); | |
| 37 for (size_t i = 0; i < parameter_count(); ++i) { | |
| 38 parameters_[i] = | |
| 39 NewNode(common()->Parameter(static_cast<int>(i)), graph->start()); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 | |
| 44 Schedule* StructuredMachineAssembler::Export() { | |
| 45 // Compute the correct codegen order. | |
| 46 DCHECK(schedule_->rpo_order()->empty()); | |
| 47 Scheduler::ComputeSpecialRPO(schedule_); | |
| 48 // Invalidate MachineAssembler. | |
| 49 Schedule* schedule = schedule_; | |
| 50 schedule_ = NULL; | |
| 51 return schedule; | |
| 52 } | |
| 53 | |
| 54 | |
| 55 Node* StructuredMachineAssembler::Parameter(size_t index) { | |
| 56 DCHECK(index < parameter_count()); | |
| 57 return parameters_[index]; | |
| 58 } | |
| 59 | 25 |
| 60 | 26 |
| 61 Node* StructuredMachineAssembler::MakeNode(Operator* op, int input_count, | 27 Node* StructuredMachineAssembler::MakeNode(Operator* op, int input_count, |
| 62 Node** inputs) { | 28 Node** inputs) { |
| 63 DCHECK(ScheduleValid()); | 29 DCHECK(ScheduleValid()); |
| 64 DCHECK(current_environment_ != NULL); | 30 DCHECK(current_environment_ != NULL); |
| 65 Node* node = graph()->NewNode(op, input_count, inputs); | 31 Node* node = graph()->NewNode(op, input_count, inputs); |
| 66 BasicBlock* block = NULL; | 32 BasicBlock* block = NULL; |
| 67 switch (op->opcode()) { | 33 switch (op->opcode()) { |
| 68 case IrOpcode::kParameter: | 34 case IrOpcode::kParameter: |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 621 } |
| 656 pending_header_merges_.clear(); | 622 pending_header_merges_.clear(); |
| 657 pending_exit_merges_.clear(); | 623 pending_exit_merges_.clear(); |
| 658 header_environment_ = NULL; | 624 header_environment_ = NULL; |
| 659 DCHECK(IsDone()); | 625 DCHECK(IsDone()); |
| 660 } | 626 } |
| 661 | 627 |
| 662 } // namespace compiler | 628 } // namespace compiler |
| 663 } // namespace internal | 629 } // namespace internal |
| 664 } // namespace v8 | 630 } // namespace v8 |
| OLD | NEW |