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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 new_element.set_copied(); | 206 new_element.set_copied(); |
207 } | 207 } |
208 if (elements_[index].is_register()) { | 208 if (elements_[index].is_register()) { |
209 Unuse(elements_[index].reg()); | 209 Unuse(elements_[index].reg()); |
210 } | 210 } |
211 new_element.set_static_type(elements_[index].static_type()); | 211 new_element.set_static_type(elements_[index].static_type()); |
212 elements_[index] = new_element; | 212 elements_[index] = new_element; |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 // Clear the dirty bits for the range of elements in | |
217 // [min(stack_pointer_ + 1,begin), end). | |
218 void VirtualFrame::SyncRange(int begin, int end) { | |
219 ASSERT(begin >= 0); | |
220 ASSERT(end <= elements_.length()); | |
221 if (begin > stack_pointer_) { | |
222 // Elements between stack_pointer_ + 1 and begin must also be synced. | |
223 for (int i = stack_pointer_ + 1; i < end; i++) { | |
224 SyncElementByPushing(i); | |
225 } | |
226 } else if (end <= stack_pointer_ + 1) { | |
227 for (int i = begin; i < end; i++) { | |
228 if (!elements_[i].is_synced()) { | |
229 SyncElementBelowStackPointer(i); | |
230 } | |
231 } | |
232 } else { | |
233 // Split into two ranges that each satisfy a condition above. | |
234 SyncRange(begin, stack_pointer_ + 1); | |
235 SyncRange(stack_pointer_ + 1, end); | |
236 } | |
237 } | |
238 | |
239 | |
240 // Clear the dirty bit for the element at a given index. | 216 // Clear the dirty bit for the element at a given index. |
241 void VirtualFrame::SyncElementAt(int index) { | 217 void VirtualFrame::SyncElementAt(int index) { |
242 if (index <= stack_pointer_) { | 218 if (index <= stack_pointer_) { |
243 if (!elements_[index].is_synced()) { | 219 if (!elements_[index].is_synced()) SyncElementBelowStackPointer(index); |
244 SyncElementBelowStackPointer(index); | 220 } else if (index == stack_pointer_ + 1) { |
245 } | 221 SyncElementByPushing(index); |
246 } else { | 222 } else { |
247 for (int i = stack_pointer_ + 1; i <= index; i++) { | 223 SyncRange(stack_pointer_ + 1, index); |
248 SyncElementByPushing(i); | |
249 } | |
250 } | 224 } |
251 } | 225 } |
252 | 226 |
253 | 227 |
254 // Make the type of all elements be MEMORY. | 228 // Make the type of all elements be MEMORY. |
255 void VirtualFrame::SpillAll() { | 229 void VirtualFrame::SpillAll() { |
256 for (int i = 0; i < elements_.length(); i++) { | 230 for (int i = 0; i < elements_.length(); i++) { |
257 SpillElementAt(i); | 231 SpillElementAt(i); |
258 } | 232 } |
259 } | 233 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 elements_[i].set_static_type(target.static_type()); | 277 elements_[i].set_static_type(target.static_type()); |
304 } | 278 } |
305 } | 279 } |
306 | 280 |
307 | 281 |
308 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { | 282 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { |
309 ASSERT(height() >= dropped_args); | 283 ASSERT(height() >= dropped_args); |
310 ASSERT(height() >= spilled_args); | 284 ASSERT(height() >= spilled_args); |
311 ASSERT(dropped_args <= spilled_args); | 285 ASSERT(dropped_args <= spilled_args); |
312 | 286 |
313 SyncRange(0, elements_.length()); | 287 SyncRange(0, elements_.length() - 1); |
314 // Spill registers. | 288 // Spill registers. |
315 for (int i = 0; i < kNumRegisters; i++) { | 289 for (int i = 0; i < kNumRegisters; i++) { |
316 if (is_used(i)) { | 290 if (is_used(i)) { |
317 SpillElementAt(register_locations_[i]); | 291 SpillElementAt(register_locations_[i]); |
318 } | 292 } |
319 } | 293 } |
320 | 294 |
321 // Spill the arguments. | 295 // Spill the arguments. |
322 for (int i = elements_.length() - spilled_args; i < elements_.length(); i++) { | 296 for (int i = elements_.length() - spilled_args; i < elements_.length(); i++) { |
323 if (!elements_[i].is_memory()) { | 297 if (!elements_[i].is_memory()) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 #endif | 501 #endif |
528 if (stack_pointer_ != other->stack_pointer_) return false; | 502 if (stack_pointer_ != other->stack_pointer_) return false; |
529 for (int i = 0; i < elements_.length(); i++) { | 503 for (int i = 0; i < elements_.length(); i++) { |
530 if (!elements_[i].Equals(other->elements_[i])) return false; | 504 if (!elements_[i].Equals(other->elements_[i])) return false; |
531 } | 505 } |
532 | 506 |
533 return true; | 507 return true; |
534 } | 508 } |
535 | 509 |
536 } } // namespace v8::internal | 510 } } // namespace v8::internal |
OLD | NEW |