| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 UsePosition* LiveRange::NextRegisterPosition(LifetimePosition start) { | 199 UsePosition* LiveRange::NextRegisterPosition(LifetimePosition start) { |
| 200 UsePosition* pos = NextUsePosition(start); | 200 UsePosition* pos = NextUsePosition(start); |
| 201 while (pos != NULL && !pos->RequiresRegister()) { | 201 while (pos != NULL && !pos->RequiresRegister()) { |
| 202 pos = pos->next(); | 202 pos = pos->next(); |
| 203 } | 203 } |
| 204 return pos; | 204 return pos; |
| 205 } | 205 } |
| 206 | 206 |
| 207 | 207 |
| 208 bool LiveRange::CanBeSpilled(LifetimePosition pos) { | 208 bool LiveRange::CanBeSpilled(LifetimePosition pos) { |
| 209 // TODO(kmillikin): Comment. Now. | |
| 210 if (pos.Value() <= Start().Value() && HasRegisterAssigned()) return false; | |
| 211 | |
| 212 // We cannot spill a live range that has a use requiring a register | 209 // We cannot spill a live range that has a use requiring a register |
| 213 // at the current or the immediate next position. | 210 // at the current or the immediate next position. |
| 214 UsePosition* use_pos = NextRegisterPosition(pos); | 211 UsePosition* use_pos = NextRegisterPosition(pos); |
| 215 if (use_pos == NULL) return true; | 212 if (use_pos == NULL) return true; |
| 216 return | 213 return |
| 217 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); | 214 use_pos->pos().Value() > pos.NextInstruction().InstructionEnd().Value(); |
| 218 } | 215 } |
| 219 | 216 |
| 220 | 217 |
| 221 UsePosition* LiveRange::FirstPosWithHint() const { | 218 UsePosition* LiveRange::FirstPosWithHint() const { |
| (...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 if (use_pos[i].Value() > use_pos[reg].Value()) { | 1907 if (use_pos[i].Value() > use_pos[reg].Value()) { |
| 1911 reg = i; | 1908 reg = i; |
| 1912 } | 1909 } |
| 1913 } | 1910 } |
| 1914 | 1911 |
| 1915 LifetimePosition pos = use_pos[reg]; | 1912 LifetimePosition pos = use_pos[reg]; |
| 1916 | 1913 |
| 1917 if (pos.Value() < register_use->pos().Value()) { | 1914 if (pos.Value() < register_use->pos().Value()) { |
| 1918 // All registers are blocked before the first use that requires a register. | 1915 // All registers are blocked before the first use that requires a register. |
| 1919 // Spill starting part of live range up to that use. | 1916 // Spill starting part of live range up to that use. |
| 1920 // | |
| 1921 // Corner case: the first use position is equal to the start of the range. | |
| 1922 // In this case we have nothing to spill and SpillBetween will just return | |
| 1923 // this range to the list of unhandled ones. This will lead to the infinite | |
| 1924 // loop. | |
| 1925 ASSERT(current->Start().Value() < register_use->pos().Value()); | |
| 1926 SpillBetween(current, current->Start(), register_use->pos()); | 1917 SpillBetween(current, current->Start(), register_use->pos()); |
| 1927 return; | 1918 return; |
| 1928 } | 1919 } |
| 1929 | 1920 |
| 1930 if (block_pos[reg].Value() < current->End().Value()) { | 1921 if (block_pos[reg].Value() < current->End().Value()) { |
| 1931 // Register becomes blocked before the current range end. Split before that | 1922 // Register becomes blocked before the current range end. Split before that |
| 1932 // position. | 1923 // position. |
| 1933 LiveRange* tail = SplitBetween(current, | 1924 LiveRange* tail = SplitBetween(current, |
| 1934 current->Start(), | 1925 current->Start(), |
| 1935 block_pos[reg].InstructionStart()); | 1926 block_pos[reg].InstructionStart()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 void LAllocator::SpillAfter(LiveRange* range, LifetimePosition pos) { | 2056 void LAllocator::SpillAfter(LiveRange* range, LifetimePosition pos) { |
| 2066 LiveRange* second_part = SplitRangeAt(range, pos); | 2057 LiveRange* second_part = SplitRangeAt(range, pos); |
| 2067 if (!AllocationOk()) return; | 2058 if (!AllocationOk()) return; |
| 2068 Spill(second_part); | 2059 Spill(second_part); |
| 2069 } | 2060 } |
| 2070 | 2061 |
| 2071 | 2062 |
| 2072 void LAllocator::SpillBetween(LiveRange* range, | 2063 void LAllocator::SpillBetween(LiveRange* range, |
| 2073 LifetimePosition start, | 2064 LifetimePosition start, |
| 2074 LifetimePosition end) { | 2065 LifetimePosition end) { |
| 2075 ASSERT(start.Value() < end.Value()); | 2066 CHECK(start.Value() < end.Value()); |
| 2076 LiveRange* second_part = SplitRangeAt(range, start); | 2067 LiveRange* second_part = SplitRangeAt(range, start); |
| 2077 if (!AllocationOk()) return; | 2068 if (!AllocationOk()) return; |
| 2078 | 2069 |
| 2079 if (second_part->Start().Value() < end.Value()) { | 2070 if (second_part->Start().Value() < end.Value()) { |
| 2080 // The split result intersects with [start, end[. | 2071 // The split result intersects with [start, end[. |
| 2081 // Split it at position between ]start+1, end[, spill the middle part | 2072 // Split it at position between ]start+1, end[, spill the middle part |
| 2082 // and put the rest to unhandled. | 2073 // and put the rest to unhandled. |
| 2083 LiveRange* third_part = SplitBetween( | 2074 LiveRange* third_part = SplitBetween( |
| 2084 second_part, | 2075 second_part, |
| 2085 second_part->Start().InstructionEnd(), | 2076 second_part->Start().InstructionEnd(), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 LiveRange* current = live_ranges()->at(i); | 2115 LiveRange* current = live_ranges()->at(i); |
| 2125 if (current != NULL) current->Verify(); | 2116 if (current != NULL) current->Verify(); |
| 2126 } | 2117 } |
| 2127 } | 2118 } |
| 2128 | 2119 |
| 2129 | 2120 |
| 2130 #endif | 2121 #endif |
| 2131 | 2122 |
| 2132 | 2123 |
| 2133 } } // namespace v8::internal | 2124 } } // namespace v8::internal |
| OLD | NEW |