Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: src/lithium-allocator.cc

Issue 12631012: Fixed register allocation corner case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added regression test Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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());
Vyacheslav Egorov (Chromium) 2013/03/11 08:43:15 I wonder if we should turn ASSERT in the callee in
Sven Panne 2013/03/11 09:48:03 Sounds like a good idea, the check is extremely ch
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-177883.js » ('j') | test/mjsunit/compiler/regress-177883.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698