| 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.h" | 5 #include "src/compiler/instruction.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 first = false; | 118 first = false; |
| 119 os << *move; | 119 os << *move; |
| 120 } | 120 } |
| 121 return os; | 121 return os; |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 void PointerMap::RecordPointer(InstructionOperand* op, Zone* zone) { | 125 void PointerMap::RecordPointer(InstructionOperand* op, Zone* zone) { |
| 126 // Do not record arguments as pointers. | 126 // Do not record arguments as pointers. |
| 127 if (op->IsStackSlot() && op->index() < 0) return; | 127 if (op->IsStackSlot() && op->index() < 0) return; |
| 128 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 128 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
| 129 pointer_operands_.Add(op, zone); | 129 pointer_operands_.Add(op, zone); |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 void PointerMap::RemovePointer(InstructionOperand* op) { | 133 void PointerMap::RemovePointer(InstructionOperand* op) { |
| 134 // Do not record arguments as pointers. | 134 // Do not record arguments as pointers. |
| 135 if (op->IsStackSlot() && op->index() < 0) return; | 135 if (op->IsStackSlot() && op->index() < 0) return; |
| 136 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 136 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
| 137 for (int i = 0; i < pointer_operands_.length(); ++i) { | 137 for (int i = 0; i < pointer_operands_.length(); ++i) { |
| 138 if (pointer_operands_[i]->Equals(op)) { | 138 if (pointer_operands_[i]->Equals(op)) { |
| 139 pointer_operands_.Remove(i); | 139 pointer_operands_.Remove(i); |
| 140 --i; | 140 --i; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 void PointerMap::RecordUntagged(InstructionOperand* op, Zone* zone) { | 146 void PointerMap::RecordUntagged(InstructionOperand* op, Zone* zone) { |
| 147 // Do not record arguments as pointers. | 147 // Do not record arguments as pointers. |
| 148 if (op->IsStackSlot() && op->index() < 0) return; | 148 if (op->IsStackSlot() && op->index() < 0) return; |
| 149 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 149 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
| 150 untagged_operands_.Add(op, zone); | 150 untagged_operands_.Add(op, zone); |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 OStream& operator<<(OStream& os, const PointerMap& pm) { | 154 OStream& operator<<(OStream& os, const PointerMap& pm) { |
| 155 os << "{"; | 155 os << "{"; |
| 156 for (ZoneList<InstructionOperand*>::iterator op = | 156 for (ZoneList<InstructionOperand*>::iterator op = |
| 157 pm.pointer_operands_.begin(); | 157 pm.pointer_operands_.begin(); |
| 158 op != pm.pointer_operands_.end(); ++op) { | 158 op != pm.pointer_operands_.end(); ++op) { |
| 159 if (op != pm.pointer_operands_.begin()) os << ";"; | 159 if (op != pm.pointer_operands_.begin()) os << ";"; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void InstructionSequence::StartBlock(BasicBlock* block) { | 324 void InstructionSequence::StartBlock(BasicBlock* block) { |
| 325 block->code_start_ = static_cast<int>(instructions_.size()); | 325 block->code_start_ = static_cast<int>(instructions_.size()); |
| 326 BlockStartInstruction* block_start = | 326 BlockStartInstruction* block_start = |
| 327 BlockStartInstruction::New(zone(), block); | 327 BlockStartInstruction::New(zone(), block); |
| 328 AddInstruction(block_start, block); | 328 AddInstruction(block_start, block); |
| 329 } | 329 } |
| 330 | 330 |
| 331 | 331 |
| 332 void InstructionSequence::EndBlock(BasicBlock* block) { | 332 void InstructionSequence::EndBlock(BasicBlock* block) { |
| 333 int end = static_cast<int>(instructions_.size()); | 333 int end = static_cast<int>(instructions_.size()); |
| 334 ASSERT(block->code_start_ >= 0 && block->code_start_ < end); | 334 DCHECK(block->code_start_ >= 0 && block->code_start_ < end); |
| 335 block->code_end_ = end; | 335 block->code_end_ = end; |
| 336 } | 336 } |
| 337 | 337 |
| 338 | 338 |
| 339 int InstructionSequence::AddInstruction(Instruction* instr, BasicBlock* block) { | 339 int InstructionSequence::AddInstruction(Instruction* instr, BasicBlock* block) { |
| 340 // TODO(titzer): the order of these gaps is a holdover from Lithium. | 340 // TODO(titzer): the order of these gaps is a holdover from Lithium. |
| 341 GapInstruction* gap = GapInstruction::New(zone()); | 341 GapInstruction* gap = GapInstruction::New(zone()); |
| 342 if (instr->IsControl()) instructions_.push_back(gap); | 342 if (instr->IsControl()) instructions_.push_back(gap); |
| 343 int index = static_cast<int>(instructions_.size()); | 343 int index = static_cast<int>(instructions_.size()); |
| 344 instructions_.push_back(instr); | 344 instructions_.push_back(instr); |
| 345 if (!instr->IsControl()) instructions_.push_back(gap); | 345 if (!instr->IsControl()) instructions_.push_back(gap); |
| 346 if (instr->NeedsPointerMap()) { | 346 if (instr->NeedsPointerMap()) { |
| 347 ASSERT(instr->pointer_map() == NULL); | 347 DCHECK(instr->pointer_map() == NULL); |
| 348 PointerMap* pointer_map = new (zone()) PointerMap(zone()); | 348 PointerMap* pointer_map = new (zone()) PointerMap(zone()); |
| 349 pointer_map->set_instruction_position(index); | 349 pointer_map->set_instruction_position(index); |
| 350 instr->set_pointer_map(pointer_map); | 350 instr->set_pointer_map(pointer_map); |
| 351 pointer_maps_.push_back(pointer_map); | 351 pointer_maps_.push_back(pointer_map); |
| 352 } | 352 } |
| 353 return index; | 353 return index; |
| 354 } | 354 } |
| 355 | 355 |
| 356 | 356 |
| 357 BasicBlock* InstructionSequence::GetBasicBlock(int instruction_index) { | 357 BasicBlock* InstructionSequence::GetBasicBlock(int instruction_index) { |
| 358 // TODO(turbofan): Optimize this. | 358 // TODO(turbofan): Optimize this. |
| 359 for (;;) { | 359 for (;;) { |
| 360 ASSERT_LE(0, instruction_index); | 360 DCHECK_LE(0, instruction_index); |
| 361 Instruction* instruction = InstructionAt(instruction_index--); | 361 Instruction* instruction = InstructionAt(instruction_index--); |
| 362 if (instruction->IsBlockStart()) { | 362 if (instruction->IsBlockStart()) { |
| 363 return BlockStartInstruction::cast(instruction)->block(); | 363 return BlockStartInstruction::cast(instruction)->block(); |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 | 368 |
| 369 bool InstructionSequence::IsReference(int virtual_register) const { | 369 bool InstructionSequence::IsReference(int virtual_register) const { |
| 370 return references_.find(virtual_register) != references_.end(); | 370 return references_.find(virtual_register) != references_.end(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 os << " B" << (*iter)->id(); | 474 os << " B" << (*iter)->id(); |
| 475 } | 475 } |
| 476 os << "\n"; | 476 os << "\n"; |
| 477 } | 477 } |
| 478 return os; | 478 return os; |
| 479 } | 479 } |
| 480 | 480 |
| 481 } // namespace compiler | 481 } // namespace compiler |
| 482 } // namespace internal | 482 } // namespace internal |
| 483 } // namespace v8 | 483 } // namespace v8 |
| OLD | NEW |