| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // new space. | 44 // new space. |
| 45 RESULT_CONTAINS_TOP = 1 << 1 | 45 RESULT_CONTAINS_TOP = 1 << 1 |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // Convenience for platform-independent signatures. We do not normally | 48 // Convenience for platform-independent signatures. We do not normally |
| 49 // distinguish memory operands from other operands on ia32. | 49 // distinguish memory operands from other operands on ia32. |
| 50 typedef Operand MemOperand; | 50 typedef Operand MemOperand; |
| 51 | 51 |
| 52 // Forward declaration. | 52 // Forward declaration. |
| 53 class JumpTarget; | 53 class JumpTarget; |
| 54 class PostCallGenerator; |
| 54 | 55 |
| 55 // MacroAssembler implements a collection of frequently used macros. | 56 // MacroAssembler implements a collection of frequently used macros. |
| 56 class MacroAssembler: public Assembler { | 57 class MacroAssembler: public Assembler { |
| 57 public: | 58 public: |
| 58 MacroAssembler(void* buffer, int size); | 59 MacroAssembler(void* buffer, int size); |
| 59 | 60 |
| 60 // --------------------------------------------------------------------------- | 61 // --------------------------------------------------------------------------- |
| 61 // GC Support | 62 // GC Support |
| 62 | 63 |
| 63 // For page containing |object| mark region covering |addr| dirty. | 64 // For page containing |object| mark region covering |addr| dirty. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 Register value); | 97 Register value); |
| 97 | 98 |
| 98 #ifdef ENABLE_DEBUGGER_SUPPORT | 99 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 99 // --------------------------------------------------------------------------- | 100 // --------------------------------------------------------------------------- |
| 100 // Debugger Support | 101 // Debugger Support |
| 101 | 102 |
| 102 void DebugBreak(); | 103 void DebugBreak(); |
| 103 #endif | 104 #endif |
| 104 | 105 |
| 105 // --------------------------------------------------------------------------- | 106 // --------------------------------------------------------------------------- |
| 106 // Stack limit support | |
| 107 | |
| 108 // Do simple test for stack overflow. This doesn't handle an overflow. | |
| 109 void StackLimitCheck(Label* on_stack_limit_hit); | |
| 110 | |
| 111 // --------------------------------------------------------------------------- | |
| 112 // Activation frames | 107 // Activation frames |
| 113 | 108 |
| 114 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | 109 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } |
| 115 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | 110 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } |
| 116 | 111 |
| 117 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | 112 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } |
| 118 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | 113 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } |
| 119 | 114 |
| 120 // Enter specific kind of exit frame; either in normal or debug mode. | 115 // Enter specific kind of exit frame. Expects the number of |
| 121 // Expects the number of arguments in register eax and | 116 // arguments in register eax and sets up the number of arguments in |
| 122 // sets up the number of arguments in register edi and the pointer | 117 // register edi and the pointer to the first argument in register |
| 123 // to the first argument in register esi. | 118 // esi. |
| 124 void EnterExitFrame(); | 119 void EnterExitFrame(bool save_doubles); |
| 125 | 120 |
| 126 void EnterApiExitFrame(int argc); | 121 void EnterApiExitFrame(int argc); |
| 127 | 122 |
| 128 // Leave the current exit frame. Expects the return value in | 123 // Leave the current exit frame. Expects the return value in |
| 129 // register eax:edx (untouched) and the pointer to the first | 124 // register eax:edx (untouched) and the pointer to the first |
| 130 // argument in register esi. | 125 // argument in register esi. |
| 131 void LeaveExitFrame(); | 126 void LeaveExitFrame(bool save_doubles); |
| 132 | 127 |
| 133 // Leave the current exit frame. Expects the return value in | 128 // Leave the current exit frame. Expects the return value in |
| 134 // register eax (untouched). | 129 // register eax (untouched). |
| 135 void LeaveApiExitFrame(); | 130 void LeaveApiExitFrame(); |
| 136 | 131 |
| 137 // Find the function context up the context chain. | 132 // Find the function context up the context chain. |
| 138 void LoadContext(Register dst, int context_chain_length); | 133 void LoadContext(Register dst, int context_chain_length); |
| 139 | 134 |
| 140 // Load the global function with the given index. | 135 // Load the global function with the given index. |
| 141 void LoadGlobalFunction(int index, Register function); | 136 void LoadGlobalFunction(int index, Register function); |
| 142 | 137 |
| 143 // Load the initial map from the global function. The registers | 138 // Load the initial map from the global function. The registers |
| 144 // function and map can be the same. | 139 // function and map can be the same. |
| 145 void LoadGlobalFunctionInitialMap(Register function, Register map); | 140 void LoadGlobalFunctionInitialMap(Register function, Register map); |
| 146 | 141 |
| 142 // Push and pop the registers that can hold pointers. |
| 143 void PushSafepointRegisters() { pushad(); } |
| 144 void PopSafepointRegisters() { popad(); } |
| 145 static int SafepointRegisterStackIndex(int reg_code); |
| 146 |
| 147 // --------------------------------------------------------------------------- | 147 // --------------------------------------------------------------------------- |
| 148 // JavaScript invokes | 148 // JavaScript invokes |
| 149 | 149 |
| 150 // Invoke the JavaScript function code by either calling or jumping. | 150 // Invoke the JavaScript function code by either calling or jumping. |
| 151 void InvokeCode(const Operand& code, | 151 void InvokeCode(const Operand& code, |
| 152 const ParameterCount& expected, | 152 const ParameterCount& expected, |
| 153 const ParameterCount& actual, | 153 const ParameterCount& actual, |
| 154 InvokeFlag flag); | 154 InvokeFlag flag, |
| 155 PostCallGenerator* post_call_generator = NULL); |
| 155 | 156 |
| 156 void InvokeCode(Handle<Code> code, | 157 void InvokeCode(Handle<Code> code, |
| 157 const ParameterCount& expected, | 158 const ParameterCount& expected, |
| 158 const ParameterCount& actual, | 159 const ParameterCount& actual, |
| 159 RelocInfo::Mode rmode, | 160 RelocInfo::Mode rmode, |
| 160 InvokeFlag flag); | 161 InvokeFlag flag, |
| 162 PostCallGenerator* post_call_generator = NULL); |
| 161 | 163 |
| 162 // Invoke the JavaScript function in the given register. Changes the | 164 // Invoke the JavaScript function in the given register. Changes the |
| 163 // current context to the context in the function before invoking. | 165 // current context to the context in the function before invoking. |
| 164 void InvokeFunction(Register function, | 166 void InvokeFunction(Register function, |
| 165 const ParameterCount& actual, | 167 const ParameterCount& actual, |
| 166 InvokeFlag flag); | 168 InvokeFlag flag, |
| 169 PostCallGenerator* post_call_generator = NULL); |
| 167 | 170 |
| 168 void InvokeFunction(JSFunction* function, | 171 void InvokeFunction(JSFunction* function, |
| 169 const ParameterCount& actual, | 172 const ParameterCount& actual, |
| 170 InvokeFlag flag); | 173 InvokeFlag flag, |
| 174 PostCallGenerator* post_call_generator = NULL); |
| 171 | 175 |
| 172 // Invoke specified builtin JavaScript function. Adds an entry to | 176 // Invoke specified builtin JavaScript function. Adds an entry to |
| 173 // the unresolved list if the name does not resolve. | 177 // the unresolved list if the name does not resolve. |
| 174 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); | 178 void InvokeBuiltin(Builtins::JavaScript id, |
| 179 InvokeFlag flag, |
| 180 PostCallGenerator* post_call_generator = NULL); |
| 175 | 181 |
| 176 // Store the function for the given builtin in the target register. | 182 // Store the function for the given builtin in the target register. |
| 177 void GetBuiltinFunction(Register target, Builtins::JavaScript id); | 183 void GetBuiltinFunction(Register target, Builtins::JavaScript id); |
| 178 | 184 |
| 179 // Store the code object for the given builtin in the target register. | 185 // Store the code object for the given builtin in the target register. |
| 180 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 186 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
| 181 | 187 |
| 182 // Expression support | 188 // Expression support |
| 183 void Set(Register dst, const Immediate& x); | 189 void Set(Register dst, const Immediate& x); |
| 184 void Set(const Operand& dst, const Immediate& x); | 190 void Set(const Operand& dst, const Immediate& x); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // Tail call a code stub (jump) and return the code object called. Try to | 456 // Tail call a code stub (jump) and return the code object called. Try to |
| 451 // generate the code if necessary. Do not perform a GC but instead return | 457 // generate the code if necessary. Do not perform a GC but instead return |
| 452 // a retry after GC failure. | 458 // a retry after GC failure. |
| 453 MUST_USE_RESULT MaybeObject* TryTailCallStub(CodeStub* stub); | 459 MUST_USE_RESULT MaybeObject* TryTailCallStub(CodeStub* stub); |
| 454 | 460 |
| 455 // Return from a code stub after popping its arguments. | 461 // Return from a code stub after popping its arguments. |
| 456 void StubReturn(int argc); | 462 void StubReturn(int argc); |
| 457 | 463 |
| 458 // Call a runtime routine. | 464 // Call a runtime routine. |
| 459 void CallRuntime(const Runtime::Function* f, int num_arguments); | 465 void CallRuntime(const Runtime::Function* f, int num_arguments); |
| 466 void CallRuntimeSaveDoubles(Runtime::FunctionId id); |
| 460 | 467 |
| 461 // Call a runtime function, returning the CodeStub object called. | 468 // Call a runtime function, returning the CodeStub object called. |
| 462 // Try to generate the stub code if necessary. Do not perform a GC | 469 // Try to generate the stub code if necessary. Do not perform a GC |
| 463 // but instead return a retry after GC failure. | 470 // but instead return a retry after GC failure. |
| 464 MUST_USE_RESULT MaybeObject* TryCallRuntime(const Runtime::Function* f, | 471 MUST_USE_RESULT MaybeObject* TryCallRuntime(const Runtime::Function* f, |
| 465 int num_arguments); | 472 int num_arguments); |
| 466 | 473 |
| 467 // Convenience function: Same as above, but takes the fid instead. | 474 // Convenience function: Same as above, but takes the fid instead. |
| 468 void CallRuntime(Runtime::FunctionId id, int num_arguments); | 475 void CallRuntime(Runtime::FunctionId id, int num_arguments); |
| 469 | 476 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // Utilities | 546 // Utilities |
| 540 | 547 |
| 541 void Ret(); | 548 void Ret(); |
| 542 | 549 |
| 543 // Emit code to discard a non-negative number of pointer-sized elements | 550 // Emit code to discard a non-negative number of pointer-sized elements |
| 544 // from the stack, clobbering only the esp register. | 551 // from the stack, clobbering only the esp register. |
| 545 void Drop(int element_count); | 552 void Drop(int element_count); |
| 546 | 553 |
| 547 void Call(Label* target) { call(target); } | 554 void Call(Label* target) { call(target); } |
| 548 | 555 |
| 556 // Emit call to the code we are currently generating. |
| 557 void CallSelf() { |
| 558 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); |
| 559 call(self, RelocInfo::CODE_TARGET); |
| 560 } |
| 561 |
| 549 // Move if the registers are not identical. | 562 // Move if the registers are not identical. |
| 550 void Move(Register target, Register source); | 563 void Move(Register target, Register source); |
| 551 | 564 |
| 552 void Move(Register target, Handle<Object> value); | 565 void Move(Register target, Handle<Object> value); |
| 553 | 566 |
| 554 Handle<Object> CodeObject() { return code_object_; } | 567 Handle<Object> CodeObject() { return code_object_; } |
| 555 | 568 |
| 556 | 569 |
| 557 // --------------------------------------------------------------------------- | 570 // --------------------------------------------------------------------------- |
| 558 // StatsCounter support | 571 // StatsCounter support |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 bool allow_stub_calls_; | 624 bool allow_stub_calls_; |
| 612 // This handle will be patched with the code object on installation. | 625 // This handle will be patched with the code object on installation. |
| 613 Handle<Object> code_object_; | 626 Handle<Object> code_object_; |
| 614 | 627 |
| 615 // Helper functions for generating invokes. | 628 // Helper functions for generating invokes. |
| 616 void InvokePrologue(const ParameterCount& expected, | 629 void InvokePrologue(const ParameterCount& expected, |
| 617 const ParameterCount& actual, | 630 const ParameterCount& actual, |
| 618 Handle<Code> code_constant, | 631 Handle<Code> code_constant, |
| 619 const Operand& code_operand, | 632 const Operand& code_operand, |
| 620 Label* done, | 633 Label* done, |
| 621 InvokeFlag flag); | 634 InvokeFlag flag, |
| 635 PostCallGenerator* post_call_generator = NULL); |
| 622 | 636 |
| 623 // Activation support. | 637 // Activation support. |
| 624 void EnterFrame(StackFrame::Type type); | 638 void EnterFrame(StackFrame::Type type); |
| 625 void LeaveFrame(StackFrame::Type type); | 639 void LeaveFrame(StackFrame::Type type); |
| 626 | 640 |
| 627 void EnterExitFramePrologue(); | 641 void EnterExitFramePrologue(); |
| 628 void EnterExitFrameEpilogue(int argc); | 642 void EnterExitFrameEpilogue(int argc, bool save_doubles); |
| 629 | 643 |
| 630 void LeaveExitFrameEpilogue(); | 644 void LeaveExitFrameEpilogue(); |
| 631 | 645 |
| 632 // Allocation support helpers. | 646 // Allocation support helpers. |
| 633 void LoadAllocationTopHelper(Register result, | 647 void LoadAllocationTopHelper(Register result, |
| 634 Register scratch, | 648 Register scratch, |
| 635 AllocationFlags flags); | 649 AllocationFlags flags); |
| 636 void UpdateAllocationTopHelper(Register result_end, Register scratch); | 650 void UpdateAllocationTopHelper(Register result_end, Register scratch); |
| 637 | 651 |
| 638 // Helper for PopHandleScope. Allowed to perform a GC and returns | 652 // Helper for PopHandleScope. Allowed to perform a GC and returns |
| (...skipping 18 matching lines...) Expand all Loading... |
| 657 // Macro assembler to emit code. | 671 // Macro assembler to emit code. |
| 658 MacroAssembler* masm() { return &masm_; } | 672 MacroAssembler* masm() { return &masm_; } |
| 659 | 673 |
| 660 private: | 674 private: |
| 661 byte* address_; // The address of the code being patched. | 675 byte* address_; // The address of the code being patched. |
| 662 int size_; // Number of bytes of the expected patch size. | 676 int size_; // Number of bytes of the expected patch size. |
| 663 MacroAssembler masm_; // Macro assembler used to generate the code. | 677 MacroAssembler masm_; // Macro assembler used to generate the code. |
| 664 }; | 678 }; |
| 665 | 679 |
| 666 | 680 |
| 681 // Helper class for generating code or data associated with the code |
| 682 // right after a call instruction. As an example this can be used to |
| 683 // generate safepoint data after calls for crankshaft. |
| 684 class PostCallGenerator { |
| 685 public: |
| 686 PostCallGenerator() { } |
| 687 virtual ~PostCallGenerator() { } |
| 688 virtual void Generate() = 0; |
| 689 }; |
| 690 |
| 691 |
| 667 // ----------------------------------------------------------------------------- | 692 // ----------------------------------------------------------------------------- |
| 668 // Static helper functions. | 693 // Static helper functions. |
| 669 | 694 |
| 670 // Generate an Operand for loading a field from an object. | 695 // Generate an Operand for loading a field from an object. |
| 671 static inline Operand FieldOperand(Register object, int offset) { | 696 static inline Operand FieldOperand(Register object, int offset) { |
| 672 return Operand(object, offset - kHeapObjectTag); | 697 return Operand(object, offset - kHeapObjectTag); |
| 673 } | 698 } |
| 674 | 699 |
| 675 | 700 |
| 676 // Generate an Operand for loading an indexed field from an object. | 701 // Generate an Operand for loading an indexed field from an object. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } \ | 739 } \ |
| 715 masm-> | 740 masm-> |
| 716 #else | 741 #else |
| 717 #define ACCESS_MASM(masm) masm-> | 742 #define ACCESS_MASM(masm) masm-> |
| 718 #endif | 743 #endif |
| 719 | 744 |
| 720 | 745 |
| 721 } } // namespace v8::internal | 746 } } // namespace v8::internal |
| 722 | 747 |
| 723 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 748 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |