OLD | NEW |
1 // Copyright 2010 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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 static const Register kSmiConstantRegister = { 15 }; // r15 (callee save). | 51 static const Register kSmiConstantRegister = { 15 }; // r15 (callee save). |
52 static const Register kRootRegister = { 13 }; // r13 (callee save). | 52 static const Register kRootRegister = { 13 }; // r13 (callee save). |
53 // Value of smi in kSmiConstantRegister. | 53 // Value of smi in kSmiConstantRegister. |
54 static const int kSmiConstantRegisterValue = 1; | 54 static const int kSmiConstantRegisterValue = 1; |
55 | 55 |
56 // Convenience for platform-independent signatures. | 56 // Convenience for platform-independent signatures. |
57 typedef Operand MemOperand; | 57 typedef Operand MemOperand; |
58 | 58 |
59 // Forward declaration. | 59 // Forward declaration. |
60 class JumpTarget; | 60 class JumpTarget; |
| 61 class PostCallGenerator; |
61 | 62 |
62 struct SmiIndex { | 63 struct SmiIndex { |
63 SmiIndex(Register index_register, ScaleFactor scale) | 64 SmiIndex(Register index_register, ScaleFactor scale) |
64 : reg(index_register), | 65 : reg(index_register), |
65 scale(scale) {} | 66 scale(scale) {} |
66 Register reg; | 67 Register reg; |
67 ScaleFactor scale; | 68 ScaleFactor scale; |
68 }; | 69 }; |
69 | 70 |
70 // MacroAssembler implements a collection of frequently used macros. | 71 // MacroAssembler implements a collection of frequently used macros. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 177 } |
177 | 178 |
178 | 179 |
179 // --------------------------------------------------------------------------- | 180 // --------------------------------------------------------------------------- |
180 // JavaScript invokes | 181 // JavaScript invokes |
181 | 182 |
182 // Invoke the JavaScript function code by either calling or jumping. | 183 // Invoke the JavaScript function code by either calling or jumping. |
183 void InvokeCode(Register code, | 184 void InvokeCode(Register code, |
184 const ParameterCount& expected, | 185 const ParameterCount& expected, |
185 const ParameterCount& actual, | 186 const ParameterCount& actual, |
186 InvokeFlag flag); | 187 InvokeFlag flag, |
| 188 PostCallGenerator* post_call_generator = NULL); |
187 | 189 |
188 void InvokeCode(Handle<Code> code, | 190 void InvokeCode(Handle<Code> code, |
189 const ParameterCount& expected, | 191 const ParameterCount& expected, |
190 const ParameterCount& actual, | 192 const ParameterCount& actual, |
191 RelocInfo::Mode rmode, | 193 RelocInfo::Mode rmode, |
192 InvokeFlag flag); | 194 InvokeFlag flag, |
| 195 PostCallGenerator* post_call_generator = NULL); |
193 | 196 |
194 // Invoke the JavaScript function in the given register. Changes the | 197 // Invoke the JavaScript function in the given register. Changes the |
195 // current context to the context in the function before invoking. | 198 // current context to the context in the function before invoking. |
196 void InvokeFunction(Register function, | 199 void InvokeFunction(Register function, |
197 const ParameterCount& actual, | 200 const ParameterCount& actual, |
198 InvokeFlag flag); | 201 InvokeFlag flag, |
| 202 PostCallGenerator* post_call_generator = NULL); |
199 | 203 |
200 void InvokeFunction(JSFunction* function, | 204 void InvokeFunction(JSFunction* function, |
201 const ParameterCount& actual, | 205 const ParameterCount& actual, |
202 InvokeFlag flag); | 206 InvokeFlag flag, |
| 207 PostCallGenerator* post_call_generator = NULL); |
203 | 208 |
204 // Invoke specified builtin JavaScript function. Adds an entry to | 209 // Invoke specified builtin JavaScript function. Adds an entry to |
205 // the unresolved list if the name does not resolve. | 210 // the unresolved list if the name does not resolve. |
206 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); | 211 void InvokeBuiltin(Builtins::JavaScript id, |
| 212 InvokeFlag flag, |
| 213 PostCallGenerator* post_call_generator = NULL); |
207 | 214 |
208 // Store the function for the given builtin in the target register. | 215 // Store the function for the given builtin in the target register. |
209 void GetBuiltinFunction(Register target, Builtins::JavaScript id); | 216 void GetBuiltinFunction(Register target, Builtins::JavaScript id); |
210 | 217 |
211 // Store the code object for the given builtin in the target register. | 218 // Store the code object for the given builtin in the target register. |
212 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 219 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
213 | 220 |
214 | 221 |
215 // --------------------------------------------------------------------------- | 222 // --------------------------------------------------------------------------- |
216 // Smi tagging, untagging and operations on tagged smis. | 223 // Smi tagging, untagging and operations on tagged smis. |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 // This handle will be patched with the code object on installation. | 996 // This handle will be patched with the code object on installation. |
990 Handle<Object> code_object_; | 997 Handle<Object> code_object_; |
991 | 998 |
992 // Helper functions for generating invokes. | 999 // Helper functions for generating invokes. |
993 template <typename LabelType> | 1000 template <typename LabelType> |
994 void InvokePrologue(const ParameterCount& expected, | 1001 void InvokePrologue(const ParameterCount& expected, |
995 const ParameterCount& actual, | 1002 const ParameterCount& actual, |
996 Handle<Code> code_constant, | 1003 Handle<Code> code_constant, |
997 Register code_register, | 1004 Register code_register, |
998 LabelType* done, | 1005 LabelType* done, |
999 InvokeFlag flag); | 1006 InvokeFlag flag, |
| 1007 PostCallGenerator* post_call_generator); |
1000 | 1008 |
1001 // Activation support. | 1009 // Activation support. |
1002 void EnterFrame(StackFrame::Type type); | 1010 void EnterFrame(StackFrame::Type type); |
1003 void LeaveFrame(StackFrame::Type type); | 1011 void LeaveFrame(StackFrame::Type type); |
1004 | 1012 |
1005 void EnterExitFramePrologue(bool save_rax); | 1013 void EnterExitFramePrologue(bool save_rax); |
1006 | 1014 |
1007 // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack | 1015 // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack |
1008 // accessible via StackSpaceOperand. | 1016 // accessible via StackSpaceOperand. |
1009 void EnterExitFrameEpilogue(int arg_stack_space, bool save_doubles); | 1017 void EnterExitFrameEpilogue(int arg_stack_space, bool save_doubles); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 // Macro assembler to emit code. | 1051 // Macro assembler to emit code. |
1044 MacroAssembler* masm() { return &masm_; } | 1052 MacroAssembler* masm() { return &masm_; } |
1045 | 1053 |
1046 private: | 1054 private: |
1047 byte* address_; // The address of the code being patched. | 1055 byte* address_; // The address of the code being patched. |
1048 int size_; // Number of bytes of the expected patch size. | 1056 int size_; // Number of bytes of the expected patch size. |
1049 MacroAssembler masm_; // Macro assembler used to generate the code. | 1057 MacroAssembler masm_; // Macro assembler used to generate the code. |
1050 }; | 1058 }; |
1051 | 1059 |
1052 | 1060 |
| 1061 // Helper class for generating code or data associated with the code |
| 1062 // right after a call instruction. As an example this can be used to |
| 1063 // generate safepoint data after calls for crankshaft. |
| 1064 class PostCallGenerator { |
| 1065 public: |
| 1066 PostCallGenerator() { } |
| 1067 virtual ~PostCallGenerator() { } |
| 1068 virtual void Generate() = 0; |
| 1069 }; |
| 1070 |
| 1071 |
1053 // ----------------------------------------------------------------------------- | 1072 // ----------------------------------------------------------------------------- |
1054 // Static helper functions. | 1073 // Static helper functions. |
1055 | 1074 |
1056 // Generate an Operand for loading a field from an object. | 1075 // Generate an Operand for loading a field from an object. |
1057 static inline Operand FieldOperand(Register object, int offset) { | 1076 static inline Operand FieldOperand(Register object, int offset) { |
1058 return Operand(object, offset - kHeapObjectTag); | 1077 return Operand(object, offset - kHeapObjectTag); |
1059 } | 1078 } |
1060 | 1079 |
1061 | 1080 |
1062 // Generate an Operand for loading an indexed field from an object. | 1081 // Generate an Operand for loading an indexed field from an object. |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 } | 1768 } |
1750 } | 1769 } |
1751 | 1770 |
1752 | 1771 |
1753 template <typename LabelType> | 1772 template <typename LabelType> |
1754 void MacroAssembler::InvokePrologue(const ParameterCount& expected, | 1773 void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
1755 const ParameterCount& actual, | 1774 const ParameterCount& actual, |
1756 Handle<Code> code_constant, | 1775 Handle<Code> code_constant, |
1757 Register code_register, | 1776 Register code_register, |
1758 LabelType* done, | 1777 LabelType* done, |
1759 InvokeFlag flag) { | 1778 InvokeFlag flag, |
| 1779 PostCallGenerator* post_call_generator) { |
1760 bool definitely_matches = false; | 1780 bool definitely_matches = false; |
1761 NearLabel invoke; | 1781 NearLabel invoke; |
1762 if (expected.is_immediate()) { | 1782 if (expected.is_immediate()) { |
1763 ASSERT(actual.is_immediate()); | 1783 ASSERT(actual.is_immediate()); |
1764 if (expected.immediate() == actual.immediate()) { | 1784 if (expected.immediate() == actual.immediate()) { |
1765 definitely_matches = true; | 1785 definitely_matches = true; |
1766 } else { | 1786 } else { |
1767 Set(rax, actual.immediate()); | 1787 Set(rax, actual.immediate()); |
1768 if (expected.immediate() == | 1788 if (expected.immediate() == |
1769 SharedFunctionInfo::kDontAdaptArgumentsSentinel) { | 1789 SharedFunctionInfo::kDontAdaptArgumentsSentinel) { |
(...skipping 30 matching lines...) Expand all Loading... |
1800 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); | 1820 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); |
1801 if (!code_constant.is_null()) { | 1821 if (!code_constant.is_null()) { |
1802 movq(rdx, code_constant, RelocInfo::EMBEDDED_OBJECT); | 1822 movq(rdx, code_constant, RelocInfo::EMBEDDED_OBJECT); |
1803 addq(rdx, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 1823 addq(rdx, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
1804 } else if (!code_register.is(rdx)) { | 1824 } else if (!code_register.is(rdx)) { |
1805 movq(rdx, code_register); | 1825 movq(rdx, code_register); |
1806 } | 1826 } |
1807 | 1827 |
1808 if (flag == CALL_FUNCTION) { | 1828 if (flag == CALL_FUNCTION) { |
1809 Call(adaptor, RelocInfo::CODE_TARGET); | 1829 Call(adaptor, RelocInfo::CODE_TARGET); |
| 1830 if (post_call_generator != NULL) post_call_generator->Generate(); |
1810 jmp(done); | 1831 jmp(done); |
1811 } else { | 1832 } else { |
1812 Jump(adaptor, RelocInfo::CODE_TARGET); | 1833 Jump(adaptor, RelocInfo::CODE_TARGET); |
1813 } | 1834 } |
1814 bind(&invoke); | 1835 bind(&invoke); |
1815 } | 1836 } |
1816 } | 1837 } |
1817 | 1838 |
1818 | 1839 |
1819 } } // namespace v8::internal | 1840 } } // namespace v8::internal |
1820 | 1841 |
1821 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1842 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |