| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 28 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| 29 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 29 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| 30 | 30 |
| 31 #include "assembler.h" | 31 #include "assembler.h" |
| 32 #include "frames.h" |
| 32 #include "v8globals.h" | 33 #include "v8globals.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 // Flags used for the AllocateInNewSpace functions. | 38 // Flags used for the AllocateInNewSpace functions. |
| 38 enum AllocationFlags { | 39 enum AllocationFlags { |
| 39 // No special flags. | 40 // No special flags. |
| 40 NO_ALLOCATION_FLAGS = 0, | 41 NO_ALLOCATION_FLAGS = 0, |
| 41 // Return the pointer to the allocated already tagged as a heap object. | 42 // Return the pointer to the allocated already tagged as a heap object. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 Register address, | 99 Register address, |
| 99 Register value); | 100 Register value); |
| 100 | 101 |
| 101 #ifdef ENABLE_DEBUGGER_SUPPORT | 102 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 102 // --------------------------------------------------------------------------- | 103 // --------------------------------------------------------------------------- |
| 103 // Debugger Support | 104 // Debugger Support |
| 104 | 105 |
| 105 void DebugBreak(); | 106 void DebugBreak(); |
| 106 #endif | 107 #endif |
| 107 | 108 |
| 108 // --------------------------------------------------------------------------- | |
| 109 // Activation frames | |
| 110 | |
| 111 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | |
| 112 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | |
| 113 | |
| 114 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | |
| 115 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | |
| 116 | |
| 117 // Enter specific kind of exit frame. Expects the number of | 109 // Enter specific kind of exit frame. Expects the number of |
| 118 // arguments in register eax and sets up the number of arguments in | 110 // arguments in register eax and sets up the number of arguments in |
| 119 // register edi and the pointer to the first argument in register | 111 // register edi and the pointer to the first argument in register |
| 120 // esi. | 112 // esi. |
| 121 void EnterExitFrame(bool save_doubles); | 113 void EnterExitFrame(bool save_doubles); |
| 122 | 114 |
| 123 void EnterApiExitFrame(int argc); | 115 void EnterApiExitFrame(int argc); |
| 124 | 116 |
| 125 // Leave the current exit frame. Expects the return value in | 117 // Leave the current exit frame. Expects the return value in |
| 126 // register eax:edx (untouched) and the pointer to the first | 118 // register eax:edx (untouched) and the pointer to the first |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 void Abort(const char* msg); | 609 void Abort(const char* msg); |
| 618 | 610 |
| 619 // Check that the stack is aligned. | 611 // Check that the stack is aligned. |
| 620 void CheckStackAlignment(); | 612 void CheckStackAlignment(); |
| 621 | 613 |
| 622 // Verify restrictions about code generated in stubs. | 614 // Verify restrictions about code generated in stubs. |
| 623 void set_generating_stub(bool value) { generating_stub_ = value; } | 615 void set_generating_stub(bool value) { generating_stub_ = value; } |
| 624 bool generating_stub() { return generating_stub_; } | 616 bool generating_stub() { return generating_stub_; } |
| 625 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } | 617 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } |
| 626 bool allow_stub_calls() { return allow_stub_calls_; } | 618 bool allow_stub_calls() { return allow_stub_calls_; } |
| 619 void set_has_frame(bool value) { has_frame_ = value; } |
| 620 bool has_frame() { return has_frame_; } |
| 621 inline bool AllowThisStubCall(CodeStub* stub); |
| 627 | 622 |
| 628 // --------------------------------------------------------------------------- | 623 // --------------------------------------------------------------------------- |
| 629 // String utilities. | 624 // String utilities. |
| 630 | 625 |
| 631 // Check whether the instance type represents a flat ascii string. Jump to the | 626 // Check whether the instance type represents a flat ascii string. Jump to the |
| 632 // label if not. If the instance type can be scratched specify same register | 627 // label if not. If the instance type can be scratched specify same register |
| 633 // for both instance type and scratch. | 628 // for both instance type and scratch. |
| 634 void JumpIfInstanceTypeIsNotSequentialAscii(Register instance_type, | 629 void JumpIfInstanceTypeIsNotSequentialAscii(Register instance_type, |
| 635 Register scratch, | 630 Register scratch, |
| 636 Label* on_not_flat_ascii_string); | 631 Label* on_not_flat_ascii_string); |
| 637 | 632 |
| 638 // Checks if both objects are sequential ASCII strings, and jumps to label | 633 // Checks if both objects are sequential ASCII strings, and jumps to label |
| 639 // if either is not. | 634 // if either is not. |
| 640 void JumpIfNotBothSequentialAsciiStrings(Register object1, | 635 void JumpIfNotBothSequentialAsciiStrings(Register object1, |
| 641 Register object2, | 636 Register object2, |
| 642 Register scratch1, | 637 Register scratch1, |
| 643 Register scratch2, | 638 Register scratch2, |
| 644 Label* on_not_flat_ascii_strings); | 639 Label* on_not_flat_ascii_strings); |
| 645 | 640 |
| 646 static int SafepointRegisterStackIndex(Register reg) { | 641 static int SafepointRegisterStackIndex(Register reg) { |
| 647 return SafepointRegisterStackIndex(reg.code()); | 642 return SafepointRegisterStackIndex(reg.code()); |
| 648 } | 643 } |
| 649 | 644 |
| 645 // Activation support. |
| 646 void EnterFrame(StackFrame::Type type); |
| 647 void LeaveFrame(StackFrame::Type type); |
| 648 |
| 650 private: | 649 private: |
| 651 bool generating_stub_; | 650 bool generating_stub_; |
| 652 bool allow_stub_calls_; | 651 bool allow_stub_calls_; |
| 652 bool has_frame_; |
| 653 // This handle will be patched with the code object on installation. | 653 // This handle will be patched with the code object on installation. |
| 654 Handle<Object> code_object_; | 654 Handle<Object> code_object_; |
| 655 | 655 |
| 656 // Helper functions for generating invokes. | 656 // Helper functions for generating invokes. |
| 657 void InvokePrologue(const ParameterCount& expected, | 657 void InvokePrologue(const ParameterCount& expected, |
| 658 const ParameterCount& actual, | 658 const ParameterCount& actual, |
| 659 Handle<Code> code_constant, | 659 Handle<Code> code_constant, |
| 660 const Operand& code_operand, | 660 const Operand& code_operand, |
| 661 Label* done, | 661 Label* done, |
| 662 InvokeFlag flag, | 662 InvokeFlag flag, |
| 663 Label::Distance done_near = Label::kFar, | 663 Label::Distance done_near = Label::kFar, |
| 664 const CallWrapper& call_wrapper = NullCallWrapper(), | 664 const CallWrapper& call_wrapper = NullCallWrapper(), |
| 665 CallKind call_kind = CALL_AS_METHOD); | 665 CallKind call_kind = CALL_AS_METHOD); |
| 666 | 666 |
| 667 // Activation support. | |
| 668 void EnterFrame(StackFrame::Type type); | |
| 669 void LeaveFrame(StackFrame::Type type); | |
| 670 | |
| 671 void EnterExitFramePrologue(); | 667 void EnterExitFramePrologue(); |
| 672 void EnterExitFrameEpilogue(int argc, bool save_doubles); | 668 void EnterExitFrameEpilogue(int argc, bool save_doubles); |
| 673 | 669 |
| 674 void LeaveExitFrameEpilogue(); | 670 void LeaveExitFrameEpilogue(); |
| 675 | 671 |
| 676 // Allocation support helpers. | 672 // Allocation support helpers. |
| 677 void LoadAllocationTopHelper(Register result, | 673 void LoadAllocationTopHelper(Register result, |
| 678 Register scratch, | 674 Register scratch, |
| 679 AllocationFlags flags); | 675 AllocationFlags flags); |
| 680 void UpdateAllocationTopHelper(Register result_end, Register scratch); | 676 void UpdateAllocationTopHelper(Register result_end, Register scratch); |
| 681 | 677 |
| 682 // Helper for PopHandleScope. Allowed to perform a GC and returns | 678 // Helper for PopHandleScope. Allowed to perform a GC and returns |
| 683 // NULL if gc_allowed. Does not perform a GC if !gc_allowed, and | 679 // NULL if gc_allowed. Does not perform a GC if !gc_allowed, and |
| 684 // possibly returns a failure object indicating an allocation failure. | 680 // possibly returns a failure object indicating an allocation failure. |
| 685 MUST_USE_RESULT MaybeObject* PopHandleScopeHelper(Register saved, | 681 MUST_USE_RESULT MaybeObject* PopHandleScopeHelper(Register saved, |
| 686 Register scratch, | 682 Register scratch, |
| 687 bool gc_allowed); | 683 bool gc_allowed); |
| 688 | 684 |
| 689 | 685 |
| 690 // Compute memory operands for safepoint stack slots. | 686 // Compute memory operands for safepoint stack slots. |
| 691 Operand SafepointRegisterSlot(Register reg); | 687 Operand SafepointRegisterSlot(Register reg); |
| 692 static int SafepointRegisterStackIndex(int reg_code); | 688 static int SafepointRegisterStackIndex(int reg_code); |
| 693 | 689 |
| 694 // Needs access to SafepointRegisterStackIndex for optimized frame | 690 // Needs access to SafepointRegisterStackIndex for optimized frame |
| 695 // traversal. | 691 // traversal. |
| 696 friend class OptimizedFrame; | 692 friend class OptimizedFrame; |
| 697 }; | 693 }; |
| 698 | 694 |
| 699 | 695 |
| 696 class FrameScope { |
| 697 public: |
| 698 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) |
| 699 : masm_(masm), type_(type) { |
| 700 ASSERT(!masm->has_frame()); |
| 701 masm->set_has_frame(true); |
| 702 if (type != StackFrame::NONE) { |
| 703 masm->EnterFrame(type); |
| 704 } |
| 705 } |
| 706 |
| 707 ~FrameScope() { |
| 708 if (type_ != StackFrame::NONE) { |
| 709 masm_->LeaveFrame(type_); |
| 710 } |
| 711 masm_->set_has_frame(false); |
| 712 } |
| 713 |
| 714 // Normally we generate the leave-frame code when this object goes |
| 715 // out of scope. Sometimes we may need to generate the code somewhere else |
| 716 // in addition. Calling this will achieve that, but the object stays in |
| 717 // scope, the MacroAssembler is still marked as being in a frame scope, and |
| 718 // the code will be generated again when it goes out of scope. |
| 719 void GenerateLeaveFrame() { |
| 720 masm_->LeaveFrame(type_); |
| 721 } |
| 722 |
| 723 private: |
| 724 MacroAssembler* masm_; |
| 725 StackFrame::Type type_; |
| 726 }; |
| 727 |
| 728 |
| 729 class NoCurrentFrameScope { |
| 730 public: |
| 731 explicit NoCurrentFrameScope(MacroAssembler* masm) |
| 732 : masm_(masm), saved_(masm->has_frame()) { |
| 733 masm->set_has_frame(false); |
| 734 } |
| 735 |
| 736 ~NoCurrentFrameScope() { |
| 737 masm_->set_has_frame(saved_); |
| 738 } |
| 739 |
| 740 private: |
| 741 MacroAssembler* masm_; |
| 742 bool saved_; |
| 743 }; |
| 744 |
| 745 |
| 700 // The code patcher is used to patch (typically) small parts of code e.g. for | 746 // The code patcher is used to patch (typically) small parts of code e.g. for |
| 701 // debugging and other types of instrumentation. When using the code patcher | 747 // debugging and other types of instrumentation. When using the code patcher |
| 702 // the exact number of bytes specified must be emitted. Is not legal to emit | 748 // the exact number of bytes specified must be emitted. Is not legal to emit |
| 703 // relocation information. If any of these constraints are violated it causes | 749 // relocation information. If any of these constraints are violated it causes |
| 704 // an assertion. | 750 // an assertion. |
| 705 class CodePatcher { | 751 class CodePatcher { |
| 706 public: | 752 public: |
| 707 CodePatcher(byte* address, int size); | 753 CodePatcher(byte* address, int size); |
| 708 virtual ~CodePatcher(); | 754 virtual ~CodePatcher(); |
| 709 | 755 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 } \ | 813 } \ |
| 768 masm-> | 814 masm-> |
| 769 #else | 815 #else |
| 770 #define ACCESS_MASM(masm) masm-> | 816 #define ACCESS_MASM(masm) masm-> |
| 771 #endif | 817 #endif |
| 772 | 818 |
| 773 | 819 |
| 774 } } // namespace v8::internal | 820 } } // namespace v8::internal |
| 775 | 821 |
| 776 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 822 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |