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/raw-machine-assembler.h" | 6 #include "src/compiler/raw-machine-assembler.h" |
7 #include "src/compiler/scheduler.h" | 7 #include "src/compiler/scheduler.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
13 RawMachineAssembler::RawMachineAssembler( | 13 RawMachineAssembler::RawMachineAssembler( |
14 Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder, | 14 Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder, |
15 MachineType word) | 15 MachineType word) |
16 : GraphBuilder(graph), | 16 : GraphBuilder(graph), |
17 schedule_(new (zone()) Schedule(zone())), | 17 schedule_(new (zone()) Schedule(zone())), |
18 machine_(zone(), word), | 18 machine_(zone(), word), |
19 common_(zone()), | 19 common_(zone()), |
20 call_descriptor_builder_(call_descriptor_builder), | 20 call_descriptor_builder_(call_descriptor_builder), |
21 parameters_(NULL), | 21 parameters_(NULL), |
22 exit_label_(schedule()->exit()), | 22 exit_label_(schedule()->end()), |
23 current_block_(schedule()->entry()) { | 23 current_block_(schedule()->start()) { |
24 Node* s = graph->NewNode(common_.Start(parameter_count())); | 24 Node* s = graph->NewNode(common_.Start(parameter_count())); |
25 graph->SetStart(s); | 25 graph->SetStart(s); |
26 if (parameter_count() == 0) return; | 26 if (parameter_count() == 0) return; |
27 parameters_ = zone()->NewArray<Node*>(parameter_count()); | 27 parameters_ = zone()->NewArray<Node*>(parameter_count()); |
28 for (int i = 0; i < parameter_count(); ++i) { | 28 for (int i = 0; i < parameter_count(); ++i) { |
29 parameters_[i] = NewNode(common()->Parameter(i), graph->start()); | 29 parameters_[i] = NewNode(common()->Parameter(i), graph->start()); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 | 33 |
(...skipping 14 matching lines...) Expand all Loading... |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 RawMachineAssembler::Label* RawMachineAssembler::Exit() { | 51 RawMachineAssembler::Label* RawMachineAssembler::Exit() { |
52 exit_label_.used_ = true; | 52 exit_label_.used_ = true; |
53 return &exit_label_; | 53 return &exit_label_; |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 void RawMachineAssembler::Goto(Label* label) { | 57 void RawMachineAssembler::Goto(Label* label) { |
58 DCHECK(current_block_ != schedule()->exit()); | 58 DCHECK(current_block_ != schedule()->end()); |
59 schedule()->AddGoto(CurrentBlock(), Use(label)); | 59 schedule()->AddGoto(CurrentBlock(), Use(label)); |
60 current_block_ = NULL; | 60 current_block_ = NULL; |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 void RawMachineAssembler::Branch(Node* condition, Label* true_val, | 64 void RawMachineAssembler::Branch(Node* condition, Label* true_val, |
65 Label* false_val) { | 65 Label* false_val) { |
66 DCHECK(current_block_ != schedule()->exit()); | 66 DCHECK(current_block_ != schedule()->end()); |
67 Node* branch = NewNode(common()->Branch(), condition); | 67 Node* branch = NewNode(common()->Branch(), condition); |
68 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); | 68 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); |
69 current_block_ = NULL; | 69 current_block_ = NULL; |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 void RawMachineAssembler::Return(Node* value) { | 73 void RawMachineAssembler::Return(Node* value) { |
74 schedule()->AddReturn(CurrentBlock(), value); | 74 schedule()->AddReturn(CurrentBlock(), value); |
75 current_block_ = NULL; | 75 current_block_ = NULL; |
76 } | 76 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 Node* node = graph()->NewNode(op, input_count, inputs); | 149 Node* node = graph()->NewNode(op, input_count, inputs); |
150 BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start() | 150 BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start() |
151 : CurrentBlock(); | 151 : CurrentBlock(); |
152 schedule()->AddNode(block, node); | 152 schedule()->AddNode(block, node); |
153 return node; | 153 return node; |
154 } | 154 } |
155 | 155 |
156 } // namespace compiler | 156 } // namespace compiler |
157 } // namespace internal | 157 } // namespace internal |
158 } // namespace v8 | 158 } // namespace v8 |
OLD | NEW |