| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 | 584 |
| 585 void VirtualFrame::Enter() { | 585 void VirtualFrame::Enter() { |
| 586 // Registers live on entry: esp, ebp, esi, edi. | 586 // Registers live on entry: esp, ebp, esi, edi. |
| 587 Comment cmnt(masm_, "[ Enter JS frame"); | 587 Comment cmnt(masm_, "[ Enter JS frame"); |
| 588 EmitPush(ebp); | 588 EmitPush(ebp); |
| 589 | 589 |
| 590 frame_pointer_ = stack_pointer_; | 590 frame_pointer_ = stack_pointer_; |
| 591 __ mov(ebp, Operand(esp)); | 591 __ mov(ebp, Operand(esp)); |
| 592 | 592 |
| 593 // Store the context in the frame. The context is kept in esi, so the | 593 // Store the context in the frame. The context is kept in esi and a |
| 594 // register reference is not owned by the frame (ie, the frame is not free | 594 // copy is stored in the frame. The external reference to esi |
| 595 // to spill it). This is implemented by making the in-frame value be | 595 // remains in addition to the cached copy in the frame. |
| 596 // memory. | 596 Push(esi); |
| 597 EmitPush(esi); | |
| 598 | 597 |
| 599 // Store the function in the frame. The frame owns the register reference | 598 // Store the function in the frame. The frame owns the register reference |
| 600 // now (ie, it can keep it in edi or spill it later). | 599 // now (ie, it can keep it in edi or spill it later). |
| 601 Push(edi); | 600 Push(edi); |
| 602 cgen_->allocator()->Unuse(edi); | 601 cgen_->allocator()->Unuse(edi); |
| 603 } | 602 } |
| 604 | 603 |
| 605 | 604 |
| 606 void VirtualFrame::Exit() { | 605 void VirtualFrame::Exit() { |
| 607 Comment cmnt(masm_, "[ Exit JS frame"); | 606 Comment cmnt(masm_, "[ Exit JS frame"); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 ASSERT(value->is_constant()); | 673 ASSERT(value->is_constant()); |
| 675 elements_[frame_index] = | 674 elements_[frame_index] = |
| 676 FrameElement::ConstantElement(value->handle(), | 675 FrameElement::ConstantElement(value->handle(), |
| 677 FrameElement::NOT_SYNCED); | 676 FrameElement::NOT_SYNCED); |
| 678 } | 677 } |
| 679 | 678 |
| 680 value->Unuse(); | 679 value->Unuse(); |
| 681 } | 680 } |
| 682 | 681 |
| 683 | 682 |
| 683 void VirtualFrame::SaveContextRegister() { |
| 684 FrameElement current = elements_[context_index()]; |
| 685 ASSERT(current.is_register() || current.is_memory()); |
| 686 if (!current.is_register() || !current.reg().is(esi)) { |
| 687 if (current.is_register()) { |
| 688 Unuse(current.reg()); |
| 689 } |
| 690 Use(esi); |
| 691 elements_[context_index()] = |
| 692 FrameElement::RegisterElement(esi, FrameElement::NOT_SYNCED); |
| 693 } |
| 694 } |
| 695 |
| 696 |
| 697 void VirtualFrame::RestoreContextRegister() { |
| 698 FrameElement current = elements_[context_index()]; |
| 699 ASSERT(current.is_register() || current.is_memory()); |
| 700 if (current.is_register() && !current.reg().is(esi)) { |
| 701 Unuse(current.reg()); |
| 702 Use(esi); |
| 703 __ mov(esi, current.reg()); |
| 704 elements_[context_index()] = |
| 705 FrameElement::RegisterElement(esi, FrameElement::NOT_SYNCED); |
| 706 } else if (current.is_memory()) { |
| 707 Use(esi); |
| 708 __ mov(esi, Operand(ebp, fp_relative(context_index()))); |
| 709 elements_[context_index()] = |
| 710 FrameElement::RegisterElement(esi, FrameElement::SYNCED); |
| 711 } |
| 712 } |
| 713 |
| 714 |
| 684 void VirtualFrame::LoadFrameSlotAt(int index) { | 715 void VirtualFrame::LoadFrameSlotAt(int index) { |
| 685 ASSERT(index >= 0); | 716 ASSERT(index >= 0); |
| 686 ASSERT(index < elements_.length()); | 717 ASSERT(index < elements_.length()); |
| 687 | 718 |
| 688 FrameElement element = elements_[index]; | 719 FrameElement element = elements_[index]; |
| 689 | 720 |
| 690 if (element.is_memory()) { | 721 if (element.is_memory()) { |
| 691 ASSERT(index <= stack_pointer_); | 722 ASSERT(index <= stack_pointer_); |
| 692 // Eagerly load memory elements into a register. The element at | 723 // Eagerly load memory elements into a register. The element at |
| 693 // the index and the new top of the frame are backed by the same | 724 // the index and the new top of the frame are backed by the same |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 int frame_arg_count) { | 830 int frame_arg_count) { |
| 800 arg0->Unuse(); | 831 arg0->Unuse(); |
| 801 arg1->Unuse(); | 832 arg1->Unuse(); |
| 802 CallStub(stub, frame_arg_count); | 833 CallStub(stub, frame_arg_count); |
| 803 Result result = cgen_->allocator()->Allocate(eax); | 834 Result result = cgen_->allocator()->Allocate(eax); |
| 804 ASSERT(result.is_valid()); | 835 ASSERT(result.is_valid()); |
| 805 return result; | 836 return result; |
| 806 } | 837 } |
| 807 | 838 |
| 808 | 839 |
| 809 void VirtualFrame::CallRuntime(Runtime::Function* f, int frame_arg_count) { | 840 Result VirtualFrame::CallRuntime(Runtime::Function* f, |
| 841 int frame_arg_count) { |
| 810 ASSERT(cgen_->HasValidEntryRegisters()); | 842 ASSERT(cgen_->HasValidEntryRegisters()); |
| 811 PrepareForCall(frame_arg_count); | 843 PrepareForCall(frame_arg_count); |
| 812 __ CallRuntime(f, frame_arg_count); | 844 __ CallRuntime(f, frame_arg_count); |
| 845 Result result = cgen_->allocator()->Allocate(eax); |
| 846 ASSERT(result.is_valid()); |
| 847 return result; |
| 813 } | 848 } |
| 814 | 849 |
| 815 | 850 |
| 816 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int frame_arg_count) { | 851 Result VirtualFrame::CallRuntime(Runtime::FunctionId id, |
| 852 int frame_arg_count) { |
| 817 ASSERT(cgen_->HasValidEntryRegisters()); | 853 ASSERT(cgen_->HasValidEntryRegisters()); |
| 818 PrepareForCall(frame_arg_count); | 854 PrepareForCall(frame_arg_count); |
| 819 __ CallRuntime(id, frame_arg_count); | 855 __ CallRuntime(id, frame_arg_count); |
| 856 Result result = cgen_->allocator()->Allocate(eax); |
| 857 ASSERT(result.is_valid()); |
| 858 return result; |
| 820 } | 859 } |
| 821 | 860 |
| 822 | 861 |
| 823 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, | 862 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, |
| 824 InvokeFlag flag, | 863 InvokeFlag flag, |
| 825 int frame_arg_count) { | 864 int frame_arg_count) { |
| 826 ASSERT(cgen_->HasValidEntryRegisters()); | 865 ASSERT(cgen_->HasValidEntryRegisters()); |
| 827 PrepareForCall(frame_arg_count); | 866 PrepareForCall(frame_arg_count); |
| 828 __ InvokeBuiltin(id, flag); | 867 __ InvokeBuiltin(id, flag); |
| 829 } | 868 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 return false; | 1001 return false; |
| 963 } | 1002 } |
| 964 } | 1003 } |
| 965 return true; | 1004 return true; |
| 966 } | 1005 } |
| 967 #endif | 1006 #endif |
| 968 | 1007 |
| 969 #undef __ | 1008 #undef __ |
| 970 | 1009 |
| 971 } } // namespace v8::internal | 1010 } } // namespace v8::internal |
| OLD | NEW |