| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 SpillElementAt(i); | 392 SpillElementAt(i); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 delete[] new_elements; | 396 delete[] new_elements; |
| 397 } | 397 } |
| 398 | 398 |
| 399 | 399 |
| 400 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 400 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
| 401 Comment cmnt(masm_, "[ Merge frame"); | 401 Comment cmnt(masm_, "[ Merge frame"); |
| 402 ASSERT(cgen_ == expected->cgen_); | |
| 403 ASSERT(masm_ == expected->masm_); | |
| 404 ASSERT(elements_.length() == expected->elements_.length()); | |
| 405 ASSERT(parameter_count_ == expected->parameter_count_); | |
| 406 ASSERT(local_count_ == expected->local_count_); | |
| 407 ASSERT(frame_pointer_ == expected->frame_pointer_); | |
| 408 | |
| 409 // Mergable frames have all elements in locations, either memory or | 402 // Mergable frames have all elements in locations, either memory or |
| 410 // register. We thus have a series of to-memory and to-register moves. | 403 // register. We thus have a series of to-memory and to-register moves. |
| 411 // First perform all to-memory moves, register-to-memory moves because | 404 // First perform all to-memory moves, register-to-memory moves because |
| 412 // they can free registers and constant-to-memory moves because they do | 405 // they can free registers and constant-to-memory moves because they do |
| 413 // not use registers. | 406 // not use registers. |
| 414 for (int i = 0; i < elements_.length(); i++) { | 407 for (int i = 0; i < elements_.length(); i++) { |
| 415 FrameElement source = elements_[i]; | 408 FrameElement source = elements_[i]; |
| 416 FrameElement target = expected->elements_[i]; | 409 FrameElement target = expected->elements_[i]; |
| 417 if (target.is_memory() && !source.is_memory()) { | 410 if (target.is_memory() && !source.is_memory()) { |
| 418 ASSERT(source.is_register() || source.is_constant()); | 411 ASSERT(source.is_register() || source.is_constant()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } else { | 454 } else { |
| 462 // Source is constant. | 455 // Source is constant. |
| 463 __ Set(target.reg(), Immediate(source.handle())); | 456 __ Set(target.reg(), Immediate(source.handle())); |
| 464 } | 457 } |
| 465 Use(target.reg()); | 458 Use(target.reg()); |
| 466 elements_[i] = target; | 459 elements_[i] = target; |
| 467 } | 460 } |
| 468 } | 461 } |
| 469 | 462 |
| 470 // At this point, the frames should be identical. | 463 // At this point, the frames should be identical. |
| 471 ASSERT(stack_pointer_ == expected->stack_pointer_); | 464 ASSERT(Equals(expected)); |
| 472 #ifdef DEBUG | |
| 473 for (int i = 0; i < elements_.length(); i++) { | |
| 474 FrameElement expect = expected->elements_[i]; | |
| 475 if (expect.is_memory()) { | |
| 476 ASSERT(elements_[i].is_memory()); | |
| 477 ASSERT(elements_[i].is_synced() && expect.is_synced()); | |
| 478 } else if (expect.is_register()) { | |
| 479 ASSERT(elements_[i].is_register()); | |
| 480 ASSERT(elements_[i].reg().is(expect.reg())); | |
| 481 ASSERT(elements_[i].is_synced() == expect.is_synced()); | |
| 482 } else { | |
| 483 ASSERT(expect.is_constant()); | |
| 484 ASSERT(elements_[i].is_constant()); | |
| 485 ASSERT(elements_[i].handle().location() == | |
| 486 expect.handle().location()); | |
| 487 ASSERT(elements_[i].is_synced() == expect.is_synced()); | |
| 488 } | |
| 489 } | |
| 490 #endif | |
| 491 } | 465 } |
| 492 | 466 |
| 493 | 467 |
| 494 void VirtualFrame::DetachFromCodeGenerator() { | 468 void VirtualFrame::DetachFromCodeGenerator() { |
| 495 // Tell the global register allocator that it is free to reallocate all | 469 // Tell the global register allocator that it is free to reallocate all |
| 496 // register references contained in this frame. The frame elements remain | 470 // register references contained in this frame. The frame elements remain |
| 497 // register references, so the frame-internal reference count is not | 471 // register references, so the frame-internal reference count is not |
| 498 // decremented. | 472 // decremented. |
| 499 for (int i = 0; i < elements_.length(); i++) { | 473 for (int i = 0; i < elements_.length(); i++) { |
| 500 if (elements_[i].is_register()) { | 474 if (elements_[i].is_register()) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 758 |
| 785 #ifdef DEBUG | 759 #ifdef DEBUG |
| 786 bool VirtualFrame::IsSpilled() { | 760 bool VirtualFrame::IsSpilled() { |
| 787 for (int i = 0; i < elements_.length(); i++) { | 761 for (int i = 0; i < elements_.length(); i++) { |
| 788 if (!elements_[i].is_memory()) { | 762 if (!elements_[i].is_memory()) { |
| 789 return false; | 763 return false; |
| 790 } | 764 } |
| 791 } | 765 } |
| 792 return true; | 766 return true; |
| 793 } | 767 } |
| 768 |
| 769 |
| 770 bool VirtualFrame::Equals(VirtualFrame* other) { |
| 771 if (cgen_ != other->cgen_) return false; |
| 772 if (masm_ != other->masm_) return false; |
| 773 if (elements_.length() != other->elements_.length()) return false; |
| 774 if (parameter_count_ != other->parameter_count_) return false; |
| 775 if (local_count_ != other->local_count_) return false; |
| 776 if (frame_pointer_ != other->frame_pointer_) return false; |
| 777 if (stack_pointer_ != other->stack_pointer_) return false; |
| 778 |
| 779 for (int i = 0; i < elements_.length(); i++) { |
| 780 FrameElement element = other->elements_[i]; |
| 781 if (element.is_memory()) { |
| 782 if (!elements_[i].is_memory()) return false; |
| 783 if (!elements_[i].is_synced() || !element.is_synced()) return false; |
| 784 } else if (element.is_register()) { |
| 785 if (!elements_[i].is_register()) return false; |
| 786 if (!elements_[i].reg().is(element.reg())) return false; |
| 787 if (elements_[i].is_synced() != element.is_synced()) return false; |
| 788 } else { |
| 789 if (!element.is_constant()) return false; |
| 790 if (!elements_[i].is_constant()) return false; |
| 791 if (elements_[i].handle().location() != element.handle().location()) { |
| 792 return false; |
| 793 } |
| 794 if (elements_[i].is_synced() != element.is_synced()) return false; |
| 795 } |
| 796 } |
| 797 return true; |
| 798 } |
| 794 #endif | 799 #endif |
| 795 | 800 |
| 796 #undef __ | 801 #undef __ |
| 797 | 802 |
| 798 } } // namespace v8::internal | 803 } } // namespace v8::internal |
| OLD | NEW |