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