OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 void VirtualFrame::Spill(Register target) { | 175 void VirtualFrame::Spill(Register target) { |
176 if (is_used(target)) { | 176 if (is_used(target)) { |
177 SpillElementAt(register_index(target)); | 177 SpillElementAt(register_index(target)); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 // Spill any register if possible, making its external reference count zero. | 182 // If there are any registers referenced only by the frame, spill one. |
183 Register VirtualFrame::SpillAnyRegister() { | 183 Register VirtualFrame::SpillAnyRegister() { |
184 // Find the leftmost (ordered by register code), least | 184 // Find the leftmost (ordered by register code) register whose only |
185 // internally-referenced register whose internal reference count matches | 185 // reference is in the frame. |
186 // its external reference count (so that spilling it from the frame frees | |
187 // it for use). | |
188 for (int i = 0; i < kNumRegisters; i++) { | 186 for (int i = 0; i < kNumRegisters; i++) { |
189 if (is_used(i) && cgen_->allocator()->count(i) == 1) { | 187 if (is_used(i) && cgen_->allocator()->count(i) == 1) { |
190 Register result = { i }; | 188 Register result = { i }; |
191 Spill(result); | 189 Spill(result); |
192 ASSERT(!cgen_->allocator()->is_used(result)); | 190 ASSERT(!cgen_->allocator()->is_used(result)); |
193 return result; | 191 return result; |
194 } | 192 } |
195 } | 193 } |
196 return no_reg; | 194 return no_reg; |
197 } | 195 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 #endif | 543 #endif |
546 if (stack_pointer_ != other->stack_pointer_) return false; | 544 if (stack_pointer_ != other->stack_pointer_) return false; |
547 for (int i = 0; i < elements_.length(); i++) { | 545 for (int i = 0; i < elements_.length(); i++) { |
548 if (!elements_[i].Equals(other->elements_[i])) return false; | 546 if (!elements_[i].Equals(other->elements_[i])) return false; |
549 } | 547 } |
550 | 548 |
551 return true; | 549 return true; |
552 } | 550 } |
553 | 551 |
554 } } // namespace v8::internal | 552 } } // namespace v8::internal |
OLD | NEW |