| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r8, | 533 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r8, |
| 534 r9, &miss); | 534 r9, &miss); |
| 535 __ bind(&miss); | 535 __ bind(&miss); |
| 536 PropertyAccessCompiler::TailCallBuiltin( | 536 PropertyAccessCompiler::TailCallBuiltin( |
| 537 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); | 537 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); |
| 538 } | 538 } |
| 539 | 539 |
| 540 | 540 |
| 541 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 541 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
| 542 CHECK(!has_new_target()); | |
| 543 // The key is in rdx and the parameter count is in rax. | 542 // The key is in rdx and the parameter count is in rax. |
| 544 DCHECK(rdx.is(ArgumentsAccessReadDescriptor::index())); | 543 DCHECK(rdx.is(ArgumentsAccessReadDescriptor::index())); |
| 545 DCHECK(rax.is(ArgumentsAccessReadDescriptor::parameter_count())); | 544 DCHECK(rax.is(ArgumentsAccessReadDescriptor::parameter_count())); |
| 546 | 545 |
| 547 // Check that the key is a smi. | 546 // Check that the key is a smi. |
| 548 Label slow; | 547 Label slow; |
| 549 __ JumpIfNotSmi(rdx, &slow); | 548 __ JumpIfNotSmi(rdx, &slow); |
| 550 | 549 |
| 551 // Check if the calling frame is an arguments adaptor frame. We look at the | 550 // Check if the calling frame is an arguments adaptor frame. We look at the |
| 552 // context offset, and if the frame is not a regular one, then we find a | 551 // context offset, and if the frame is not a regular one, then we find a |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { | 599 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { |
| 601 // Stack layout: | 600 // Stack layout: |
| 602 // rsp[0] : return address | 601 // rsp[0] : return address |
| 603 // rsp[8] : number of parameters (tagged) | 602 // rsp[8] : number of parameters (tagged) |
| 604 // rsp[16] : receiver displacement | 603 // rsp[16] : receiver displacement |
| 605 // rsp[24] : function | 604 // rsp[24] : function |
| 606 // Registers used over the whole function: | 605 // Registers used over the whole function: |
| 607 // rbx: the mapped parameter count (untagged) | 606 // rbx: the mapped parameter count (untagged) |
| 608 // rax: the allocated object (tagged). | 607 // rax: the allocated object (tagged). |
| 609 | 608 |
| 610 CHECK(!has_new_target()); | |
| 611 | |
| 612 Factory* factory = isolate()->factory(); | 609 Factory* factory = isolate()->factory(); |
| 613 | 610 |
| 614 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); | 611 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 615 __ SmiToInteger64(rbx, args.GetArgumentOperand(2)); | 612 __ SmiToInteger64(rbx, args.GetArgumentOperand(2)); |
| 616 // rbx = parameter count (untagged) | 613 // rbx = parameter count (untagged) |
| 617 | 614 |
| 618 // Check if the calling frame is an arguments adaptor frame. | 615 // Check if the calling frame is an arguments adaptor frame. |
| 619 Label runtime; | 616 Label runtime; |
| 620 Label adaptor_frame, try_allocate; | 617 Label adaptor_frame, try_allocate; |
| 621 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 618 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 __ movp(args.GetArgumentOperand(2), rcx); // Patch argument count. | 812 __ movp(args.GetArgumentOperand(2), rcx); // Patch argument count. |
| 816 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); | 813 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); |
| 817 } | 814 } |
| 818 | 815 |
| 819 | 816 |
| 820 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { | 817 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { |
| 821 // rsp[0] : return address | 818 // rsp[0] : return address |
| 822 // rsp[8] : number of parameters | 819 // rsp[8] : number of parameters |
| 823 // rsp[16] : receiver displacement | 820 // rsp[16] : receiver displacement |
| 824 // rsp[24] : function | 821 // rsp[24] : function |
| 825 CHECK(!has_new_target()); | |
| 826 | 822 |
| 827 // Check if the calling frame is an arguments adaptor frame. | 823 // Check if the calling frame is an arguments adaptor frame. |
| 828 Label runtime; | 824 Label runtime; |
| 829 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 825 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 830 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); | 826 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); |
| 831 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 827 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 832 __ j(not_equal, &runtime); | 828 __ j(not_equal, &runtime); |
| 833 | 829 |
| 834 // Patch the arguments.length and the parameters pointer. | 830 // Patch the arguments.length and the parameters pointer. |
| 835 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); | 831 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 | 921 |
| 926 // Get the length from the frame. | 922 // Get the length from the frame. |
| 927 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); | 923 StackArgumentsAccessor args(rsp, 3, ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 928 __ movp(rcx, args.GetArgumentOperand(2)); | 924 __ movp(rcx, args.GetArgumentOperand(2)); |
| 929 __ SmiToInteger64(rcx, rcx); | 925 __ SmiToInteger64(rcx, rcx); |
| 930 __ jmp(&try_allocate); | 926 __ jmp(&try_allocate); |
| 931 | 927 |
| 932 // Patch the arguments.length and the parameters pointer. | 928 // Patch the arguments.length and the parameters pointer. |
| 933 __ bind(&adaptor_frame); | 929 __ bind(&adaptor_frame); |
| 934 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 930 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 935 | |
| 936 if (has_new_target()) { | |
| 937 // Subtract 1 from smi-tagged arguments count. | |
| 938 __ subp(rcx, Immediate(2)); | |
| 939 } | |
| 940 __ movp(args.GetArgumentOperand(2), rcx); | 931 __ movp(args.GetArgumentOperand(2), rcx); |
| 941 __ SmiToInteger64(rcx, rcx); | 932 __ SmiToInteger64(rcx, rcx); |
| 942 __ leap(rdx, Operand(rdx, rcx, times_pointer_size, | 933 __ leap(rdx, Operand(rdx, rcx, times_pointer_size, |
| 943 StandardFrameConstants::kCallerSPOffset)); | 934 StandardFrameConstants::kCallerSPOffset)); |
| 944 __ movp(args.GetArgumentOperand(1), rdx); | 935 __ movp(args.GetArgumentOperand(1), rdx); |
| 945 | 936 |
| 946 // Try the new space allocation. Start out with computing the size of | 937 // Try the new space allocation. Start out with computing the size of |
| 947 // the arguments object and the elements array. | 938 // the arguments object and the elements array. |
| 948 Label add_arguments_object; | 939 Label add_arguments_object; |
| 949 __ bind(&try_allocate); | 940 __ bind(&try_allocate); |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); | 2011 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); |
| 2021 __ j(equal, &feedback_register_initialized); | 2012 __ j(equal, &feedback_register_initialized); |
| 2022 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 2013 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
| 2023 __ bind(&feedback_register_initialized); | 2014 __ bind(&feedback_register_initialized); |
| 2024 } | 2015 } |
| 2025 | 2016 |
| 2026 __ AssertUndefinedOrAllocationSite(rbx); | 2017 __ AssertUndefinedOrAllocationSite(rbx); |
| 2027 } | 2018 } |
| 2028 | 2019 |
| 2029 // Pass original constructor to construct stub. | 2020 // Pass original constructor to construct stub. |
| 2030 if (IsSuperConstructorCall()) { | 2021 __ movp(rdx, rdi); |
| 2031 __ movp(rdx, Operand(rsp, rax, times_pointer_size, 2 * kPointerSize)); | |
| 2032 } else { | |
| 2033 __ movp(rdx, rdi); | |
| 2034 } | |
| 2035 | 2022 |
| 2036 // Jump to the function-specific construct stub. | 2023 // Jump to the function-specific construct stub. |
| 2037 Register jmp_reg = rcx; | 2024 Register jmp_reg = rcx; |
| 2038 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 2025 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 2039 __ movp(jmp_reg, FieldOperand(jmp_reg, | 2026 __ movp(jmp_reg, FieldOperand(jmp_reg, |
| 2040 SharedFunctionInfo::kConstructStubOffset)); | 2027 SharedFunctionInfo::kConstructStubOffset)); |
| 2041 __ leap(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); | 2028 __ leap(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); |
| 2042 __ jmp(jmp_reg); | 2029 __ jmp(jmp_reg); |
| 2043 | 2030 |
| 2044 // rdi: called object | 2031 // rdi: called object |
| (...skipping 3022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5067 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, | 5054 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, |
| 5068 kStackSpace, nullptr, return_value_operand, NULL); | 5055 kStackSpace, nullptr, return_value_operand, NULL); |
| 5069 } | 5056 } |
| 5070 | 5057 |
| 5071 | 5058 |
| 5072 #undef __ | 5059 #undef __ |
| 5073 | 5060 |
| 5074 } } // namespace v8::internal | 5061 } } // namespace v8::internal |
| 5075 | 5062 |
| 5076 #endif // V8_TARGET_ARCH_X64 | 5063 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |