| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 BitVector* bits_; | 424 BitVector* bits_; |
| 425 }; | 425 }; |
| 426 | 426 |
| 427 | 427 |
| 428 class LAllocator BASE_EMBEDDED { | 428 class LAllocator BASE_EMBEDDED { |
| 429 public: | 429 public: |
| 430 LAllocator(int first_virtual_register, HGraph* graph); | 430 LAllocator(int first_virtual_register, HGraph* graph); |
| 431 | 431 |
| 432 static void TraceAlloc(const char* msg, ...); | 432 static void TraceAlloc(const char* msg, ...); |
| 433 | 433 |
| 434 // Lithium translation support. | |
| 435 // Record a use of an input operand in the current instruction. | |
| 436 void RecordUse(HValue* value, LUnallocated* operand); | |
| 437 // Record the definition of the output operand. | |
| 438 void RecordDefinition(HInstruction* instr, LUnallocated* operand); | |
| 439 // Record a temporary operand. | |
| 440 void RecordTemporary(LUnallocated* operand); | |
| 441 | |
| 442 // Checks whether the value of a given virtual register is tagged. | 434 // Checks whether the value of a given virtual register is tagged. |
| 443 bool HasTaggedValue(int virtual_register) const; | 435 bool HasTaggedValue(int virtual_register) const; |
| 444 | 436 |
| 445 // Returns the register kind required by the given virtual register. | 437 // Returns the register kind required by the given virtual register. |
| 446 RegisterKind RequiredRegisterKind(int virtual_register) const; | 438 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 447 | 439 |
| 448 // Control max function size. | 440 bool Allocate(LChunk* chunk); |
| 449 static int max_initial_value_ids(); | |
| 450 | |
| 451 void Allocate(LChunk* chunk); | |
| 452 | 441 |
| 453 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } | 442 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } |
| 454 const Vector<LiveRange*>* fixed_live_ranges() const { | 443 const Vector<LiveRange*>* fixed_live_ranges() const { |
| 455 return &fixed_live_ranges_; | 444 return &fixed_live_ranges_; |
| 456 } | 445 } |
| 457 const Vector<LiveRange*>* fixed_double_live_ranges() const { | 446 const Vector<LiveRange*>* fixed_double_live_ranges() const { |
| 458 return &fixed_double_live_ranges_; | 447 return &fixed_double_live_ranges_; |
| 459 } | 448 } |
| 460 | 449 |
| 461 LChunk* chunk() const { return chunk_; } | 450 LChunk* chunk() const { return chunk_; } |
| 462 HGraph* graph() const { return graph_; } | 451 HGraph* graph() const { return graph_; } |
| 463 | 452 |
| 453 int GetVirtualRegister() { |
| 454 if (next_virtual_register_ > LUnallocated::kMaxVirtualRegisters) { |
| 455 allocation_ok_ = false; |
| 456 } |
| 457 return next_virtual_register_++; |
| 458 } |
| 459 |
| 460 bool AllocationOk() { return allocation_ok_; } |
| 461 |
| 464 void MarkAsOsrEntry() { | 462 void MarkAsOsrEntry() { |
| 465 // There can be only one. | 463 // There can be only one. |
| 466 ASSERT(!has_osr_entry_); | 464 ASSERT(!has_osr_entry_); |
| 467 // Simply set a flag to find and process instruction later. | 465 // Simply set a flag to find and process instruction later. |
| 468 has_osr_entry_ = true; | 466 has_osr_entry_ = true; |
| 469 } | 467 } |
| 470 | 468 |
| 471 #ifdef DEBUG | 469 #ifdef DEBUG |
| 472 void Verify() const; | 470 void Verify() const; |
| 473 #endif | 471 #endif |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 void AllocateBlockedReg(LiveRange* range); | 524 void AllocateBlockedReg(LiveRange* range); |
| 527 | 525 |
| 528 // Live range splitting helpers. | 526 // Live range splitting helpers. |
| 529 | 527 |
| 530 // Split the given range at the given position. | 528 // Split the given range at the given position. |
| 531 // If range starts at or after the given position then the | 529 // If range starts at or after the given position then the |
| 532 // original range is returned. | 530 // original range is returned. |
| 533 // Otherwise returns the live range that starts at pos and contains | 531 // Otherwise returns the live range that starts at pos and contains |
| 534 // all uses from the original range that follow pos. Uses at pos will | 532 // all uses from the original range that follow pos. Uses at pos will |
| 535 // still be owned by the original range after splitting. | 533 // still be owned by the original range after splitting. |
| 536 LiveRange* SplitAt(LiveRange* range, LifetimePosition pos); | 534 LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); |
| 537 | 535 |
| 538 // Split the given range in a position from the interval [start, end]. | 536 // Split the given range in a position from the interval [start, end]. |
| 539 LiveRange* SplitBetween(LiveRange* range, | 537 LiveRange* SplitBetween(LiveRange* range, |
| 540 LifetimePosition start, | 538 LifetimePosition start, |
| 541 LifetimePosition end); | 539 LifetimePosition end); |
| 542 | 540 |
| 543 // Find a lifetime position in the interval [start, end] which | 541 // Find a lifetime position in the interval [start, end] which |
| 544 // is optimal for splitting: it is either header of the outermost | 542 // is optimal for splitting: it is either header of the outermost |
| 545 // loop covered by this interval or the latest possible position. | 543 // loop covered by this interval or the latest possible position. |
| 546 LifetimePosition FindOptimalSplitPos(LifetimePosition start, | 544 LifetimePosition FindOptimalSplitPos(LifetimePosition start, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 const char* RegisterName(int allocation_index); | 582 const char* RegisterName(int allocation_index); |
| 585 | 583 |
| 586 inline bool IsGapAt(int index); | 584 inline bool IsGapAt(int index); |
| 587 | 585 |
| 588 inline LInstruction* InstructionAt(int index); | 586 inline LInstruction* InstructionAt(int index); |
| 589 | 587 |
| 590 inline LGap* GapAt(int index); | 588 inline LGap* GapAt(int index); |
| 591 | 589 |
| 592 LChunk* chunk_; | 590 LChunk* chunk_; |
| 593 | 591 |
| 592 // Indicates success or failure during register allocation. |
| 593 bool allocation_ok_; |
| 594 |
| 594 // During liveness analysis keep a mapping from block id to live_in sets | 595 // During liveness analysis keep a mapping from block id to live_in sets |
| 595 // for blocks already analyzed. | 596 // for blocks already analyzed. |
| 596 ZoneList<BitVector*> live_in_sets_; | 597 ZoneList<BitVector*> live_in_sets_; |
| 597 | 598 |
| 598 // Liveness analysis results. | 599 // Liveness analysis results. |
| 599 ZoneList<LiveRange*> live_ranges_; | 600 ZoneList<LiveRange*> live_ranges_; |
| 600 | 601 |
| 601 // Lists of live ranges | 602 // Lists of live ranges |
| 602 EmbeddedVector<LiveRange*, Register::kNumAllocatableRegisters> | 603 EmbeddedVector<LiveRange*, Register::kNumAllocatableRegisters> |
| 603 fixed_live_ranges_; | 604 fixed_live_ranges_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 620 | 621 |
| 621 bool has_osr_entry_; | 622 bool has_osr_entry_; |
| 622 | 623 |
| 623 DISALLOW_COPY_AND_ASSIGN(LAllocator); | 624 DISALLOW_COPY_AND_ASSIGN(LAllocator); |
| 624 }; | 625 }; |
| 625 | 626 |
| 626 | 627 |
| 627 } } // namespace v8::internal | 628 } } // namespace v8::internal |
| 628 | 629 |
| 629 #endif // V8_LITHIUM_ALLOCATOR_H_ | 630 #endif // V8_LITHIUM_ALLOCATOR_H_ |
| OLD | NEW |