OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | 148 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } |
149 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | 149 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } |
150 | 150 |
151 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | 151 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } |
152 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | 152 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } |
153 | 153 |
154 // Enter specific kind of exit frame; either in normal or | 154 // Enter specific kind of exit frame; either in normal or |
155 // debug mode. Expects the number of arguments in register rax and | 155 // debug mode. Expects the number of arguments in register rax and |
156 // sets up the number of arguments in register rdi and the pointer | 156 // sets up the number of arguments in register rdi and the pointer |
157 // to the first argument in register rsi. | 157 // to the first argument in register rsi. |
158 void EnterExitFrame(int result_size = 1); | 158 // |
| 159 // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack |
| 160 // accessible via StackSpaceOperand. |
| 161 void EnterExitFrame(int arg_stack_space = 0); |
159 | 162 |
160 void EnterApiExitFrame(int stack_space, | 163 void EnterApiExitFrame(int stack_space, |
161 int argc, | 164 int arg_stack_space); |
162 int result_size = 1); | |
163 | 165 |
164 // Leave the current exit frame. Expects/provides the return value in | 166 // Leave the current exit frame. Expects/provides the return value in |
165 // register rax:rdx (untouched) and the pointer to the first | 167 // register rax:rdx (untouched) and the pointer to the first |
166 // argument in register rsi. | 168 // argument in register rsi. |
167 void LeaveExitFrame(int result_size = 1); | 169 void LeaveExitFrame(int result_size = 1); |
168 | 170 |
169 | 171 |
170 // --------------------------------------------------------------------------- | 172 // --------------------------------------------------------------------------- |
171 // JavaScript invokes | 173 // JavaScript invokes |
172 | 174 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // Jump to a runtime routine. | 833 // Jump to a runtime routine. |
832 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext, | 834 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext, |
833 int result_size); | 835 int result_size); |
834 | 836 |
835 // Prepares stack to put arguments (aligns and so on). | 837 // Prepares stack to put arguments (aligns and so on). |
836 // Uses callee-saved rsi to restore stack state after call. WIN64 calling | 838 // Uses callee-saved rsi to restore stack state after call. WIN64 calling |
837 // convention requires to put the pointer to the return value slot into rcx | 839 // convention requires to put the pointer to the return value slot into rcx |
838 // (rcx must be preserverd until TryCallApiFunctionAndReturn). argc is number | 840 // (rcx must be preserverd until TryCallApiFunctionAndReturn). argc is number |
839 // of arguments to be passed in C-function. stack_space * kPointerSize bytes | 841 // of arguments to be passed in C-function. stack_space * kPointerSize bytes |
840 // will be removed from stack after the call. Saves context (rsi). | 842 // will be removed from stack after the call. Saves context (rsi). |
841 void PrepareCallApiFunction(int stack_space, int argc); | 843 // Clobbers rax. Allocates arg_stack_space * kPointerSize inside the exit |
| 844 // frame (not GCed). |
| 845 // |
| 846 // Assumes stack_space GCed references on top of the stack and return address. |
| 847 // After call they will be removed. |
| 848 void PrepareCallApiFunction(int stack_space, int arg_stack_space); |
842 | 849 |
843 // Calls an API function. Allocates HandleScope, extracts | 850 // Calls an API function. Allocates HandleScope, extracts |
844 // returned value from handle and propagates exceptions. | 851 // returned value from handle and propagates exceptions. |
845 // Clobbers r12, r14, rbx and caller-save registers. Restores context. | 852 // Clobbers r12, r14, rbx and caller-save registers. Restores context. |
846 MUST_USE_RESULT MaybeObject* TryCallApiFunctionAndReturn( | 853 MUST_USE_RESULT MaybeObject* TryCallApiFunctionAndReturn( |
847 ApiFunction* function); | 854 ApiFunction* function); |
848 | 855 |
849 // Before calling a C-function from generated code, align arguments on stack. | 856 // Before calling a C-function from generated code, align arguments on stack. |
850 // After aligning the frame, arguments must be stored in esp[0], esp[4], | 857 // After aligning the frame, arguments must be stored in esp[0], esp[4], |
851 // etc., not pushed. The argument count assumes all arguments are word sized. | 858 // etc., not pushed. The argument count assumes all arguments are word sized. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 Handle<Code> code_constant, | 935 Handle<Code> code_constant, |
929 Register code_register, | 936 Register code_register, |
930 LabelType* done, | 937 LabelType* done, |
931 InvokeFlag flag); | 938 InvokeFlag flag); |
932 | 939 |
933 // Activation support. | 940 // Activation support. |
934 void EnterFrame(StackFrame::Type type); | 941 void EnterFrame(StackFrame::Type type); |
935 void LeaveFrame(StackFrame::Type type); | 942 void LeaveFrame(StackFrame::Type type); |
936 | 943 |
937 void EnterExitFramePrologue(bool save_rax); | 944 void EnterExitFramePrologue(bool save_rax); |
938 void EnterExitFrameEpilogue(int result_size, int argc); | 945 |
| 946 // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack |
| 947 // accessible via StackSpaceOperand. |
| 948 void EnterExitFrameEpilogue(int arg_stack_space); |
939 | 949 |
940 // Allocation support helpers. | 950 // Allocation support helpers. |
941 // Loads the top of new-space into the result register. | 951 // Loads the top of new-space into the result register. |
942 // If flags contains RESULT_CONTAINS_TOP then result_end is valid and | 952 // If flags contains RESULT_CONTAINS_TOP then result_end is valid and |
943 // already contains the top of new-space, and scratch is invalid. | 953 // already contains the top of new-space, and scratch is invalid. |
944 // Otherwise the address of the new-space top is loaded into scratch (if | 954 // Otherwise the address of the new-space top is loaded into scratch (if |
945 // scratch is valid), and the new-space top is loaded into result. | 955 // scratch is valid), and the new-space top is loaded into result. |
946 void LoadAllocationTopHelper(Register result, | 956 void LoadAllocationTopHelper(Register result, |
947 Register result_end, | 957 Register result_end, |
948 Register scratch, | 958 Register scratch, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 static inline Operand ContextOperand(Register context, int index) { | 1011 static inline Operand ContextOperand(Register context, int index) { |
1002 return Operand(context, Context::SlotOffset(index)); | 1012 return Operand(context, Context::SlotOffset(index)); |
1003 } | 1013 } |
1004 | 1014 |
1005 | 1015 |
1006 static inline Operand GlobalObjectOperand() { | 1016 static inline Operand GlobalObjectOperand() { |
1007 return ContextOperand(rsi, Context::GLOBAL_INDEX); | 1017 return ContextOperand(rsi, Context::GLOBAL_INDEX); |
1008 } | 1018 } |
1009 | 1019 |
1010 | 1020 |
| 1021 // Provides access to exit frame stack space (not GCed). |
| 1022 static inline Operand StackSpaceOperand(int index) { |
| 1023 #ifdef _WIN64 |
| 1024 const int kShaddowSpace = 4; |
| 1025 return Operand(rsp, (index + kShaddowSpace) * kPointerSize); |
| 1026 #else |
| 1027 return Operand(rsp, index * kPointerSize); |
| 1028 #endif |
| 1029 } |
| 1030 |
| 1031 |
1011 | 1032 |
1012 #ifdef GENERATED_CODE_COVERAGE | 1033 #ifdef GENERATED_CODE_COVERAGE |
1013 extern void LogGeneratedCodeCoverage(const char* file_line); | 1034 extern void LogGeneratedCodeCoverage(const char* file_line); |
1014 #define CODE_COVERAGE_STRINGIFY(x) #x | 1035 #define CODE_COVERAGE_STRINGIFY(x) #x |
1015 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1036 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
1016 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1037 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
1017 #define ACCESS_MASM(masm) { \ | 1038 #define ACCESS_MASM(masm) { \ |
1018 byte* x64_coverage_function = \ | 1039 byte* x64_coverage_function = \ |
1019 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ | 1040 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ |
1020 masm->pushfd(); \ | 1041 masm->pushfd(); \ |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 Jump(adaptor, RelocInfo::CODE_TARGET); | 1739 Jump(adaptor, RelocInfo::CODE_TARGET); |
1719 } | 1740 } |
1720 bind(&invoke); | 1741 bind(&invoke); |
1721 } | 1742 } |
1722 } | 1743 } |
1723 | 1744 |
1724 | 1745 |
1725 } } // namespace v8::internal | 1746 } } // namespace v8::internal |
1726 | 1747 |
1727 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1748 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |