OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 __ pushq(rbp); // Caller's frame pointer. | 651 __ pushq(rbp); // Caller's frame pointer. |
652 __ movp(rbp, rsp); | 652 __ movp(rbp, rsp); |
653 __ Push(rsi); // Callee's context. | 653 __ Push(rsi); // Callee's context. |
654 __ Push(rdi); // Callee's JS function. | 654 __ Push(rdi); // Callee's JS function. |
655 __ Push(rdx); // Callee's new target. | 655 __ Push(rdx); // Callee's new target. |
656 | 656 |
657 // Get the bytecode array from the function object (or from the DebugInfo if | 657 // Get the bytecode array from the function object (or from the DebugInfo if |
658 // it is present) and load it into kInterpreterBytecodeArrayRegister. | 658 // it is present) and load it into kInterpreterBytecodeArrayRegister. |
659 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 659 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
660 Label load_debug_bytecode_array, bytecode_array_loaded; | 660 Label load_debug_bytecode_array, bytecode_array_loaded; |
661 DCHECK_EQ(Smi::FromInt(0), DebugInfo::uninitialized()); | 661 DCHECK_EQ(Smi::kZero, DebugInfo::uninitialized()); |
662 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), | 662 __ cmpp(FieldOperand(rax, SharedFunctionInfo::kDebugInfoOffset), |
663 Immediate(0)); | 663 Immediate(0)); |
664 __ j(not_equal, &load_debug_bytecode_array); | 664 __ j(not_equal, &load_debug_bytecode_array); |
665 __ movp(kInterpreterBytecodeArrayRegister, | 665 __ movp(kInterpreterBytecodeArrayRegister, |
666 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); | 666 FieldOperand(rax, SharedFunctionInfo::kFunctionDataOffset)); |
667 __ bind(&bytecode_array_loaded); | 667 __ bind(&bytecode_array_loaded); |
668 | 668 |
669 // Check whether we should continue to use the interpreter. | 669 // Check whether we should continue to use the interpreter. |
670 Label switch_to_different_code_kind; | 670 Label switch_to_different_code_kind; |
671 __ Move(rcx, masm->CodeObject()); // Self-reference to this code. | 671 __ Move(rcx, masm->CodeObject()); // Self-reference to this code. |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // This should be unreachable. | 979 // This should be unreachable. |
980 __ int3(); | 980 __ int3(); |
981 } | 981 } |
982 } | 982 } |
983 | 983 |
984 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 984 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
985 // Set the return address to the correct point in the interpreter entry | 985 // Set the return address to the correct point in the interpreter entry |
986 // trampoline. | 986 // trampoline. |
987 Smi* interpreter_entry_return_pc_offset( | 987 Smi* interpreter_entry_return_pc_offset( |
988 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 988 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
989 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 989 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero); |
990 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 990 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
991 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + | 991 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + |
992 Code::kHeaderSize - kHeapObjectTag)); | 992 Code::kHeaderSize - kHeapObjectTag)); |
993 __ Push(rbx); | 993 __ Push(rbx); |
994 | 994 |
995 // Initialize dispatch table register. | 995 // Initialize dispatch table register. |
996 __ Move( | 996 __ Move( |
997 kInterpreterDispatchTableRegister, | 997 kInterpreterDispatchTableRegister, |
998 ExternalReference::interpreter_dispatch_table_address(masm->isolate())); | 998 ExternalReference::interpreter_dispatch_table_address(masm->isolate())); |
999 | 999 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 | 1897 |
1898 // 2. Load the first argument into rbx. | 1898 // 2. Load the first argument into rbx. |
1899 { | 1899 { |
1900 StackArgumentsAccessor args(rsp, rax); | 1900 StackArgumentsAccessor args(rsp, rax); |
1901 Label no_arguments, done; | 1901 Label no_arguments, done; |
1902 __ testp(rax, rax); | 1902 __ testp(rax, rax); |
1903 __ j(zero, &no_arguments, Label::kNear); | 1903 __ j(zero, &no_arguments, Label::kNear); |
1904 __ movp(rbx, args.GetArgumentOperand(1)); | 1904 __ movp(rbx, args.GetArgumentOperand(1)); |
1905 __ jmp(&done, Label::kNear); | 1905 __ jmp(&done, Label::kNear); |
1906 __ bind(&no_arguments); | 1906 __ bind(&no_arguments); |
1907 __ Move(rbx, Smi::FromInt(0)); | 1907 __ Move(rbx, Smi::kZero); |
1908 __ bind(&done); | 1908 __ bind(&done); |
1909 } | 1909 } |
1910 | 1910 |
1911 // 3. Make sure rbx is a number. | 1911 // 3. Make sure rbx is a number. |
1912 { | 1912 { |
1913 Label done_convert; | 1913 Label done_convert; |
1914 __ JumpIfSmi(rbx, &done_convert); | 1914 __ JumpIfSmi(rbx, &done_convert); |
1915 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1915 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1916 Heap::kHeapNumberMapRootIndex); | 1916 Heap::kHeapNumberMapRootIndex); |
1917 __ j(equal, &done_convert); | 1917 __ j(equal, &done_convert); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 // static | 2150 // static |
2151 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { | 2151 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { |
2152 // ----------- S t a t e ------------- | 2152 // ----------- S t a t e ------------- |
2153 // -- rdx : requested object size (untagged) | 2153 // -- rdx : requested object size (untagged) |
2154 // -- rsp[0] : return address | 2154 // -- rsp[0] : return address |
2155 // ----------------------------------- | 2155 // ----------------------------------- |
2156 __ Integer32ToSmi(rdx, rdx); | 2156 __ Integer32ToSmi(rdx, rdx); |
2157 __ PopReturnAddressTo(rcx); | 2157 __ PopReturnAddressTo(rcx); |
2158 __ Push(rdx); | 2158 __ Push(rdx); |
2159 __ PushReturnAddressFrom(rcx); | 2159 __ PushReturnAddressFrom(rcx); |
2160 __ Move(rsi, Smi::FromInt(0)); | 2160 __ Move(rsi, Smi::kZero); |
2161 __ TailCallRuntime(Runtime::kAllocateInNewSpace); | 2161 __ TailCallRuntime(Runtime::kAllocateInNewSpace); |
2162 } | 2162 } |
2163 | 2163 |
2164 // static | 2164 // static |
2165 void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) { | 2165 void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) { |
2166 // ----------- S t a t e ------------- | 2166 // ----------- S t a t e ------------- |
2167 // -- rdx : requested object size (untagged) | 2167 // -- rdx : requested object size (untagged) |
2168 // -- rsp[0] : return address | 2168 // -- rsp[0] : return address |
2169 // ----------------------------------- | 2169 // ----------------------------------- |
2170 __ Integer32ToSmi(rdx, rdx); | 2170 __ Integer32ToSmi(rdx, rdx); |
2171 __ PopReturnAddressTo(rcx); | 2171 __ PopReturnAddressTo(rcx); |
2172 __ Push(rdx); | 2172 __ Push(rdx); |
2173 __ Push(Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); | 2173 __ Push(Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); |
2174 __ PushReturnAddressFrom(rcx); | 2174 __ PushReturnAddressFrom(rcx); |
2175 __ Move(rsi, Smi::FromInt(0)); | 2175 __ Move(rsi, Smi::kZero); |
2176 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); | 2176 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); |
2177 } | 2177 } |
2178 | 2178 |
2179 // static | 2179 // static |
2180 void Builtins::Generate_Abort(MacroAssembler* masm) { | 2180 void Builtins::Generate_Abort(MacroAssembler* masm) { |
2181 // ----------- S t a t e ------------- | 2181 // ----------- S t a t e ------------- |
2182 // -- rdx : message_id as Smi | 2182 // -- rdx : message_id as Smi |
2183 // -- rsp[0] : return address | 2183 // -- rsp[0] : return address |
2184 // ----------------------------------- | 2184 // ----------------------------------- |
2185 __ PopReturnAddressTo(rcx); | 2185 __ PopReturnAddressTo(rcx); |
2186 __ Push(rdx); | 2186 __ Push(rdx); |
2187 __ PushReturnAddressFrom(rcx); | 2187 __ PushReturnAddressFrom(rcx); |
2188 __ Move(rsi, Smi::FromInt(0)); | 2188 __ Move(rsi, Smi::kZero); |
2189 __ TailCallRuntime(Runtime::kAbort); | 2189 __ TailCallRuntime(Runtime::kAbort); |
2190 } | 2190 } |
2191 | 2191 |
2192 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2192 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2193 // ----------- S t a t e ------------- | 2193 // ----------- S t a t e ------------- |
2194 // -- rax : actual number of arguments | 2194 // -- rax : actual number of arguments |
2195 // -- rbx : expected number of arguments | 2195 // -- rbx : expected number of arguments |
2196 // -- rdx : new target (passed through to callee) | 2196 // -- rdx : new target (passed through to callee) |
2197 // -- rdi : function (passed through to callee) | 2197 // -- rdi : function (passed through to callee) |
2198 // ----------------------------------- | 2198 // ----------------------------------- |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3089 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3090 Generate_OnStackReplacementHelper(masm, true); | 3090 Generate_OnStackReplacementHelper(masm, true); |
3091 } | 3091 } |
3092 | 3092 |
3093 #undef __ | 3093 #undef __ |
3094 | 3094 |
3095 } // namespace internal | 3095 } // namespace internal |
3096 } // namespace v8 | 3096 } // namespace v8 |
3097 | 3097 |
3098 #endif // V8_TARGET_ARCH_X64 | 3098 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |