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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 bool LiveRange::CanBeSpilled(LifetimePosition pos) { | 222 bool LiveRange::CanBeSpilled(LifetimePosition pos) { |
223 // We cannot spill a live range that has a use requiring a register | 223 // We cannot spill a live range that has a use requiring a register |
224 // at the current or the immediate next position. | 224 // at the current or the immediate next position. |
225 UsePosition* use_pos = NextRegisterPosition(pos); | 225 UsePosition* use_pos = NextRegisterPosition(pos); |
226 if (use_pos == NULL) return true; | 226 if (use_pos == NULL) return true; |
227 return | 227 return |
228 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); | 228 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 UsePosition* LiveRange::FirstPosWithHint() const { | |
233 UsePosition* pos = first_pos_; | |
234 while (pos != NULL && !pos->HasHint()) pos = pos->next(); | |
235 return pos; | |
236 } | |
237 | |
238 | |
239 LOperand* LiveRange::CreateAssignedOperand(Zone* zone) { | 232 LOperand* LiveRange::CreateAssignedOperand(Zone* zone) { |
240 LOperand* op = NULL; | 233 LOperand* op = NULL; |
241 if (HasRegisterAssigned()) { | 234 if (HasRegisterAssigned()) { |
242 ASSERT(!IsSpilled()); | 235 ASSERT(!IsSpilled()); |
243 if (IsDouble()) { | 236 if (IsDouble()) { |
244 op = LDoubleRegister::Create(assigned_register(), zone); | 237 op = LDoubleRegister::Create(assigned_register(), zone); |
245 } else { | 238 } else { |
246 op = LRegister::Create(assigned_register(), zone); | 239 op = LRegister::Create(assigned_register(), zone); |
247 } | 240 } |
248 } else if (IsSpilled()) { | 241 } else if (IsSpilled()) { |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 for (int i = 0; i < inactive_live_ranges_.length(); ++i) { | 1799 for (int i = 0; i < inactive_live_ranges_.length(); ++i) { |
1807 LiveRange* cur_inactive = inactive_live_ranges_.at(i); | 1800 LiveRange* cur_inactive = inactive_live_ranges_.at(i); |
1808 ASSERT(cur_inactive->End().Value() > current->Start().Value()); | 1801 ASSERT(cur_inactive->End().Value() > current->Start().Value()); |
1809 LifetimePosition next_intersection = | 1802 LifetimePosition next_intersection = |
1810 cur_inactive->FirstIntersection(current); | 1803 cur_inactive->FirstIntersection(current); |
1811 if (!next_intersection.IsValid()) continue; | 1804 if (!next_intersection.IsValid()) continue; |
1812 int cur_reg = cur_inactive->assigned_register(); | 1805 int cur_reg = cur_inactive->assigned_register(); |
1813 free_until_pos[cur_reg] = Min(free_until_pos[cur_reg], next_intersection); | 1806 free_until_pos[cur_reg] = Min(free_until_pos[cur_reg], next_intersection); |
1814 } | 1807 } |
1815 | 1808 |
1816 UsePosition* hinted_use = current->FirstPosWithHint(); | 1809 LOperand* hint = current->FirstHint(); |
1817 if (hinted_use != NULL) { | 1810 if (hint != NULL && (hint->IsRegister() || hint->IsDoubleRegister())) { |
1818 LOperand* hint = hinted_use->hint(); | 1811 int register_index = hint->index(); |
1819 if (hint->IsRegister() || hint->IsDoubleRegister()) { | 1812 TraceAlloc( |
1820 int register_index = hint->index(); | 1813 "Found reg hint %s (free until [%d) for live range %d (end %d[).\n", |
1821 TraceAlloc( | 1814 RegisterName(register_index), |
1822 "Found reg hint %s (free until [%d) for live range %d (end %d[).\n", | 1815 free_until_pos[register_index].Value(), |
1823 RegisterName(register_index), | 1816 current->id(), |
1824 free_until_pos[register_index].Value(), | 1817 current->End().Value()); |
1825 current->id(), | |
1826 current->End().Value()); | |
1827 | 1818 |
1828 // The desired register is free until the end of the current live range. | 1819 // The desired register is free until the end of the current live range. |
1829 if (free_until_pos[register_index].Value() >= current->End().Value()) { | 1820 if (free_until_pos[register_index].Value() >= current->End().Value()) { |
1830 TraceAlloc("Assigning preferred reg %s to live range %d\n", | 1821 TraceAlloc("Assigning preferred reg %s to live range %d\n", |
1831 RegisterName(register_index), | 1822 RegisterName(register_index), |
1832 current->id()); | 1823 current->id()); |
1833 SetLiveRangeAssignedRegister(current, register_index, mode_, zone_); | 1824 SetLiveRangeAssignedRegister(current, register_index, mode_, zone_); |
1834 return true; | 1825 return true; |
1835 } | |
1836 } | 1826 } |
1837 } | 1827 } |
1838 | 1828 |
1839 // Find the register which stays free for the longest time. | 1829 // Find the register which stays free for the longest time. |
1840 int reg = 0; | 1830 int reg = 0; |
1841 for (int i = 1; i < RegisterCount(); ++i) { | 1831 for (int i = 1; i < RegisterCount(); ++i) { |
1842 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) { | 1832 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) { |
1843 reg = i; | 1833 reg = i; |
1844 } | 1834 } |
1845 } | 1835 } |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 LiveRange* current = live_ranges()->at(i); | 2178 LiveRange* current = live_ranges()->at(i); |
2189 if (current != NULL) current->Verify(); | 2179 if (current != NULL) current->Verify(); |
2190 } | 2180 } |
2191 } | 2181 } |
2192 | 2182 |
2193 | 2183 |
2194 #endif | 2184 #endif |
2195 | 2185 |
2196 | 2186 |
2197 } } // namespace v8::internal | 2187 } } // namespace v8::internal |
OLD | NEW |