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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // Make the type of all elements be MEMORY. | 224 // Make the type of all elements be MEMORY. |
225 void VirtualFrame::SpillAll() { | 225 void VirtualFrame::SpillAll() { |
226 for (int i = 0; i < elements_.length(); i++) { | 226 for (int i = 0; i < elements_.length(); i++) { |
227 SpillElementAt(i); | 227 SpillElementAt(i); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 void VirtualFrame::PrepareMergeTo(VirtualFrame* expected) { | 232 void VirtualFrame::PrepareMergeTo(VirtualFrame* expected) { |
233 // No code needs to be generated to invalidate valid elements. No | 233 // Perform state changes on this frame that will make merge to the |
234 // code needs to be generated to move values to memory if they are | 234 // expected frame simpler or else increase the likelihood that his |
235 // already synced. | 235 // frame will match another. |
236 for (int i = 0; i < elements_.length(); i++) { | 236 for (int i = 0; i < elements_.length(); i++) { |
237 FrameElement source = elements_[i]; | 237 FrameElement source = elements_[i]; |
238 FrameElement target = expected->elements_[i]; | 238 FrameElement target = expected->elements_[i]; |
| 239 |
239 if (!target.is_valid() || | 240 if (!target.is_valid() || |
240 (target.is_memory() && !source.is_memory() && source.is_synced())) { | 241 (target.is_memory() && !source.is_memory() && source.is_synced())) { |
| 242 // No code needs to be generated to invalidate valid elements. |
| 243 // No code needs to be generated to move values to memory if |
| 244 // they are already synced. We perform those moves here, before |
| 245 // merging. |
241 if (source.is_register()) { | 246 if (source.is_register()) { |
242 // If the frame is the code generator's current frame, we have | 247 // If the frame is the code generator's current frame, we have |
243 // to decrement both the frame-internal and global register | 248 // to decrement both the frame-internal and global register |
244 // counts. | 249 // counts. |
245 if (cgen_->frame() == this) { | 250 if (cgen_->frame() == this) { |
246 Unuse(source.reg()); | 251 Unuse(source.reg()); |
247 } else { | 252 } else { |
248 frame_registers_.Unuse(source.reg()); | 253 frame_registers_.Unuse(source.reg()); |
249 } | 254 } |
250 } | 255 } |
251 elements_[i] = target; | 256 elements_[i] = target; |
| 257 } else if (target.is_register() && !source.is_memory()) { |
| 258 // If an element's target is a register, and the element is not |
| 259 // in memory, then the sync state of the element is irrelevant. |
| 260 // We clear the sync bit. |
| 261 ASSERT(source.is_valid()); |
| 262 elements_[i].clear_sync(); |
252 } | 263 } |
253 } | 264 } |
254 } | 265 } |
255 | 266 |
256 | 267 |
257 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { | 268 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { |
258 ASSERT(height() >= dropped_args); | 269 ASSERT(height() >= dropped_args); |
259 ASSERT(height() >= spilled_args); | 270 ASSERT(height() >= spilled_args); |
260 ASSERT(dropped_args <= spilled_args); | 271 ASSERT(dropped_args <= spilled_args); |
261 | 272 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 for (int i = 0; i < kNumRegisters; i++) { | 544 for (int i = 0; i < kNumRegisters; i++) { |
534 if (frame_registers_.count(i) != other->frame_registers_.count(i)) { | 545 if (frame_registers_.count(i) != other->frame_registers_.count(i)) { |
535 return false; | 546 return false; |
536 } | 547 } |
537 } | 548 } |
538 | 549 |
539 return true; | 550 return true; |
540 } | 551 } |
541 | 552 |
542 } } // namespace v8::internal | 553 } } // namespace v8::internal |
OLD | NEW |