| 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/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 InstructionOperand* current_hint_operand_; | 310 InstructionOperand* current_hint_operand_; |
| 311 InstructionOperand* spill_operand_; | 311 InstructionOperand* spill_operand_; |
| 312 int spill_start_index_; | 312 int spill_start_index_; |
| 313 | 313 |
| 314 friend class RegisterAllocator; // Assigns to kind_. | 314 friend class RegisterAllocator; // Assigns to kind_. |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 | 317 |
| 318 class RegisterAllocator BASE_EMBEDDED { | 318 class RegisterAllocator BASE_EMBEDDED { |
| 319 public: | 319 public: |
| 320 explicit RegisterAllocator(InstructionSequence* code); | 320 // TODO(dcarney): remove info |
| 321 explicit RegisterAllocator(Frame* frame, CompilationInfo* info, |
| 322 InstructionSequence* code); |
| 321 | 323 |
| 322 static void TraceAlloc(const char* msg, ...); | 324 static void TraceAlloc(const char* msg, ...); |
| 323 | 325 |
| 324 // Checks whether the value of a given virtual register is a reference. | 326 // Checks whether the value of a given virtual register is a reference. |
| 325 // TODO(titzer): rename this to IsReference. | 327 // TODO(titzer): rename this to IsReference. |
| 326 bool HasTaggedValue(int virtual_register) const; | 328 bool HasTaggedValue(int virtual_register) const; |
| 327 | 329 |
| 328 // Returns the register kind required by the given virtual register. | 330 // Returns the register kind required by the given virtual register. |
| 329 RegisterKind RequiredRegisterKind(int virtual_register) const; | 331 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 330 | 332 |
| 331 bool Allocate(); | 333 bool Allocate(); |
| 332 | 334 |
| 333 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } | 335 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } |
| 334 const Vector<LiveRange*>* fixed_live_ranges() const { | 336 const Vector<LiveRange*>* fixed_live_ranges() const { |
| 335 return &fixed_live_ranges_; | 337 return &fixed_live_ranges_; |
| 336 } | 338 } |
| 337 const Vector<LiveRange*>* fixed_double_live_ranges() const { | 339 const Vector<LiveRange*>* fixed_double_live_ranges() const { |
| 338 return &fixed_double_live_ranges_; | 340 return &fixed_double_live_ranges_; |
| 339 } | 341 } |
| 340 | 342 |
| 343 CompilationInfo* info() const { return info_; } |
| 341 inline InstructionSequence* code() const { return code_; } | 344 inline InstructionSequence* code() const { return code_; } |
| 342 | 345 |
| 343 // This zone is for datastructures only needed during register allocation. | 346 // This zone is for datastructures only needed during register allocation. |
| 344 inline Zone* zone() { return &zone_; } | 347 inline Zone* zone() { return &zone_; } |
| 345 | 348 |
| 346 // This zone is for InstructionOperands and moves that live beyond register | 349 // This zone is for InstructionOperands and moves that live beyond register |
| 347 // allocation. | 350 // allocation. |
| 348 inline Zone* code_zone() { return code()->zone(); } | 351 inline Zone* code_zone() { return code()->zone(); } |
| 349 | 352 |
| 350 int GetVirtualRegister() { | 353 int GetVirtualRegister() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 LiveRange* FixedDoubleLiveRangeFor(int index); | 488 LiveRange* FixedDoubleLiveRangeFor(int index); |
| 486 LiveRange* LiveRangeFor(int index); | 489 LiveRange* LiveRangeFor(int index); |
| 487 GapInstruction* GetLastGap(const InstructionBlock* block); | 490 GapInstruction* GetLastGap(const InstructionBlock* block); |
| 488 | 491 |
| 489 const char* RegisterName(int allocation_index); | 492 const char* RegisterName(int allocation_index); |
| 490 | 493 |
| 491 inline Instruction* InstructionAt(int index) { | 494 inline Instruction* InstructionAt(int index) { |
| 492 return code()->InstructionAt(index); | 495 return code()->InstructionAt(index); |
| 493 } | 496 } |
| 494 | 497 |
| 498 Frame* frame() const { return frame_; } |
| 499 |
| 495 Zone zone_; | 500 Zone zone_; |
| 496 InstructionSequence* code_; | 501 Frame* const frame_; |
| 502 CompilationInfo* const info_; |
| 503 InstructionSequence* const code_; |
| 497 | 504 |
| 498 // During liveness analysis keep a mapping from block id to live_in sets | 505 // During liveness analysis keep a mapping from block id to live_in sets |
| 499 // for blocks already analyzed. | 506 // for blocks already analyzed. |
| 500 ZoneList<BitVector*> live_in_sets_; | 507 ZoneList<BitVector*> live_in_sets_; |
| 501 | 508 |
| 502 // Liveness analysis results. | 509 // Liveness analysis results. |
| 503 ZoneList<LiveRange*> live_ranges_; | 510 ZoneList<LiveRange*> live_ranges_; |
| 504 | 511 |
| 505 // Lists of live ranges | 512 // Lists of live ranges |
| 506 EmbeddedVector<LiveRange*, Register::kMaxNumAllocatableRegisters> | 513 EmbeddedVector<LiveRange*, Register::kMaxNumAllocatableRegisters> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 RegisterAllocator* allocator_; | 545 RegisterAllocator* allocator_; |
| 539 unsigned allocator_zone_start_allocation_size_; | 546 unsigned allocator_zone_start_allocation_size_; |
| 540 | 547 |
| 541 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase); | 548 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase); |
| 542 }; | 549 }; |
| 543 } | 550 } |
| 544 } | 551 } |
| 545 } // namespace v8::internal::compiler | 552 } // namespace v8::internal::compiler |
| 546 | 553 |
| 547 #endif // V8_REGISTER_ALLOCATOR_H_ | 554 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |