| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 __ bind(&argc); | 65 __ bind(&argc); |
| 66 __ addp(rax, Immediate(num_extra_args + 1)); | 66 __ addp(rax, Immediate(num_extra_args + 1)); |
| 67 __ bind(&done_argc); | 67 __ bind(&done_argc); |
| 68 | 68 |
| 69 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); | 69 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 static void CallRuntimePassFunction( | 73 static void CallRuntimePassFunction( |
| 74 MacroAssembler* masm, Runtime::FunctionId function_id) { | 74 MacroAssembler* masm, Runtime::FunctionId function_id) { |
| 75 // ----------- S t a t e ------------- |
| 76 // -- rdx : new target (preserved for callee) |
| 77 // -- rdi : target function (preserved for callee) |
| 78 // ----------------------------------- |
| 79 |
| 75 FrameScope scope(masm, StackFrame::INTERNAL); | 80 FrameScope scope(masm, StackFrame::INTERNAL); |
| 76 // Push a copy of the function onto the stack. | 81 // Push a copy of the target function and the new target. |
| 77 __ Push(rdi); | 82 __ Push(rdi); |
| 83 __ Push(rdx); |
| 78 // Function is also the parameter to the runtime call. | 84 // Function is also the parameter to the runtime call. |
| 79 __ Push(rdi); | 85 __ Push(rdi); |
| 80 | 86 |
| 81 __ CallRuntime(function_id, 1); | 87 __ CallRuntime(function_id, 1); |
| 82 // Restore receiver. | 88 // Restore target function and new target. |
| 89 __ Pop(rdx); |
| 83 __ Pop(rdi); | 90 __ Pop(rdi); |
| 84 } | 91 } |
| 85 | 92 |
| 86 | 93 |
| 87 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 94 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
| 88 __ movp(kScratchRegister, | 95 __ movp(kScratchRegister, |
| 89 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 96 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 90 __ movp(kScratchRegister, | 97 __ movp(kScratchRegister, |
| 91 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); | 98 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); |
| 92 __ leap(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); | 99 __ leap(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 __ j(greater_equal, &loop); | 316 __ j(greater_equal, &loop); |
| 310 | 317 |
| 311 // Call the function. | 318 // Call the function. |
| 312 if (is_api_function) { | 319 if (is_api_function) { |
| 313 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 320 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 314 Handle<Code> code = | 321 Handle<Code> code = |
| 315 masm->isolate()->builtins()->HandleApiCallConstruct(); | 322 masm->isolate()->builtins()->HandleApiCallConstruct(); |
| 316 __ Call(code, RelocInfo::CODE_TARGET); | 323 __ Call(code, RelocInfo::CODE_TARGET); |
| 317 } else { | 324 } else { |
| 318 ParameterCount actual(rax); | 325 ParameterCount actual(rax); |
| 319 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); | 326 __ InvokeFunction(rdi, rdx, actual, CALL_FUNCTION, NullCallWrapper()); |
| 320 } | 327 } |
| 321 | 328 |
| 322 // Store offset of return address for deoptimizer. | 329 // Store offset of return address for deoptimizer. |
| 323 if (create_implicit_receiver && !is_api_function) { | 330 if (create_implicit_receiver && !is_api_function) { |
| 324 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 331 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
| 325 } | 332 } |
| 326 | 333 |
| 327 // Restore context from the frame. | 334 // Restore context from the frame. |
| 328 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 335 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 329 | 336 |
| (...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 | 1710 |
| 1704 // ----------- S t a t e ------------- | 1711 // ----------- S t a t e ------------- |
| 1705 // -- rax : the number of arguments (not including the receiver) | 1712 // -- rax : the number of arguments (not including the receiver) |
| 1706 // -- rdx : the shared function info. | 1713 // -- rdx : the shared function info. |
| 1707 // -- rdi : the function to call (checked to be a JSFunction) | 1714 // -- rdi : the function to call (checked to be a JSFunction) |
| 1708 // -- rsi : the function context. | 1715 // -- rsi : the function context. |
| 1709 // ----------------------------------- | 1716 // ----------------------------------- |
| 1710 | 1717 |
| 1711 __ LoadSharedFunctionInfoSpecialField( | 1718 __ LoadSharedFunctionInfoSpecialField( |
| 1712 rbx, rdx, SharedFunctionInfo::kFormalParameterCountOffset); | 1719 rbx, rdx, SharedFunctionInfo::kFormalParameterCountOffset); |
| 1713 __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 1720 __ movp(r8, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
| 1714 ParameterCount actual(rax); | 1721 ParameterCount actual(rax); |
| 1715 ParameterCount expected(rbx); | 1722 ParameterCount expected(rbx); |
| 1716 __ InvokeCode(rdx, expected, actual, JUMP_FUNCTION, NullCallWrapper()); | 1723 __ InvokeCode(r8, no_reg, expected, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 1717 | 1724 |
| 1718 // The function is a "classConstructor", need to raise an exception. | 1725 // The function is a "classConstructor", need to raise an exception. |
| 1719 __ bind(&class_constructor); | 1726 __ bind(&class_constructor); |
| 1720 { | 1727 { |
| 1721 FrameScope frame(masm, StackFrame::INTERNAL); | 1728 FrameScope frame(masm, StackFrame::INTERNAL); |
| 1722 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); | 1729 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
| 1723 } | 1730 } |
| 1724 } | 1731 } |
| 1725 | 1732 |
| 1726 | 1733 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 __ ret(0); | 1917 __ ret(0); |
| 1911 } | 1918 } |
| 1912 | 1919 |
| 1913 | 1920 |
| 1914 #undef __ | 1921 #undef __ |
| 1915 | 1922 |
| 1916 } // namespace internal | 1923 } // namespace internal |
| 1917 } // namespace v8 | 1924 } // namespace v8 |
| 1918 | 1925 |
| 1919 #endif // V8_TARGET_ARCH_X64 | 1926 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |