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::kZero, DebugInfo::uninitialized()); | 661 DCHECK_EQ(Smi::FromInt(0), 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::kZero); | 989 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 | 1881 |
1882 // 2. Load the first argument into rbx. | 1882 // 2. Load the first argument into rbx. |
1883 { | 1883 { |
1884 StackArgumentsAccessor args(rsp, rax); | 1884 StackArgumentsAccessor args(rsp, rax); |
1885 Label no_arguments, done; | 1885 Label no_arguments, done; |
1886 __ testp(rax, rax); | 1886 __ testp(rax, rax); |
1887 __ j(zero, &no_arguments, Label::kNear); | 1887 __ j(zero, &no_arguments, Label::kNear); |
1888 __ movp(rbx, args.GetArgumentOperand(1)); | 1888 __ movp(rbx, args.GetArgumentOperand(1)); |
1889 __ jmp(&done, Label::kNear); | 1889 __ jmp(&done, Label::kNear); |
1890 __ bind(&no_arguments); | 1890 __ bind(&no_arguments); |
1891 __ Move(rbx, Smi::kZero); | 1891 __ Move(rbx, Smi::FromInt(0)); |
1892 __ bind(&done); | 1892 __ bind(&done); |
1893 } | 1893 } |
1894 | 1894 |
1895 // 3. Make sure rbx is a number. | 1895 // 3. Make sure rbx is a number. |
1896 { | 1896 { |
1897 Label done_convert; | 1897 Label done_convert; |
1898 __ JumpIfSmi(rbx, &done_convert); | 1898 __ JumpIfSmi(rbx, &done_convert); |
1899 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1899 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1900 Heap::kHeapNumberMapRootIndex); | 1900 Heap::kHeapNumberMapRootIndex); |
1901 __ j(equal, &done_convert); | 1901 __ j(equal, &done_convert); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 // static | 2134 // static |
2135 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { | 2135 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { |
2136 // ----------- S t a t e ------------- | 2136 // ----------- S t a t e ------------- |
2137 // -- rdx : requested object size (untagged) | 2137 // -- rdx : requested object size (untagged) |
2138 // -- rsp[0] : return address | 2138 // -- rsp[0] : return address |
2139 // ----------------------------------- | 2139 // ----------------------------------- |
2140 __ Integer32ToSmi(rdx, rdx); | 2140 __ Integer32ToSmi(rdx, rdx); |
2141 __ PopReturnAddressTo(rcx); | 2141 __ PopReturnAddressTo(rcx); |
2142 __ Push(rdx); | 2142 __ Push(rdx); |
2143 __ PushReturnAddressFrom(rcx); | 2143 __ PushReturnAddressFrom(rcx); |
2144 __ Move(rsi, Smi::kZero); | 2144 __ Move(rsi, Smi::FromInt(0)); |
2145 __ TailCallRuntime(Runtime::kAllocateInNewSpace); | 2145 __ TailCallRuntime(Runtime::kAllocateInNewSpace); |
2146 } | 2146 } |
2147 | 2147 |
2148 // static | 2148 // static |
2149 void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) { | 2149 void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) { |
2150 // ----------- S t a t e ------------- | 2150 // ----------- S t a t e ------------- |
2151 // -- rdx : requested object size (untagged) | 2151 // -- rdx : requested object size (untagged) |
2152 // -- rsp[0] : return address | 2152 // -- rsp[0] : return address |
2153 // ----------------------------------- | 2153 // ----------------------------------- |
2154 __ Integer32ToSmi(rdx, rdx); | 2154 __ Integer32ToSmi(rdx, rdx); |
2155 __ PopReturnAddressTo(rcx); | 2155 __ PopReturnAddressTo(rcx); |
2156 __ Push(rdx); | 2156 __ Push(rdx); |
2157 __ Push(Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); | 2157 __ Push(Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); |
2158 __ PushReturnAddressFrom(rcx); | 2158 __ PushReturnAddressFrom(rcx); |
2159 __ Move(rsi, Smi::kZero); | 2159 __ Move(rsi, Smi::FromInt(0)); |
2160 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); | 2160 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); |
2161 } | 2161 } |
2162 | 2162 |
2163 // static | 2163 // static |
2164 void Builtins::Generate_Abort(MacroAssembler* masm) { | 2164 void Builtins::Generate_Abort(MacroAssembler* masm) { |
2165 // ----------- S t a t e ------------- | 2165 // ----------- S t a t e ------------- |
2166 // -- rdx : message_id as Smi | 2166 // -- rdx : message_id as Smi |
2167 // -- rsp[0] : return address | 2167 // -- rsp[0] : return address |
2168 // ----------------------------------- | 2168 // ----------------------------------- |
2169 __ PopReturnAddressTo(rcx); | 2169 __ PopReturnAddressTo(rcx); |
2170 __ Push(rdx); | 2170 __ Push(rdx); |
2171 __ PushReturnAddressFrom(rcx); | 2171 __ PushReturnAddressFrom(rcx); |
2172 __ Move(rsi, Smi::kZero); | 2172 __ Move(rsi, Smi::FromInt(0)); |
2173 __ TailCallRuntime(Runtime::kAbort); | 2173 __ TailCallRuntime(Runtime::kAbort); |
2174 } | 2174 } |
2175 | 2175 |
2176 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2176 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2177 // ----------- S t a t e ------------- | 2177 // ----------- S t a t e ------------- |
2178 // -- rax : actual number of arguments | 2178 // -- rax : actual number of arguments |
2179 // -- rbx : expected number of arguments | 2179 // -- rbx : expected number of arguments |
2180 // -- rdx : new target (passed through to callee) | 2180 // -- rdx : new target (passed through to callee) |
2181 // -- rdi : function (passed through to callee) | 2181 // -- rdi : function (passed through to callee) |
2182 // ----------------------------------- | 2182 // ----------------------------------- |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3073 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3074 Generate_OnStackReplacementHelper(masm, true); | 3074 Generate_OnStackReplacementHelper(masm, true); |
3075 } | 3075 } |
3076 | 3076 |
3077 #undef __ | 3077 #undef __ |
3078 | 3078 |
3079 } // namespace internal | 3079 } // namespace internal |
3080 } // namespace v8 | 3080 } // namespace v8 |
3081 | 3081 |
3082 #endif // V8_TARGET_ARCH_X64 | 3082 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |