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

Side by Side Diff: src/virtual-frame.cc

Issue 50005: Add a copied flag to virtual frame elements that tells if a copy has... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
« no previous file with comments | « src/virtual-frame.h ('k') | src/virtual-frame-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // We do not allow copies of copies, so we follow one link to 86 // We do not allow copies of copies, so we follow one link to
87 // the actual backing store of a copy before making a copy. 87 // the actual backing store of a copy before making a copy.
88 index = target.index(); 88 index = target.index();
89 ASSERT(elements_[index].is_memory() || elements_[index].is_register()); 89 ASSERT(elements_[index].is_memory() || elements_[index].is_register());
90 // Fall through. 90 // Fall through.
91 91
92 case FrameElement::MEMORY: // Fall through. 92 case FrameElement::MEMORY: // Fall through.
93 case FrameElement::REGISTER: 93 case FrameElement::REGISTER:
94 // All copies are backed by memory or register locations. 94 // All copies are backed by memory or register locations.
95 result.type_ = 95 result.type_ =
96 FrameElement::TypeField::encode(FrameElement::COPY) | 96 FrameElement::TypeField::encode(FrameElement::COPY)
97 FrameElement::SyncField::encode(FrameElement::NOT_SYNCED); 97 | FrameElement::IsCopiedField::encode(false)
98 | FrameElement::SyncField::encode(FrameElement::NOT_SYNCED);
98 result.data_.index_ = index; 99 result.data_.index_ = index;
100 elements_[index].set_copied();
99 break; 101 break;
100 102
101 case FrameElement::INVALID: 103 case FrameElement::INVALID:
102 // We should not try to copy invalid elements. 104 // We should not try to copy invalid elements.
103 UNREACHABLE(); 105 UNREACHABLE();
104 break; 106 break;
105 } 107 }
106 return result; 108 return result;
107 } 109 }
108 110
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 203 }
202 return result; 204 return result;
203 } 205 }
204 206
205 207
206 // Make the type of the element at a given index be MEMORY. 208 // Make the type of the element at a given index be MEMORY.
207 void VirtualFrame::SpillElementAt(int index) { 209 void VirtualFrame::SpillElementAt(int index) {
208 if (!elements_[index].is_valid()) return; 210 if (!elements_[index].is_valid()) return;
209 211
210 SyncElementAt(index); 212 SyncElementAt(index);
213 // The element is now in memory. Its copied flag is preserved.
214 FrameElement new_element = FrameElement::MemoryElement();
215 if (elements_[index].is_copied()) {
216 new_element.set_copied();
217 }
211 if (elements_[index].is_register()) { 218 if (elements_[index].is_register()) {
212 Unuse(elements_[index].reg()); 219 Unuse(elements_[index].reg());
213 } 220 }
214 // The element is now in memory. 221 elements_[index] = new_element;
215 elements_[index] = FrameElement::MemoryElement();
216 } 222 }
217 223
218 224
219 // Clear the dirty bits for the range of elements in [begin, end). 225 // Clear the dirty bits for the range of elements in [begin, end).
220 void VirtualFrame::SyncRange(int begin, int end) { 226 void VirtualFrame::SyncRange(int begin, int end) {
221 ASSERT(begin >= 0); 227 ASSERT(begin >= 0);
222 ASSERT(end <= elements_.length()); 228 ASSERT(end <= elements_.length());
223 for (int i = begin; i < end; i++) { 229 for (int i = begin; i < end; i++) {
224 RawSyncElementAt(i); 230 RawSyncElementAt(i);
225 } 231 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 275 }
270 elements_[i] = target; 276 elements_[i] = target;
271 } else if (target.is_register() && !target.is_synced() && 277 } else if (target.is_register() && !target.is_synced() &&
272 !source.is_memory()) { 278 !source.is_memory()) {
273 // If an element's target is a register that doesn't need to be 279 // If an element's target is a register that doesn't need to be
274 // synced, and the element is not in memory, then the sync state 280 // synced, and the element is not in memory, then the sync state
275 // of the element is irrelevant. We clear the sync bit. 281 // of the element is irrelevant. We clear the sync bit.
276 ASSERT(source.is_valid()); 282 ASSERT(source.is_valid());
277 elements_[i].clear_sync(); 283 elements_[i].clear_sync();
278 } 284 }
285
286 elements_[i].clear_copied();
287 if (elements_[i].is_copy()) {
288 elements_[elements_[i].index()].set_copied();
289 }
279 } 290 }
280 } 291 }
281 292
282 293
283 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { 294 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) {
284 ASSERT(height() >= dropped_args); 295 ASSERT(height() >= dropped_args);
285 ASSERT(height() >= spilled_args); 296 ASSERT(height() >= spilled_args);
286 ASSERT(dropped_args <= spilled_args); 297 ASSERT(dropped_args <= spilled_args);
287 298
288 int arg_base_index = elements_.length() - spilled_args; 299 int arg_base_index = elements_.length() - spilled_args;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 bool same_constant = original.is_constant() 371 bool same_constant = original.is_constant()
361 && value->is_constant() 372 && value->is_constant()
362 && original.handle().is_identical_to(value->handle()); 373 && original.handle().is_identical_to(value->handle());
363 if (same_register || same_constant) { 374 if (same_register || same_constant) {
364 value->Unuse(); 375 value->Unuse();
365 return; 376 return;
366 } 377 }
367 378
368 // If the original may be a copy, adjust to preserve the copy-on-write 379 // If the original may be a copy, adjust to preserve the copy-on-write
369 // semantics of copied elements. 380 // semantics of copied elements.
370 if (original.is_register() || original.is_memory()) { 381 if (original.is_copied() &&
382 (original.is_register() || original.is_memory())) {
371 FrameElement ignored = AdjustCopies(frame_index); 383 FrameElement ignored = AdjustCopies(frame_index);
372 } 384 }
373 385
374 // If the original is a register reference, deallocate it. 386 // If the original is a register reference, deallocate it.
375 if (original.is_register()) { 387 if (original.is_register()) {
376 Unuse(original.reg()); 388 Unuse(original.reg());
377 } 389 }
378 390
379 FrameElement new_element; 391 FrameElement new_element;
380 if (value->is_register()) { 392 if (value->is_register()) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 if (num_dropped == 0) return; 528 if (num_dropped == 0) return;
517 Result tos = Pop(); 529 Result tos = Pop();
518 if (num_dropped > 1) { 530 if (num_dropped > 1) {
519 Drop(num_dropped - 1); 531 Drop(num_dropped - 1);
520 } 532 }
521 SetElementAt(0, &tos); 533 SetElementAt(0, &tos);
522 } 534 }
523 535
524 536
525 bool FrameElement::Equals(FrameElement other) { 537 bool FrameElement::Equals(FrameElement other) {
526 if (type() != other.type()) return false; 538 if (type_ != other.type_) return false;
527 if (is_synced() != other.is_synced()) return false;
528 539
529 if (is_register()) { 540 if (is_register()) {
530 if (!reg().is(other.reg())) return false; 541 if (!reg().is(other.reg())) return false;
531 } else if (is_constant()) { 542 } else if (is_constant()) {
532 if (!handle().is_identical_to(other.handle())) return false; 543 if (!handle().is_identical_to(other.handle())) return false;
533 } else if (is_copy()) { 544 } else if (is_copy()) {
534 if (index() != other.index()) return false; 545 if (index() != other.index()) return false;
535 } 546 }
536 547
537 return true; 548 return true;
538 } 549 }
539 550
540 551
541 bool VirtualFrame::Equals(VirtualFrame* other) { 552 bool VirtualFrame::Equals(VirtualFrame* other) {
553 #ifdef DEBUG
554 // These are sanity checks in debug builds, but we do not need to
555 // use them to distinguish frames at merge points.
542 if (cgen_ != other->cgen_) return false; 556 if (cgen_ != other->cgen_) return false;
543 if (masm_ != other->masm_) return false; 557 if (masm_ != other->masm_) return false;
544 if (elements_.length() != other->elements_.length()) return false;
545
546 for (int i = 0; i < elements_.length(); i++) {
547 if (!elements_[i].Equals(other->elements_[i])) return false;
548 }
549
550 if (parameter_count_ != other->parameter_count_) return false; 558 if (parameter_count_ != other->parameter_count_) return false;
551 if (local_count_ != other->local_count_) return false; 559 if (local_count_ != other->local_count_) return false;
552 if (stack_pointer_ != other->stack_pointer_) return false;
553 if (frame_pointer_ != other->frame_pointer_) return false; 560 if (frame_pointer_ != other->frame_pointer_) return false;
554 561
555 for (int i = 0; i < kNumRegisters; i++) { 562 for (int i = 0; i < kNumRegisters; i++) {
556 if (frame_registers_.count(i) != other->frame_registers_.count(i)) { 563 if (frame_registers_.count(i) != other->frame_registers_.count(i)) {
557 return false; 564 return false;
558 } 565 }
559 } 566 }
567 if (elements_.length() != other->elements_.length()) return false;
568 #endif
569 if (stack_pointer_ != other->stack_pointer_) return false;
570 for (int i = 0; i < elements_.length(); i++) {
571 if (!elements_[i].Equals(other->elements_[i])) return false;
572 }
560 573
561 return true; 574 return true;
562 } 575 }
563 576
564 } } // namespace v8::internal 577 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/virtual-frame.h ('k') | src/virtual-frame-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698