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/node.h" | |
11 #include "src/compiler/schedule.h" | |
12 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
13 #include "src/zone.h" | 11 #include "src/zone.h" |
14 | 12 |
15 namespace v8 { | 13 namespace v8 { |
16 namespace internal { | 14 namespace internal { |
17 | 15 |
18 // Forward declarations. | 16 // Forward declarations. |
19 class BitVector; | 17 class BitVector; |
20 class InstructionOperand; | 18 class InstructionOperand; |
21 class UnallocatedOperand; | 19 class UnallocatedOperand; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 private: | 369 private: |
372 void MeetRegisterConstraints(); | 370 void MeetRegisterConstraints(); |
373 void ResolvePhis(); | 371 void ResolvePhis(); |
374 void BuildLiveRanges(); | 372 void BuildLiveRanges(); |
375 void AllocateGeneralRegisters(); | 373 void AllocateGeneralRegisters(); |
376 void AllocateDoubleRegisters(); | 374 void AllocateDoubleRegisters(); |
377 void ConnectRanges(); | 375 void ConnectRanges(); |
378 void ResolveControlFlow(); | 376 void ResolveControlFlow(); |
379 void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps. | 377 void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps. |
380 void AllocateRegisters(); | 378 void AllocateRegisters(); |
381 bool CanEagerlyResolveControlFlow(BasicBlock* block) const; | 379 bool CanEagerlyResolveControlFlow(const InstructionBlock* block) const; |
382 inline bool SafePointsAreInOrder() const; | 380 inline bool SafePointsAreInOrder() const; |
383 | 381 |
384 // Liveness analysis support. | 382 // Liveness analysis support. |
385 void InitializeLivenessAnalysis(); | 383 void InitializeLivenessAnalysis(); |
386 BitVector* ComputeLiveOut(BasicBlock* block); | 384 BitVector* ComputeLiveOut(const InstructionBlock* block); |
387 void AddInitialIntervals(BasicBlock* block, BitVector* live_out); | 385 void AddInitialIntervals(const InstructionBlock* block, BitVector* live_out); |
388 bool IsOutputRegisterOf(Instruction* instr, int index); | 386 bool IsOutputRegisterOf(Instruction* instr, int index); |
389 bool IsOutputDoubleRegisterOf(Instruction* instr, int index); | 387 bool IsOutputDoubleRegisterOf(Instruction* instr, int index); |
390 void ProcessInstructions(BasicBlock* block, BitVector* live); | 388 void ProcessInstructions(const InstructionBlock* block, BitVector* live); |
391 void MeetRegisterConstraints(BasicBlock* block); | 389 void MeetRegisterConstraints(const InstructionBlock* block); |
392 void MeetConstraintsBetween(Instruction* first, Instruction* second, | 390 void MeetConstraintsBetween(Instruction* first, Instruction* second, |
393 int gap_index); | 391 int gap_index); |
394 void MeetRegisterConstraintsForLastInstructionInBlock(BasicBlock* block); | 392 void MeetRegisterConstraintsForLastInstructionInBlock( |
395 void ResolvePhis(BasicBlock* block); | 393 const InstructionBlock* block); |
| 394 void ResolvePhis(const InstructionBlock* block); |
396 | 395 |
397 // Helper methods for building intervals. | 396 // Helper methods for building intervals. |
398 InstructionOperand* AllocateFixed(UnallocatedOperand* operand, int pos, | 397 InstructionOperand* AllocateFixed(UnallocatedOperand* operand, int pos, |
399 bool is_tagged); | 398 bool is_tagged); |
400 LiveRange* LiveRangeFor(InstructionOperand* operand); | 399 LiveRange* LiveRangeFor(InstructionOperand* operand); |
401 void Define(LifetimePosition position, InstructionOperand* operand, | 400 void Define(LifetimePosition position, InstructionOperand* operand, |
402 InstructionOperand* hint); | 401 InstructionOperand* hint); |
403 void Use(LifetimePosition block_start, LifetimePosition position, | 402 void Use(LifetimePosition block_start, LifetimePosition position, |
404 InstructionOperand* operand, InstructionOperand* hint); | 403 InstructionOperand* operand, InstructionOperand* hint); |
405 void AddConstraintsGapMove(int index, InstructionOperand* from, | 404 void AddConstraintsGapMove(int index, InstructionOperand* from, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 458 |
460 // If we are trying to spill a range inside the loop try to | 459 // If we are trying to spill a range inside the loop try to |
461 // hoist spill position out to the point just before the loop. | 460 // hoist spill position out to the point just before the loop. |
462 LifetimePosition FindOptimalSpillingPos(LiveRange* range, | 461 LifetimePosition FindOptimalSpillingPos(LiveRange* range, |
463 LifetimePosition pos); | 462 LifetimePosition pos); |
464 | 463 |
465 void Spill(LiveRange* range); | 464 void Spill(LiveRange* range); |
466 bool IsBlockBoundary(LifetimePosition pos); | 465 bool IsBlockBoundary(LifetimePosition pos); |
467 | 466 |
468 // Helper methods for resolving control flow. | 467 // Helper methods for resolving control flow. |
469 void ResolveControlFlow(LiveRange* range, BasicBlock* block, | 468 void ResolveControlFlow(LiveRange* range, const InstructionBlock* block, |
470 BasicBlock* pred); | 469 const InstructionBlock* pred); |
471 | 470 |
472 inline void SetLiveRangeAssignedRegister(LiveRange* range, int reg); | 471 inline void SetLiveRangeAssignedRegister(LiveRange* range, int reg); |
473 | 472 |
474 // Return parallel move that should be used to connect ranges split at the | 473 // Return parallel move that should be used to connect ranges split at the |
475 // given position. | 474 // given position. |
476 ParallelMove* GetConnectingParallelMove(LifetimePosition pos); | 475 ParallelMove* GetConnectingParallelMove(LifetimePosition pos); |
477 | 476 |
478 // Return the block which contains give lifetime position. | 477 // Return the block which contains give lifetime position. |
479 BasicBlock* GetBlock(LifetimePosition pos); | 478 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); |
480 | 479 |
481 // Helper methods for the fixed registers. | 480 // Helper methods for the fixed registers. |
482 int RegisterCount() const; | 481 int RegisterCount() const; |
483 static int FixedLiveRangeID(int index) { return -index - 1; } | 482 static int FixedLiveRangeID(int index) { return -index - 1; } |
484 static int FixedDoubleLiveRangeID(int index); | 483 static int FixedDoubleLiveRangeID(int index); |
485 LiveRange* FixedLiveRangeFor(int index); | 484 LiveRange* FixedLiveRangeFor(int index); |
486 LiveRange* FixedDoubleLiveRangeFor(int index); | 485 LiveRange* FixedDoubleLiveRangeFor(int index); |
487 LiveRange* LiveRangeFor(int index); | 486 LiveRange* LiveRangeFor(int index); |
488 GapInstruction* GetLastGap(BasicBlock* block); | 487 GapInstruction* GetLastGap(const InstructionBlock* block); |
489 | 488 |
490 const char* RegisterName(int allocation_index); | 489 const char* RegisterName(int allocation_index); |
491 | 490 |
492 inline Instruction* InstructionAt(int index) { | 491 inline Instruction* InstructionAt(int index) { |
493 return code()->InstructionAt(index); | 492 return code()->InstructionAt(index); |
494 } | 493 } |
495 | 494 |
496 Zone zone_; | 495 Zone zone_; |
497 InstructionSequence* code_; | 496 InstructionSequence* code_; |
498 | 497 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 RegisterAllocator* allocator_; | 538 RegisterAllocator* allocator_; |
540 unsigned allocator_zone_start_allocation_size_; | 539 unsigned allocator_zone_start_allocation_size_; |
541 | 540 |
542 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase); | 541 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase); |
543 }; | 542 }; |
544 } | 543 } |
545 } | 544 } |
546 } // namespace v8::internal::compiler | 545 } // namespace v8::internal::compiler |
547 | 546 |
548 #endif // V8_REGISTER_ALLOCATOR_H_ | 547 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |