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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // ------------------------------------------------------------------------- | 574 // ------------------------------------------------------------------------- |
575 // Activation frames. | 575 // Activation frames. |
576 | 576 |
577 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | 577 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } |
578 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | 578 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } |
579 | 579 |
580 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | 580 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } |
581 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | 581 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } |
582 | 582 |
583 // Enter exit frame. | 583 // Enter exit frame. |
584 // Expects the number of arguments in register a0 and | 584 // argc - argument count to be dropped by LeaveExitFrame. |
585 // the builtin function to call in register a1. | 585 // save_doubles - saves FPU registers on stack, currently disabled. |
586 // On output hold_argc, hold_function, and hold_argv are setup. | 586 // stack_space - extra stack space. |
587 void EnterExitFrame(Register hold_argc, | 587 void EnterExitFrame(bool save_doubles, |
588 Register hold_argv, | 588 int stack_space = 0); |
589 Register hold_function, | |
590 bool save_doubles); | |
591 | 589 |
592 // Leave the current exit frame. Expects the return value in v0. | 590 // Leave the current exit frame. |
593 void LeaveExitFrame(bool save_doubles); | 591 void LeaveExitFrame(bool save_doubles, Register arg_count); |
594 | |
595 // Align the stack by optionally pushing a Smi zero. | |
596 void AlignStack(int offset); // TODO(mips) : remove this function. | |
597 | 592 |
598 // Get the actual activation frame alignment for target environment. | 593 // Get the actual activation frame alignment for target environment. |
599 static int ActivationFrameAlignment(); | 594 static int ActivationFrameAlignment(); |
600 | 595 |
| 596 // Make sure the stack is aligned. Only emits code in debug mode. |
| 597 void AssertStackIsAligned(); |
| 598 |
601 void LoadContext(Register dst, int context_chain_length); | 599 void LoadContext(Register dst, int context_chain_length); |
602 | 600 |
603 void LoadGlobalFunction(int index, Register function); | 601 void LoadGlobalFunction(int index, Register function); |
604 | 602 |
605 // Load the initial map from the global function. The registers | 603 // Load the initial map from the global function. The registers |
606 // function and map can be the same, function is then overwritten. | 604 // function and map can be the same, function is then overwritten. |
607 void LoadGlobalFunctionInitialMap(Register function, | 605 void LoadGlobalFunctionInitialMap(Register function, |
608 Register map, | 606 Register map, |
609 Register scratch); | 607 Register scratch); |
610 | 608 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 | 660 |
663 // Push a new try handler and link into try handler chain. | 661 // Push a new try handler and link into try handler chain. |
664 // The return address must be passed in register ra. | 662 // The return address must be passed in register ra. |
665 // Clobber t0, t1, t2. | 663 // Clobber t0, t1, t2. |
666 void PushTryHandler(CodeLocation try_location, HandlerType type); | 664 void PushTryHandler(CodeLocation try_location, HandlerType type); |
667 | 665 |
668 // Unlink the stack handler on top of the stack from the try handler chain. | 666 // Unlink the stack handler on top of the stack from the try handler chain. |
669 // Must preserve the result register. | 667 // Must preserve the result register. |
670 void PopTryHandler(); | 668 void PopTryHandler(); |
671 | 669 |
| 670 // Passes thrown value (in v0) to the handler of top of the try handler chain. |
| 671 void Throw(Register value); |
| 672 |
| 673 // Propagates an uncatchable exception to the top of the current JS stack's |
| 674 // handler chain. |
| 675 void ThrowUncatchable(UncatchableExceptionType type, Register value); |
| 676 |
672 // Copies a fixed number of fields of heap objects from src to dst. | 677 // Copies a fixed number of fields of heap objects from src to dst. |
673 void CopyFields(Register dst, Register src, RegList temps, int field_count); | 678 void CopyFields(Register dst, Register src, RegList temps, int field_count); |
674 | 679 |
675 // Copies a number of bytes from src to dst. All registers are clobbered. On | 680 // Copies a number of bytes from src to dst. All registers are clobbered. On |
676 // exit src and dst will point to the place just after where the last byte was | 681 // exit src and dst will point to the place just after where the last byte was |
677 // read or written and length will be zero. | 682 // read or written and length will be zero. |
678 void CopyBytes(Register src, | 683 void CopyBytes(Register src, |
679 Register dst, | 684 Register dst, |
680 Register length, | 685 Register length, |
681 Register scratch); | 686 Register scratch); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 Ret(ge, overflow_check, Operand(zero_reg), bd); | 788 Ret(ge, overflow_check, Operand(zero_reg), bd); |
784 } | 789 } |
785 | 790 |
786 // ------------------------------------------------------------------------- | 791 // ------------------------------------------------------------------------- |
787 // Runtime calls. | 792 // Runtime calls. |
788 | 793 |
789 // Call a code stub. | 794 // Call a code stub. |
790 void CallStub(CodeStub* stub, Condition cond = cc_always, | 795 void CallStub(CodeStub* stub, Condition cond = cc_always, |
791 Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg)); | 796 Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg)); |
792 | 797 |
| 798 // Call a code stub and return the code object called. Try to generate |
| 799 // the code if necessary. Do not perform a GC but instead return a retry |
| 800 // after GC failure. |
| 801 MUST_USE_RESULT MaybeObject* TryCallStub(CodeStub* stub, |
| 802 Condition cond = cc_always, |
| 803 Register r1 = zero_reg, |
| 804 const Operand& r2 = |
| 805 Operand(zero_reg)); |
| 806 |
793 // Tail call a code stub (jump). | 807 // Tail call a code stub (jump). |
794 void TailCallStub(CodeStub* stub); | 808 void TailCallStub(CodeStub* stub); |
795 | 809 |
| 810 // Tail call a code stub (jump) and return the code object called. Try to |
| 811 // generate the code if necessary. Do not perform a GC but instead return |
| 812 // a retry after GC failure. |
| 813 MUST_USE_RESULT MaybeObject* TryTailCallStub(CodeStub* stub, |
| 814 Condition cond = cc_always, |
| 815 Register r1 = zero_reg, |
| 816 const Operand& r2 = |
| 817 Operand(zero_reg)); |
| 818 |
796 void CallJSExitStub(CodeStub* stub); | 819 void CallJSExitStub(CodeStub* stub); |
797 | 820 |
798 // Call a runtime routine. | 821 // Call a runtime routine. |
799 void CallRuntime(const Runtime::Function* f, int num_arguments); | 822 void CallRuntime(const Runtime::Function* f, int num_arguments); |
800 void CallRuntimeSaveDoubles(Runtime::FunctionId id); | 823 void CallRuntimeSaveDoubles(Runtime::FunctionId id); |
801 | 824 |
802 // Convenience function: Same as above, but takes the fid instead. | 825 // Convenience function: Same as above, but takes the fid instead. |
803 void CallRuntime(Runtime::FunctionId fid, int num_arguments); | 826 void CallRuntime(Runtime::FunctionId fid, int num_arguments); |
804 | 827 |
805 // Convenience function: call an external reference. | 828 // Convenience function: call an external reference. |
806 void CallExternalReference(const ExternalReference& ext, | 829 void CallExternalReference(const ExternalReference& ext, |
807 int num_arguments); | 830 int num_arguments); |
808 | 831 |
809 // Tail call of a runtime routine (jump). | 832 // Tail call of a runtime routine (jump). |
810 // Like JumpToExternalReference, but also takes care of passing the number | 833 // Like JumpToExternalReference, but also takes care of passing the number |
811 // of parameters. | 834 // of parameters. |
812 void TailCallExternalReference(const ExternalReference& ext, | 835 void TailCallExternalReference(const ExternalReference& ext, |
813 int num_arguments, | 836 int num_arguments, |
814 int result_size); | 837 int result_size); |
815 | 838 |
| 839 // Tail call of a runtime routine (jump). Try to generate the code if |
| 840 // necessary. Do not perform a GC but instead return a retry after GC |
| 841 // failure. |
| 842 MUST_USE_RESULT MaybeObject* TryTailCallExternalReference( |
| 843 const ExternalReference& ext, int num_arguments, int result_size); |
| 844 |
816 // Convenience function: tail call a runtime routine (jump). | 845 // Convenience function: tail call a runtime routine (jump). |
817 void TailCallRuntime(Runtime::FunctionId fid, | 846 void TailCallRuntime(Runtime::FunctionId fid, |
818 int num_arguments, | 847 int num_arguments, |
819 int result_size); | 848 int result_size); |
820 | 849 |
821 // Before calling a C-function from generated code, align arguments on stack | 850 // Before calling a C-function from generated code, align arguments on stack |
822 // and add space for the four mips argument slots. | 851 // and add space for the four mips argument slots. |
823 // After aligning the frame, non-register arguments must be stored on the | 852 // After aligning the frame, non-register arguments must be stored on the |
824 // stack, after the argument-slots using helper: CFunctionArgumentOperand(). | 853 // stack, after the argument-slots using helper: CFunctionArgumentOperand(). |
825 // The argument count assumes all arguments are word sized. | 854 // The argument count assumes all arguments are word sized. |
826 // Some compilers/platforms require the stack to be aligned when calling | 855 // Some compilers/platforms require the stack to be aligned when calling |
827 // C++ code. | 856 // C++ code. |
828 // Needs a scratch register to do some arithmetic. This register will be | 857 // Needs a scratch register to do some arithmetic. This register will be |
829 // trashed. | 858 // trashed. |
830 void PrepareCallCFunction(int num_arguments, Register scratch); | 859 void PrepareCallCFunction(int num_arguments, Register scratch); |
831 | 860 |
832 // Arguments 1-4 are placed in registers a0 thru a3 respectively. | 861 // Arguments 1-4 are placed in registers a0 thru a3 respectively. |
833 // Arguments 5..n are stored to stack using following: | 862 // Arguments 5..n are stored to stack using following: |
834 // sw(t0, CFunctionArgumentOperand(5)); | 863 // sw(t0, CFunctionArgumentOperand(5)); |
835 | 864 |
836 // Calls a C function and cleans up the space for arguments allocated | 865 // Calls a C function and cleans up the space for arguments allocated |
837 // by PrepareCallCFunction. The called function is not allowed to trigger a | 866 // by PrepareCallCFunction. The called function is not allowed to trigger a |
838 // garbage collection, since that might move the code and invalidate the | 867 // garbage collection, since that might move the code and invalidate the |
839 // return address (unless this is somehow accounted for by the called | 868 // return address (unless this is somehow accounted for by the called |
840 // function). | 869 // function). |
841 void CallCFunction(ExternalReference function, int num_arguments); | 870 void CallCFunction(ExternalReference function, int num_arguments); |
842 void CallCFunction(Register function, Register scratch, int num_arguments); | 871 void CallCFunction(Register function, Register scratch, int num_arguments); |
| 872 void GetCFunctionDoubleResult(const DoubleRegister dst); |
843 | 873 |
844 void GetCFunctionDoubleResult(const DoubleRegister dst); | 874 // Calls an API function. Allocates HandleScope, extracts returned value |
| 875 // from handle and propagates exceptions. Restores context. |
| 876 MaybeObject* TryCallApiFunctionAndReturn(ExternalReference function, |
| 877 int stack_space); |
845 | 878 |
846 // Jump to the builtin routine. | 879 // Jump to the builtin routine. |
847 void JumpToExternalReference(const ExternalReference& builtin); | 880 void JumpToExternalReference(const ExternalReference& builtin); |
848 | 881 |
| 882 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext); |
| 883 |
849 // Invoke specified builtin JavaScript function. Adds an entry to | 884 // Invoke specified builtin JavaScript function. Adds an entry to |
850 // the unresolved list if the name does not resolve. | 885 // the unresolved list if the name does not resolve. |
851 void InvokeBuiltin(Builtins::JavaScript id, | 886 void InvokeBuiltin(Builtins::JavaScript id, |
852 InvokeFlag flag, | 887 InvokeFlag flag, |
853 const CallWrapper& call_wrapper = NullCallWrapper()); | 888 const CallWrapper& call_wrapper = NullCallWrapper()); |
854 | 889 |
855 // Store the code object for the given builtin in the target register and | 890 // Store the code object for the given builtin in the target register and |
856 // setup the function in a1. | 891 // setup the function in a1. |
857 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 892 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
858 | 893 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1165 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
1131 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1166 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
1132 #else | 1167 #else |
1133 #define ACCESS_MASM(masm) masm-> | 1168 #define ACCESS_MASM(masm) masm-> |
1134 #endif | 1169 #endif |
1135 | 1170 |
1136 } } // namespace v8::internal | 1171 } } // namespace v8::internal |
1137 | 1172 |
1138 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 1173 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
1139 | 1174 |
OLD | NEW |