| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 | 132 |
| 133 LiveRange::LiveRange(int id, Zone* zone) | 133 LiveRange::LiveRange(int id, Zone* zone) |
| 134 : id_(id), | 134 : id_(id), |
| 135 spilled_(false), | 135 spilled_(false), |
| 136 is_double_(false), | 136 kind_(UNALLOCATED_REGISTERS), |
| 137 assigned_register_(kInvalidAssignment), | 137 assigned_register_(kInvalidAssignment), |
| 138 last_interval_(NULL), | 138 last_interval_(NULL), |
| 139 first_interval_(NULL), | 139 first_interval_(NULL), |
| 140 first_pos_(NULL), | 140 first_pos_(NULL), |
| 141 parent_(NULL), | 141 parent_(NULL), |
| 142 next_(NULL), | 142 next_(NULL), |
| 143 current_interval_(NULL), | 143 current_interval_(NULL), |
| 144 last_processed_use_(NULL), | 144 last_processed_use_(NULL), |
| 145 current_hint_operand_(NULL), | 145 current_hint_operand_(NULL), |
| 146 spill_operand_(new(zone) LOperand()), | 146 spill_operand_(new(zone) LOperand()), |
| 147 spill_start_index_(kMaxInt) { } | 147 spill_start_index_(kMaxInt) { } |
| 148 | 148 |
| 149 | 149 |
| 150 void LiveRange::set_assigned_register(int reg, | 150 void LiveRange::set_assigned_register(int reg, Zone* zone) { |
| 151 RegisterKind register_kind, | |
| 152 Zone* zone) { | |
| 153 ASSERT(!HasRegisterAssigned() && !IsSpilled()); | 151 ASSERT(!HasRegisterAssigned() && !IsSpilled()); |
| 154 assigned_register_ = reg; | 152 assigned_register_ = reg; |
| 155 is_double_ = (register_kind == DOUBLE_REGISTERS); | |
| 156 ConvertOperands(zone); | 153 ConvertOperands(zone); |
| 157 } | 154 } |
| 158 | 155 |
| 159 | 156 |
| 160 void LiveRange::MakeSpilled(Zone* zone) { | 157 void LiveRange::MakeSpilled(Zone* zone) { |
| 161 ASSERT(!IsSpilled()); | 158 ASSERT(!IsSpilled()); |
| 162 ASSERT(TopLevel()->HasAllocatedSpillOperand()); | 159 ASSERT(TopLevel()->HasAllocatedSpillOperand()); |
| 163 spilled_ = true; | 160 spilled_ = true; |
| 164 assigned_register_ = kInvalidAssignment; | 161 assigned_register_ = kInvalidAssignment; |
| 165 ConvertOperands(zone); | 162 ConvertOperands(zone); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (use_pos == NULL) return true; | 226 if (use_pos == NULL) return true; |
| 230 return | 227 return |
| 231 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); | 228 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); |
| 232 } | 229 } |
| 233 | 230 |
| 234 | 231 |
| 235 LOperand* LiveRange::CreateAssignedOperand(Zone* zone) { | 232 LOperand* LiveRange::CreateAssignedOperand(Zone* zone) { |
| 236 LOperand* op = NULL; | 233 LOperand* op = NULL; |
| 237 if (HasRegisterAssigned()) { | 234 if (HasRegisterAssigned()) { |
| 238 ASSERT(!IsSpilled()); | 235 ASSERT(!IsSpilled()); |
| 239 if (IsDouble()) { | 236 switch (Kind()) { |
| 240 op = LDoubleRegister::Create(assigned_register(), zone); | 237 case GENERAL_REGISTERS: |
| 241 } else { | 238 op = LRegister::Create(assigned_register(), zone); |
| 242 op = LRegister::Create(assigned_register(), zone); | 239 break; |
| 240 case DOUBLE_REGISTERS: |
| 241 op = LDoubleRegister::Create(assigned_register(), zone); |
| 242 break; |
| 243 default: |
| 244 UNREACHABLE(); |
| 243 } | 245 } |
| 244 } else if (IsSpilled()) { | 246 } else if (IsSpilled()) { |
| 245 ASSERT(!HasRegisterAssigned()); | 247 ASSERT(!HasRegisterAssigned()); |
| 246 op = TopLevel()->GetSpillOperand(); | 248 op = TopLevel()->GetSpillOperand(); |
| 247 ASSERT(!op->IsUnallocated()); | 249 ASSERT(!op->IsUnallocated()); |
| 248 } else { | 250 } else { |
| 249 LUnallocated* unalloc = new(zone) LUnallocated(LUnallocated::NONE); | 251 LUnallocated* unalloc = new(zone) LUnallocated(LUnallocated::NONE); |
| 250 unalloc->set_virtual_register(id_); | 252 unalloc->set_virtual_register(id_); |
| 251 op = unalloc; | 253 op = unalloc; |
| 252 } | 254 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 result->first_pos_ = use_after; | 349 result->first_pos_ = use_after; |
| 348 | 350 |
| 349 // Discard cached iteration state. It might be pointing | 351 // Discard cached iteration state. It might be pointing |
| 350 // to the use that no longer belongs to this live range. | 352 // to the use that no longer belongs to this live range. |
| 351 last_processed_use_ = NULL; | 353 last_processed_use_ = NULL; |
| 352 current_interval_ = NULL; | 354 current_interval_ = NULL; |
| 353 | 355 |
| 354 // Link the new live range in the chain before any of the other | 356 // Link the new live range in the chain before any of the other |
| 355 // ranges linked from the range before the split. | 357 // ranges linked from the range before the split. |
| 356 result->parent_ = (parent_ == NULL) ? this : parent_; | 358 result->parent_ = (parent_ == NULL) ? this : parent_; |
| 359 result->kind_ = result->parent_->kind_; |
| 357 result->next_ = next_; | 360 result->next_ = next_; |
| 358 next_ = result; | 361 next_ = result; |
| 359 | 362 |
| 360 #ifdef DEBUG | 363 #ifdef DEBUG |
| 361 Verify(); | 364 Verify(); |
| 362 result->Verify(); | 365 result->Verify(); |
| 363 #endif | 366 #endif |
| 364 } | 367 } |
| 365 | 368 |
| 366 | 369 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 live_in_sets_(graph->blocks()->length(), zone()), | 551 live_in_sets_(graph->blocks()->length(), zone()), |
| 549 live_ranges_(num_values * 2, zone()), | 552 live_ranges_(num_values * 2, zone()), |
| 550 fixed_live_ranges_(NULL), | 553 fixed_live_ranges_(NULL), |
| 551 fixed_double_live_ranges_(NULL), | 554 fixed_double_live_ranges_(NULL), |
| 552 unhandled_live_ranges_(num_values * 2, zone()), | 555 unhandled_live_ranges_(num_values * 2, zone()), |
| 553 active_live_ranges_(8, zone()), | 556 active_live_ranges_(8, zone()), |
| 554 inactive_live_ranges_(8, zone()), | 557 inactive_live_ranges_(8, zone()), |
| 555 reusable_slots_(8, zone()), | 558 reusable_slots_(8, zone()), |
| 556 next_virtual_register_(num_values), | 559 next_virtual_register_(num_values), |
| 557 first_artificial_register_(num_values), | 560 first_artificial_register_(num_values), |
| 558 mode_(GENERAL_REGISTERS), | 561 mode_(UNALLOCATED_REGISTERS), |
| 559 num_registers_(-1), | 562 num_registers_(-1), |
| 560 graph_(graph), | 563 graph_(graph), |
| 561 has_osr_entry_(false), | 564 has_osr_entry_(false), |
| 562 allocation_ok_(true) { } | 565 allocation_ok_(true) { } |
| 563 | 566 |
| 564 | 567 |
| 565 void LAllocator::InitializeLivenessAnalysis() { | 568 void LAllocator::InitializeLivenessAnalysis() { |
| 566 // Initialize the live_in sets for each block to NULL. | 569 // Initialize the live_in sets for each block to NULL. |
| 567 int block_count = graph_->blocks()->length(); | 570 int block_count = graph_->blocks()->length(); |
| 568 live_in_sets_.Initialize(block_count, zone()); | 571 live_in_sets_.Initialize(block_count, zone()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 return operand; | 651 return operand; |
| 649 } | 652 } |
| 650 | 653 |
| 651 | 654 |
| 652 LiveRange* LAllocator::FixedLiveRangeFor(int index) { | 655 LiveRange* LAllocator::FixedLiveRangeFor(int index) { |
| 653 ASSERT(index < Register::kMaxNumAllocatableRegisters); | 656 ASSERT(index < Register::kMaxNumAllocatableRegisters); |
| 654 LiveRange* result = fixed_live_ranges_[index]; | 657 LiveRange* result = fixed_live_ranges_[index]; |
| 655 if (result == NULL) { | 658 if (result == NULL) { |
| 656 result = new(zone()) LiveRange(FixedLiveRangeID(index), chunk()->zone()); | 659 result = new(zone()) LiveRange(FixedLiveRangeID(index), chunk()->zone()); |
| 657 ASSERT(result->IsFixed()); | 660 ASSERT(result->IsFixed()); |
| 658 SetLiveRangeAssignedRegister(result, index, GENERAL_REGISTERS); | 661 result->kind_ = GENERAL_REGISTERS; |
| 662 SetLiveRangeAssignedRegister(result, index); |
| 659 fixed_live_ranges_[index] = result; | 663 fixed_live_ranges_[index] = result; |
| 660 } | 664 } |
| 661 return result; | 665 return result; |
| 662 } | 666 } |
| 663 | 667 |
| 664 | 668 |
| 665 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) { | 669 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) { |
| 666 ASSERT(index < DoubleRegister::NumAllocatableRegisters()); | 670 ASSERT(index < DoubleRegister::NumAllocatableRegisters()); |
| 667 LiveRange* result = fixed_double_live_ranges_[index]; | 671 LiveRange* result = fixed_double_live_ranges_[index]; |
| 668 if (result == NULL) { | 672 if (result == NULL) { |
| 669 result = new(zone()) LiveRange(FixedDoubleLiveRangeID(index), | 673 result = new(zone()) LiveRange(FixedDoubleLiveRangeID(index), |
| 670 chunk()->zone()); | 674 chunk()->zone()); |
| 671 ASSERT(result->IsFixed()); | 675 ASSERT(result->IsFixed()); |
| 672 SetLiveRangeAssignedRegister(result, index, DOUBLE_REGISTERS); | 676 result->kind_ = DOUBLE_REGISTERS; |
| 677 SetLiveRangeAssignedRegister(result, index); |
| 673 fixed_double_live_ranges_[index] = result; | 678 fixed_double_live_ranges_[index] = result; |
| 674 } | 679 } |
| 675 return result; | 680 return result; |
| 676 } | 681 } |
| 677 | 682 |
| 678 | 683 |
| 679 LiveRange* LAllocator::LiveRangeFor(int index) { | 684 LiveRange* LAllocator::LiveRangeFor(int index) { |
| 680 if (index >= live_ranges_.length()) { | 685 if (index >= live_ranges_.length()) { |
| 681 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone()); | 686 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone()); |
| 682 } | 687 } |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 } | 1375 } |
| 1371 PrintF("Value %d used before first definition!\n", operand_index); | 1376 PrintF("Value %d used before first definition!\n", operand_index); |
| 1372 LiveRange* range = LiveRangeFor(operand_index); | 1377 LiveRange* range = LiveRangeFor(operand_index); |
| 1373 PrintF("First use is at %d\n", range->first_pos()->pos().Value()); | 1378 PrintF("First use is at %d\n", range->first_pos()->pos().Value()); |
| 1374 iterator.Advance(); | 1379 iterator.Advance(); |
| 1375 } | 1380 } |
| 1376 ASSERT(!found); | 1381 ASSERT(!found); |
| 1377 } | 1382 } |
| 1378 #endif | 1383 #endif |
| 1379 } | 1384 } |
| 1385 |
| 1386 for (int i = 0; i < live_ranges_.length(); ++i) { |
| 1387 if (live_ranges_[i] != NULL) { |
| 1388 live_ranges_[i]->kind_ = RequiredRegisterKind(live_ranges_[i]->id()); |
| 1389 } |
| 1390 } |
| 1380 } | 1391 } |
| 1381 | 1392 |
| 1382 | 1393 |
| 1383 bool LAllocator::SafePointsAreInOrder() const { | 1394 bool LAllocator::SafePointsAreInOrder() const { |
| 1384 const ZoneList<LPointerMap*>* pointer_maps = chunk_->pointer_maps(); | 1395 const ZoneList<LPointerMap*>* pointer_maps = chunk_->pointer_maps(); |
| 1385 int safe_point = 0; | 1396 int safe_point = 0; |
| 1386 for (int i = 0; i < pointer_maps->length(); ++i) { | 1397 for (int i = 0; i < pointer_maps->length(); ++i) { |
| 1387 LPointerMap* map = pointer_maps->at(i); | 1398 LPointerMap* map = pointer_maps->at(i); |
| 1388 if (safe_point > map->lithium_position()) return false; | 1399 if (safe_point > map->lithium_position()) return false; |
| 1389 safe_point = map->lithium_position(); | 1400 safe_point = map->lithium_position(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 map->RecordPointer(operand, chunk()->zone()); | 1487 map->RecordPointer(operand, chunk()->zone()); |
| 1477 } | 1488 } |
| 1478 } | 1489 } |
| 1479 } | 1490 } |
| 1480 } | 1491 } |
| 1481 | 1492 |
| 1482 | 1493 |
| 1483 void LAllocator::AllocateGeneralRegisters() { | 1494 void LAllocator::AllocateGeneralRegisters() { |
| 1484 LAllocatorPhase phase("L_Allocate general registers", this); | 1495 LAllocatorPhase phase("L_Allocate general registers", this); |
| 1485 num_registers_ = Register::NumAllocatableRegisters(); | 1496 num_registers_ = Register::NumAllocatableRegisters(); |
| 1497 mode_ = GENERAL_REGISTERS; |
| 1486 AllocateRegisters(); | 1498 AllocateRegisters(); |
| 1487 } | 1499 } |
| 1488 | 1500 |
| 1489 | 1501 |
| 1490 void LAllocator::AllocateDoubleRegisters() { | 1502 void LAllocator::AllocateDoubleRegisters() { |
| 1491 LAllocatorPhase phase("L_Allocate double registers", this); | 1503 LAllocatorPhase phase("L_Allocate double registers", this); |
| 1492 num_registers_ = DoubleRegister::NumAllocatableRegisters(); | 1504 num_registers_ = DoubleRegister::NumAllocatableRegisters(); |
| 1493 mode_ = DOUBLE_REGISTERS; | 1505 mode_ = DOUBLE_REGISTERS; |
| 1494 AllocateRegisters(); | 1506 AllocateRegisters(); |
| 1495 } | 1507 } |
| 1496 | 1508 |
| 1497 | 1509 |
| 1498 void LAllocator::AllocateRegisters() { | 1510 void LAllocator::AllocateRegisters() { |
| 1499 ASSERT(unhandled_live_ranges_.is_empty()); | 1511 ASSERT(unhandled_live_ranges_.is_empty()); |
| 1500 | 1512 |
| 1501 for (int i = 0; i < live_ranges_.length(); ++i) { | 1513 for (int i = 0; i < live_ranges_.length(); ++i) { |
| 1502 if (live_ranges_[i] != NULL) { | 1514 if (live_ranges_[i] != NULL) { |
| 1503 if (RequiredRegisterKind(live_ranges_[i]->id()) == mode_) { | 1515 if (live_ranges_[i]->Kind() == mode_) { |
| 1504 AddToUnhandledUnsorted(live_ranges_[i]); | 1516 AddToUnhandledUnsorted(live_ranges_[i]); |
| 1505 } | 1517 } |
| 1506 } | 1518 } |
| 1507 } | 1519 } |
| 1508 SortUnhandled(); | 1520 SortUnhandled(); |
| 1509 ASSERT(UnhandledIsSorted()); | 1521 ASSERT(UnhandledIsSorted()); |
| 1510 | 1522 |
| 1511 ASSERT(reusable_slots_.is_empty()); | 1523 ASSERT(reusable_slots_.is_empty()); |
| 1512 ASSERT(active_live_ranges_.is_empty()); | 1524 ASSERT(active_live_ranges_.is_empty()); |
| 1513 ASSERT(inactive_live_ranges_.is_empty()); | 1525 ASSERT(inactive_live_ranges_.is_empty()); |
| 1514 | 1526 |
| 1515 if (mode_ == DOUBLE_REGISTERS) { | 1527 if (mode_ == DOUBLE_REGISTERS) { |
| 1516 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { | 1528 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { |
| 1517 LiveRange* current = fixed_double_live_ranges_.at(i); | 1529 LiveRange* current = fixed_double_live_ranges_.at(i); |
| 1518 if (current != NULL) { | 1530 if (current != NULL) { |
| 1519 AddToInactive(current); | 1531 AddToInactive(current); |
| 1520 } | 1532 } |
| 1521 } | 1533 } |
| 1522 } else { | 1534 } else { |
| 1535 ASSERT(mode_ == GENERAL_REGISTERS); |
| 1523 for (int i = 0; i < fixed_live_ranges_.length(); ++i) { | 1536 for (int i = 0; i < fixed_live_ranges_.length(); ++i) { |
| 1524 LiveRange* current = fixed_live_ranges_.at(i); | 1537 LiveRange* current = fixed_live_ranges_.at(i); |
| 1525 if (current != NULL) { | 1538 if (current != NULL) { |
| 1526 AddToInactive(current); | 1539 AddToInactive(current); |
| 1527 } | 1540 } |
| 1528 } | 1541 } |
| 1529 } | 1542 } |
| 1530 | 1543 |
| 1531 while (!unhandled_live_ranges_.is_empty()) { | 1544 while (!unhandled_live_ranges_.is_empty()) { |
| 1532 ASSERT(UnhandledIsSorted()); | 1545 ASSERT(UnhandledIsSorted()); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 RegisterName(register_index), | 1820 RegisterName(register_index), |
| 1808 free_until_pos[register_index].Value(), | 1821 free_until_pos[register_index].Value(), |
| 1809 current->id(), | 1822 current->id(), |
| 1810 current->End().Value()); | 1823 current->End().Value()); |
| 1811 | 1824 |
| 1812 // The desired register is free until the end of the current live range. | 1825 // The desired register is free until the end of the current live range. |
| 1813 if (free_until_pos[register_index].Value() >= current->End().Value()) { | 1826 if (free_until_pos[register_index].Value() >= current->End().Value()) { |
| 1814 TraceAlloc("Assigning preferred reg %s to live range %d\n", | 1827 TraceAlloc("Assigning preferred reg %s to live range %d\n", |
| 1815 RegisterName(register_index), | 1828 RegisterName(register_index), |
| 1816 current->id()); | 1829 current->id()); |
| 1817 SetLiveRangeAssignedRegister(current, register_index, mode_); | 1830 SetLiveRangeAssignedRegister(current, register_index); |
| 1818 return true; | 1831 return true; |
| 1819 } | 1832 } |
| 1820 } | 1833 } |
| 1821 | 1834 |
| 1822 // Find the register which stays free for the longest time. | 1835 // Find the register which stays free for the longest time. |
| 1823 int reg = 0; | 1836 int reg = 0; |
| 1824 for (int i = 1; i < RegisterCount(); ++i) { | 1837 for (int i = 1; i < RegisterCount(); ++i) { |
| 1825 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) { | 1838 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) { |
| 1826 reg = i; | 1839 reg = i; |
| 1827 } | 1840 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1842 AddToUnhandledSorted(tail); | 1855 AddToUnhandledSorted(tail); |
| 1843 } | 1856 } |
| 1844 | 1857 |
| 1845 | 1858 |
| 1846 // Register reg is available at the range start and is free until | 1859 // Register reg is available at the range start and is free until |
| 1847 // the range end. | 1860 // the range end. |
| 1848 ASSERT(pos.Value() >= current->End().Value()); | 1861 ASSERT(pos.Value() >= current->End().Value()); |
| 1849 TraceAlloc("Assigning free reg %s to live range %d\n", | 1862 TraceAlloc("Assigning free reg %s to live range %d\n", |
| 1850 RegisterName(reg), | 1863 RegisterName(reg), |
| 1851 current->id()); | 1864 current->id()); |
| 1852 SetLiveRangeAssignedRegister(current, reg, mode_); | 1865 SetLiveRangeAssignedRegister(current, reg); |
| 1853 | 1866 |
| 1854 return true; | 1867 return true; |
| 1855 } | 1868 } |
| 1856 | 1869 |
| 1857 | 1870 |
| 1858 void LAllocator::AllocateBlockedReg(LiveRange* current) { | 1871 void LAllocator::AllocateBlockedReg(LiveRange* current) { |
| 1859 UsePosition* register_use = current->NextRegisterPosition(current->Start()); | 1872 UsePosition* register_use = current->NextRegisterPosition(current->Start()); |
| 1860 if (register_use == NULL) { | 1873 if (register_use == NULL) { |
| 1861 // There is no use in the current live range that requires a register. | 1874 // There is no use in the current live range that requires a register. |
| 1862 // We can just spill it. | 1875 // We can just spill it. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 block_pos[reg].InstructionStart()); | 1940 block_pos[reg].InstructionStart()); |
| 1928 if (!AllocationOk()) return; | 1941 if (!AllocationOk()) return; |
| 1929 AddToUnhandledSorted(tail); | 1942 AddToUnhandledSorted(tail); |
| 1930 } | 1943 } |
| 1931 | 1944 |
| 1932 // Register reg is not blocked for the whole range. | 1945 // Register reg is not blocked for the whole range. |
| 1933 ASSERT(block_pos[reg].Value() >= current->End().Value()); | 1946 ASSERT(block_pos[reg].Value() >= current->End().Value()); |
| 1934 TraceAlloc("Assigning blocked reg %s to live range %d\n", | 1947 TraceAlloc("Assigning blocked reg %s to live range %d\n", |
| 1935 RegisterName(reg), | 1948 RegisterName(reg), |
| 1936 current->id()); | 1949 current->id()); |
| 1937 SetLiveRangeAssignedRegister(current, reg, mode_); | 1950 SetLiveRangeAssignedRegister(current, reg); |
| 1938 | 1951 |
| 1939 // This register was not free. Thus we need to find and spill | 1952 // This register was not free. Thus we need to find and spill |
| 1940 // parts of active and inactive live regions that use the same register | 1953 // parts of active and inactive live regions that use the same register |
| 1941 // at the same lifetime positions as current. | 1954 // at the same lifetime positions as current. |
| 1942 SplitAndSpillIntersecting(current); | 1955 SplitAndSpillIntersecting(current); |
| 1943 } | 1956 } |
| 1944 | 1957 |
| 1945 | 1958 |
| 1946 LifetimePosition LAllocator::FindOptimalSpillingPos(LiveRange* range, | 1959 LifetimePosition LAllocator::FindOptimalSpillingPos(LiveRange* range, |
| 1947 LifetimePosition pos) { | 1960 LifetimePosition pos) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 } | 2157 } |
| 2145 | 2158 |
| 2146 | 2159 |
| 2147 void LAllocator::Spill(LiveRange* range) { | 2160 void LAllocator::Spill(LiveRange* range) { |
| 2148 ASSERT(!range->IsSpilled()); | 2161 ASSERT(!range->IsSpilled()); |
| 2149 TraceAlloc("Spilling live range %d\n", range->id()); | 2162 TraceAlloc("Spilling live range %d\n", range->id()); |
| 2150 LiveRange* first = range->TopLevel(); | 2163 LiveRange* first = range->TopLevel(); |
| 2151 | 2164 |
| 2152 if (!first->HasAllocatedSpillOperand()) { | 2165 if (!first->HasAllocatedSpillOperand()) { |
| 2153 LOperand* op = TryReuseSpillSlot(range); | 2166 LOperand* op = TryReuseSpillSlot(range); |
| 2154 if (op == NULL) op = chunk_->GetNextSpillSlot(mode_ == DOUBLE_REGISTERS); | 2167 if (op == NULL) op = chunk_->GetNextSpillSlot(range->Kind()); |
| 2155 first->SetSpillOperand(op); | 2168 first->SetSpillOperand(op); |
| 2156 } | 2169 } |
| 2157 range->MakeSpilled(chunk()->zone()); | 2170 range->MakeSpilled(chunk()->zone()); |
| 2158 } | 2171 } |
| 2159 | 2172 |
| 2160 | 2173 |
| 2161 int LAllocator::RegisterCount() const { | 2174 int LAllocator::RegisterCount() const { |
| 2162 return num_registers_; | 2175 return num_registers_; |
| 2163 } | 2176 } |
| 2164 | 2177 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2199 isolate()->GetHTracer()->TraceLiveRanges(name(), allocator_); | 2212 isolate()->GetHTracer()->TraceLiveRanges(name(), allocator_); |
| 2200 } | 2213 } |
| 2201 | 2214 |
| 2202 #ifdef DEBUG | 2215 #ifdef DEBUG |
| 2203 if (allocator_ != NULL) allocator_->Verify(); | 2216 if (allocator_ != NULL) allocator_->Verify(); |
| 2204 #endif | 2217 #endif |
| 2205 } | 2218 } |
| 2206 | 2219 |
| 2207 | 2220 |
| 2208 } } // namespace v8::internal | 2221 } } // namespace v8::internal |
| OLD | NEW |