OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (a == NULL || a->start().Value() > other->End().Value()) break; | 518 if (a == NULL || a->start().Value() > other->End().Value()) break; |
519 AdvanceLastProcessedMarker(a, advance_last_processed_up_to); | 519 AdvanceLastProcessedMarker(a, advance_last_processed_up_to); |
520 } else { | 520 } else { |
521 b = b->next(); | 521 b = b->next(); |
522 } | 522 } |
523 } | 523 } |
524 return LifetimePosition::Invalid(); | 524 return LifetimePosition::Invalid(); |
525 } | 525 } |
526 | 526 |
527 | 527 |
| 528 LAllocator::LAllocator(int num_values, HGraph* graph) |
| 529 : chunk_(NULL), |
| 530 live_in_sets_(graph->blocks()->length()), |
| 531 live_ranges_(num_values * 2), |
| 532 fixed_live_ranges_(NULL), |
| 533 fixed_double_live_ranges_(NULL), |
| 534 unhandled_live_ranges_(num_values * 2), |
| 535 active_live_ranges_(8), |
| 536 inactive_live_ranges_(8), |
| 537 reusable_slots_(8), |
| 538 next_virtual_register_(num_values), |
| 539 first_artificial_register_(num_values), |
| 540 mode_(NONE), |
| 541 num_registers_(-1), |
| 542 graph_(graph), |
| 543 has_osr_entry_(false) {} |
| 544 |
| 545 |
528 void LAllocator::InitializeLivenessAnalysis() { | 546 void LAllocator::InitializeLivenessAnalysis() { |
529 // Initialize the live_in sets for each block to NULL. | 547 // Initialize the live_in sets for each block to NULL. |
530 int block_count = graph_->blocks()->length(); | 548 int block_count = graph_->blocks()->length(); |
531 live_in_sets_.Initialize(block_count); | 549 live_in_sets_.Initialize(block_count); |
532 live_in_sets_.AddBlock(NULL, block_count); | 550 live_in_sets_.AddBlock(NULL, block_count); |
533 } | 551 } |
534 | 552 |
535 | 553 |
536 BitVector* LAllocator::ComputeLiveOut(HBasicBlock* block) { | 554 BitVector* LAllocator::ComputeLiveOut(HBasicBlock* block) { |
537 // Compute live out for the given block, except not including backward | 555 // Compute live out for the given block, except not including backward |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 LInstruction* instr = InstructionAt(pos); | 629 LInstruction* instr = InstructionAt(pos); |
612 if (instr->HasPointerMap()) { | 630 if (instr->HasPointerMap()) { |
613 instr->pointer_map()->RecordPointer(operand); | 631 instr->pointer_map()->RecordPointer(operand); |
614 } | 632 } |
615 } | 633 } |
616 return operand; | 634 return operand; |
617 } | 635 } |
618 | 636 |
619 | 637 |
620 LiveRange* LAllocator::FixedLiveRangeFor(int index) { | 638 LiveRange* LAllocator::FixedLiveRangeFor(int index) { |
621 if (index >= fixed_live_ranges_.length()) { | 639 ASSERT(index < Register::kNumAllocatableRegisters); |
622 fixed_live_ranges_.AddBlock(NULL, | |
623 index - fixed_live_ranges_.length() + 1); | |
624 } | |
625 | |
626 LiveRange* result = fixed_live_ranges_[index]; | 640 LiveRange* result = fixed_live_ranges_[index]; |
627 if (result == NULL) { | 641 if (result == NULL) { |
628 result = new LiveRange(FixedLiveRangeID(index)); | 642 result = new LiveRange(FixedLiveRangeID(index)); |
629 ASSERT(result->IsFixed()); | 643 ASSERT(result->IsFixed()); |
630 result->set_assigned_register(index, GENERAL_REGISTERS); | 644 result->set_assigned_register(index, GENERAL_REGISTERS); |
631 fixed_live_ranges_[index] = result; | 645 fixed_live_ranges_[index] = result; |
632 } | 646 } |
633 return result; | 647 return result; |
634 } | 648 } |
635 | 649 |
636 | 650 |
637 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) { | 651 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) { |
638 if (index >= fixed_double_live_ranges_.length()) { | 652 ASSERT(index < DoubleRegister::kNumAllocatableRegisters); |
639 fixed_double_live_ranges_.AddBlock(NULL, | |
640 index - fixed_double_live_ranges_.length() + 1); | |
641 } | |
642 | |
643 LiveRange* result = fixed_double_live_ranges_[index]; | 653 LiveRange* result = fixed_double_live_ranges_[index]; |
644 if (result == NULL) { | 654 if (result == NULL) { |
645 result = new LiveRange(FixedDoubleLiveRangeID(index)); | 655 result = new LiveRange(FixedDoubleLiveRangeID(index)); |
646 ASSERT(result->IsFixed()); | 656 ASSERT(result->IsFixed()); |
647 result->set_assigned_register(index, DOUBLE_REGISTERS); | 657 result->set_assigned_register(index, DOUBLE_REGISTERS); |
648 fixed_double_live_ranges_[index] = result; | 658 fixed_double_live_ranges_[index] = result; |
649 } | 659 } |
650 return result; | 660 return result; |
651 } | 661 } |
652 | 662 |
| 663 |
653 LiveRange* LAllocator::LiveRangeFor(int index) { | 664 LiveRange* LAllocator::LiveRangeFor(int index) { |
654 if (index >= live_ranges_.length()) { | 665 if (index >= live_ranges_.length()) { |
655 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1); | 666 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1); |
656 } | 667 } |
657 LiveRange* result = live_ranges_[index]; | 668 LiveRange* result = live_ranges_[index]; |
658 if (result == NULL) { | 669 if (result == NULL) { |
659 result = new LiveRange(index); | 670 result = new LiveRange(index); |
660 live_ranges_[index] = result; | 671 live_ranges_[index] = result; |
661 } | 672 } |
662 return result; | 673 return result; |
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 LiveRange* current = live_ranges()->at(i); | 2097 LiveRange* current = live_ranges()->at(i); |
2087 if (current != NULL) current->Verify(); | 2098 if (current != NULL) current->Verify(); |
2088 } | 2099 } |
2089 } | 2100 } |
2090 | 2101 |
2091 | 2102 |
2092 #endif | 2103 #endif |
2093 | 2104 |
2094 | 2105 |
2095 } } // namespace v8::internal | 2106 } } // namespace v8::internal |
OLD | NEW |