| 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 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if (parameter_count() == 0) return; | 24 if (parameter_count() == 0) return; |
| 25 parameters_ = zone()->NewArray<Node*>(parameter_count()); | 25 parameters_ = zone()->NewArray<Node*>(parameter_count()); |
| 26 for (int i = 0; i < parameter_count(); ++i) { | 26 for (int i = 0; i < parameter_count(); ++i) { |
| 27 parameters_[i] = NewNode(common()->Parameter(i)); | 27 parameters_[i] = NewNode(common()->Parameter(i)); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 | 31 |
| 32 Schedule* RawMachineAssembler::Export() { | 32 Schedule* RawMachineAssembler::Export() { |
| 33 // Compute the correct codegen order. | 33 // Compute the correct codegen order. |
| 34 ASSERT(schedule_->rpo_order()->empty()); | 34 DCHECK(schedule_->rpo_order()->empty()); |
| 35 Scheduler scheduler(zone(), graph(), schedule_); | 35 Scheduler scheduler(zone(), graph(), schedule_); |
| 36 scheduler.ComputeSpecialRPO(); | 36 scheduler.ComputeSpecialRPO(); |
| 37 // Invalidate MachineAssembler. | 37 // Invalidate MachineAssembler. |
| 38 Schedule* schedule = schedule_; | 38 Schedule* schedule = schedule_; |
| 39 schedule_ = NULL; | 39 schedule_ = NULL; |
| 40 return schedule; | 40 return schedule; |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 Node* RawMachineAssembler::Parameter(int index) { | 44 Node* RawMachineAssembler::Parameter(int index) { |
| 45 ASSERT(0 <= index && index < parameter_count()); | 45 DCHECK(0 <= index && index < parameter_count()); |
| 46 return parameters_[index]; | 46 return parameters_[index]; |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 RawMachineAssembler::Label* RawMachineAssembler::Exit() { | 50 RawMachineAssembler::Label* RawMachineAssembler::Exit() { |
| 51 exit_label_.used_ = true; | 51 exit_label_.used_ = true; |
| 52 return &exit_label_; | 52 return &exit_label_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 void RawMachineAssembler::Goto(Label* label) { | 56 void RawMachineAssembler::Goto(Label* label) { |
| 57 ASSERT(current_block_ != schedule()->exit()); | 57 DCHECK(current_block_ != schedule()->exit()); |
| 58 schedule()->AddGoto(CurrentBlock(), Use(label)); | 58 schedule()->AddGoto(CurrentBlock(), Use(label)); |
| 59 current_block_ = NULL; | 59 current_block_ = NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 void RawMachineAssembler::Branch(Node* condition, Label* true_val, | 63 void RawMachineAssembler::Branch(Node* condition, Label* true_val, |
| 64 Label* false_val) { | 64 Label* false_val) { |
| 65 ASSERT(current_block_ != schedule()->exit()); | 65 DCHECK(current_block_ != schedule()->exit()); |
| 66 Node* branch = NewNode(common()->Branch(), condition); | 66 Node* branch = NewNode(common()->Branch(), condition); |
| 67 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); | 67 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); |
| 68 current_block_ = NULL; | 68 current_block_ = NULL; |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 void RawMachineAssembler::Return(Node* value) { | 72 void RawMachineAssembler::Return(Node* value) { |
| 73 schedule()->AddReturn(CurrentBlock(), value); | 73 schedule()->AddReturn(CurrentBlock(), value); |
| 74 current_block_ = NULL; | 74 current_block_ = NULL; |
| 75 } | 75 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 Node* call = graph()->NewNode(common()->Call(descriptor), centry, arg0, ref, | 109 Node* call = graph()->NewNode(common()->Call(descriptor), centry, arg0, ref, |
| 110 arity, context); | 110 arity, context); |
| 111 schedule()->AddCall(CurrentBlock(), call, Use(continuation), | 111 schedule()->AddCall(CurrentBlock(), call, Use(continuation), |
| 112 Use(deoptimization)); | 112 Use(deoptimization)); |
| 113 current_block_ = NULL; | 113 current_block_ = NULL; |
| 114 return call; | 114 return call; |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 void RawMachineAssembler::Bind(Label* label) { | 118 void RawMachineAssembler::Bind(Label* label) { |
| 119 ASSERT(current_block_ == NULL); | 119 DCHECK(current_block_ == NULL); |
| 120 ASSERT(!label->bound_); | 120 DCHECK(!label->bound_); |
| 121 label->bound_ = true; | 121 label->bound_ = true; |
| 122 current_block_ = EnsureBlock(label); | 122 current_block_ = EnsureBlock(label); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 BasicBlock* RawMachineAssembler::Use(Label* label) { | 126 BasicBlock* RawMachineAssembler::Use(Label* label) { |
| 127 label->used_ = true; | 127 label->used_ = true; |
| 128 return EnsureBlock(label); | 128 return EnsureBlock(label); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 BasicBlock* RawMachineAssembler::EnsureBlock(Label* label) { | 132 BasicBlock* RawMachineAssembler::EnsureBlock(Label* label) { |
| 133 if (label->block_ == NULL) label->block_ = schedule()->NewBasicBlock(); | 133 if (label->block_ == NULL) label->block_ = schedule()->NewBasicBlock(); |
| 134 return label->block_; | 134 return label->block_; |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 BasicBlock* RawMachineAssembler::CurrentBlock() { | 138 BasicBlock* RawMachineAssembler::CurrentBlock() { |
| 139 ASSERT(current_block_); | 139 DCHECK(current_block_); |
| 140 return current_block_; | 140 return current_block_; |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 Node* RawMachineAssembler::MakeNode(Operator* op, int input_count, | 144 Node* RawMachineAssembler::MakeNode(Operator* op, int input_count, |
| 145 Node** inputs) { | 145 Node** inputs) { |
| 146 ASSERT(ScheduleValid()); | 146 DCHECK(ScheduleValid()); |
| 147 ASSERT(current_block_ != NULL); | 147 DCHECK(current_block_ != NULL); |
| 148 Node* node = graph()->NewNode(op, input_count, inputs); | 148 Node* node = graph()->NewNode(op, input_count, inputs); |
| 149 BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start() | 149 BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start() |
| 150 : CurrentBlock(); | 150 : CurrentBlock(); |
| 151 schedule()->AddNode(block, node); | 151 schedule()->AddNode(block, node); |
| 152 return node; | 152 return node; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace compiler | 155 } // namespace compiler |
| 156 } // namespace internal | 156 } // namespace internal |
| 157 } // namespace v8 | 157 } // namespace v8 |
| OLD | NEW |