| 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 #ifndef V8_REGISTER_ALLOCATOR_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_H_ |
| 6 #define V8_REGISTER_ALLOCATOR_H_ | 6 #define V8_REGISTER_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/compiler/instruction.h" | 9 #include "src/compiler/instruction.h" |
| 10 #include "src/compiler/zone-pool.h" | 10 #include "src/compiler/zone-pool.h" |
| 11 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
| 12 #include "src/zone.h" | 12 #include "src/zone.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 // Forward declarations. | 17 // Forward declarations. |
| 18 class BitVector; | 18 class BitVector; |
| 19 class InstructionOperand; | 19 class InstructionOperand; |
| 20 class UnallocatedOperand; | 20 class UnallocatedOperand; |
| 21 class ParallelMove; | 21 class ParallelMove; |
| 22 class PointerMap; | 22 class PointerMap; |
| 23 | 23 |
| 24 namespace compiler { | 24 namespace compiler { |
| 25 | 25 |
| 26 class PipelineStatistics; |
| 27 |
| 26 enum RegisterKind { | 28 enum RegisterKind { |
| 27 UNALLOCATED_REGISTERS, | 29 UNALLOCATED_REGISTERS, |
| 28 GENERAL_REGISTERS, | 30 GENERAL_REGISTERS, |
| 29 DOUBLE_REGISTERS | 31 DOUBLE_REGISTERS |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 | 34 |
| 33 // This class represents a single point of a InstructionOperand's lifetime. For | 35 // This class represents a single point of a InstructionOperand's lifetime. For |
| 34 // each instruction there are exactly two lifetime positions: the beginning and | 36 // each instruction there are exactly two lifetime positions: the beginning and |
| 35 // the end of the instruction. Lifetime positions for different instructions are | 37 // the end of the instruction. Lifetime positions for different instructions are |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 326 |
| 325 static void TraceAlloc(const char* msg, ...); | 327 static void TraceAlloc(const char* msg, ...); |
| 326 | 328 |
| 327 // Checks whether the value of a given virtual register is a reference. | 329 // Checks whether the value of a given virtual register is a reference. |
| 328 // TODO(titzer): rename this to IsReference. | 330 // TODO(titzer): rename this to IsReference. |
| 329 bool HasTaggedValue(int virtual_register) const; | 331 bool HasTaggedValue(int virtual_register) const; |
| 330 | 332 |
| 331 // Returns the register kind required by the given virtual register. | 333 // Returns the register kind required by the given virtual register. |
| 332 RegisterKind RequiredRegisterKind(int virtual_register) const; | 334 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 333 | 335 |
| 334 // TODO(dcarney): fix compilation phase stats to not require this. | 336 bool Allocate(PipelineStatistics* stats = NULL); |
| 335 bool Allocate(ZonePool* zone_pool = NULL); | |
| 336 | 337 |
| 337 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } | 338 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } |
| 338 const Vector<LiveRange*>* fixed_live_ranges() const { | 339 const Vector<LiveRange*>* fixed_live_ranges() const { |
| 339 return &fixed_live_ranges_; | 340 return &fixed_live_ranges_; |
| 340 } | 341 } |
| 341 const Vector<LiveRange*>* fixed_double_live_ranges() const { | 342 const Vector<LiveRange*>* fixed_double_live_ranges() const { |
| 342 return &fixed_double_live_ranges_; | 343 return &fixed_double_live_ranges_; |
| 343 } | 344 } |
| 344 | 345 |
| 345 CompilationInfo* info() const { return info_; } | 346 CompilationInfo* info() const { return info_; } |
| 346 inline InstructionSequence* code() const { return code_; } | 347 inline InstructionSequence* code() const { return code_; } |
| 347 ZonePool* zone_pool() const { return zone_pool_; } | |
| 348 | 348 |
| 349 // This zone is for datastructures only needed during register allocation. | 349 // This zone is for datastructures only needed during register allocation. |
| 350 inline Zone* zone() const { return zone_; } | 350 inline Zone* zone() const { return zone_; } |
| 351 | 351 |
| 352 // This zone is for InstructionOperands and moves that live beyond register | 352 // This zone is for InstructionOperands and moves that live beyond register |
| 353 // allocation. | 353 // allocation. |
| 354 inline Zone* code_zone() const { return code()->zone(); } | 354 inline Zone* code_zone() const { return code()->zone(); } |
| 355 | 355 |
| 356 int GetVirtualRegister() { | 356 int GetVirtualRegister() { |
| 357 int vreg = code()->NextVirtualRegister(); | 357 int vreg = code()->NextVirtualRegister(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 const char* RegisterName(int allocation_index); | 495 const char* RegisterName(int allocation_index); |
| 496 | 496 |
| 497 inline Instruction* InstructionAt(int index) { | 497 inline Instruction* InstructionAt(int index) { |
| 498 return code()->InstructionAt(index); | 498 return code()->InstructionAt(index); |
| 499 } | 499 } |
| 500 | 500 |
| 501 Frame* frame() const { return frame_; } | 501 Frame* frame() const { return frame_; } |
| 502 | 502 |
| 503 Zone* const zone_; | 503 Zone* const zone_; |
| 504 // TODO(dcarney): remove this. | |
| 505 ZonePool* zone_pool_; | |
| 506 Frame* const frame_; | 504 Frame* const frame_; |
| 507 CompilationInfo* const info_; | 505 CompilationInfo* const info_; |
| 508 InstructionSequence* const code_; | 506 InstructionSequence* const code_; |
| 509 | 507 |
| 510 // During liveness analysis keep a mapping from block id to live_in sets | 508 // During liveness analysis keep a mapping from block id to live_in sets |
| 511 // for blocks already analyzed. | 509 // for blocks already analyzed. |
| 512 ZoneList<BitVector*> live_in_sets_; | 510 ZoneList<BitVector*> live_in_sets_; |
| 513 | 511 |
| 514 // Liveness analysis results. | 512 // Liveness analysis results. |
| 515 ZoneList<LiveRange*> live_ranges_; | 513 ZoneList<LiveRange*> live_ranges_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 538 #endif | 536 #endif |
| 539 | 537 |
| 540 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 538 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
| 541 }; | 539 }; |
| 542 | 540 |
| 543 } | 541 } |
| 544 } | 542 } |
| 545 } // namespace v8::internal::compiler | 543 } // namespace v8::internal::compiler |
| 546 | 544 |
| 547 #endif // V8_REGISTER_ALLOCATOR_H_ | 545 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |