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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 | 1317 |
1318 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { | 1318 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
1319 // rdi - function | 1319 // rdi - function |
1320 // rdx - slot id | 1320 // rdx - slot id |
1321 // rbx - vector | 1321 // rbx - vector |
1322 // rcx - allocation site (loaded from vector[slot]). | 1322 // rcx - allocation site (loaded from vector[slot]). |
1323 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); | 1323 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); |
1324 __ cmpp(rdi, r8); | 1324 __ cmpp(rdi, r8); |
1325 __ j(not_equal, miss); | 1325 __ j(not_equal, miss); |
1326 | 1326 |
1327 __ movp(rax, Immediate(arg_count())); | |
1328 | |
1329 // Increment the call count for monomorphic function calls. | 1327 // Increment the call count for monomorphic function calls. |
1330 IncrementCallCount(masm, rbx, rdx); | 1328 IncrementCallCount(masm, rbx, rdx); |
1331 | 1329 |
1332 __ movp(rbx, rcx); | 1330 __ movp(rbx, rcx); |
1333 __ movp(rdx, rdi); | 1331 __ movp(rdx, rdi); |
1334 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 1332 __ Set(rax, arg_count()); |
| 1333 ArrayConstructorStub stub(masm->isolate()); |
1335 __ TailCallStub(&stub); | 1334 __ TailCallStub(&stub); |
1336 } | 1335 } |
1337 | 1336 |
1338 | 1337 |
1339 void CallICStub::Generate(MacroAssembler* masm) { | 1338 void CallICStub::Generate(MacroAssembler* masm) { |
1340 // ----------- S t a t e ------------- | 1339 // ----------- S t a t e ------------- |
1341 // -- rdi - function | 1340 // -- rdi - function |
1342 // -- rdx - slot id | 1341 // -- rdx - slot id |
1343 // -- rbx - vector | 1342 // -- rbx - vector |
1344 // ----------------------------------- | 1343 // ----------------------------------- |
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3532 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; | 3531 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; |
3533 for (int i = 0; i < 2; i++) { | 3532 for (int i = 0; i < 2; i++) { |
3534 // For internal arrays we only need a few things | 3533 // For internal arrays we only need a few things |
3535 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 3534 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
3536 stubh1.GetCode(); | 3535 stubh1.GetCode(); |
3537 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 3536 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
3538 stubh2.GetCode(); | 3537 stubh2.GetCode(); |
3539 } | 3538 } |
3540 } | 3539 } |
3541 | 3540 |
| 3541 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
| 3542 MacroAssembler* masm, AllocationSiteOverrideMode mode) { |
| 3543 Label not_zero_case, not_one_case; |
| 3544 __ testp(rax, rax); |
| 3545 __ j(not_zero, ¬_zero_case); |
| 3546 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
3542 | 3547 |
3543 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 3548 __ bind(¬_zero_case); |
3544 MacroAssembler* masm, | 3549 __ cmpl(rax, Immediate(1)); |
3545 AllocationSiteOverrideMode mode) { | 3550 __ j(greater, ¬_one_case); |
3546 if (argument_count() == ANY) { | 3551 CreateArrayDispatchOneArgument(masm, mode); |
3547 Label not_zero_case, not_one_case; | |
3548 __ testp(rax, rax); | |
3549 __ j(not_zero, ¬_zero_case); | |
3550 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | |
3551 | 3552 |
3552 __ bind(¬_zero_case); | 3553 __ bind(¬_one_case); |
3553 __ cmpl(rax, Immediate(1)); | 3554 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
3554 __ j(greater, ¬_one_case); | 3555 __ TailCallStub(&stub); |
3555 CreateArrayDispatchOneArgument(masm, mode); | |
3556 | |
3557 __ bind(¬_one_case); | |
3558 ArrayNArgumentsConstructorStub stub(masm->isolate()); | |
3559 __ TailCallStub(&stub); | |
3560 } else if (argument_count() == NONE) { | |
3561 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | |
3562 } else if (argument_count() == ONE) { | |
3563 CreateArrayDispatchOneArgument(masm, mode); | |
3564 } else if (argument_count() == MORE_THAN_ONE) { | |
3565 ArrayNArgumentsConstructorStub stub(masm->isolate()); | |
3566 __ TailCallStub(&stub); | |
3567 } else { | |
3568 UNREACHABLE(); | |
3569 } | |
3570 } | 3556 } |
3571 | 3557 |
3572 | |
3573 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 3558 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
3574 // ----------- S t a t e ------------- | 3559 // ----------- S t a t e ------------- |
3575 // -- rax : argc | 3560 // -- rax : argc |
3576 // -- rbx : AllocationSite or undefined | 3561 // -- rbx : AllocationSite or undefined |
3577 // -- rdi : constructor | 3562 // -- rdi : constructor |
3578 // -- rdx : new target | 3563 // -- rdx : new target |
3579 // -- rsp[0] : return address | 3564 // -- rsp[0] : return address |
3580 // -- rsp[8] : last argument | 3565 // -- rsp[8] : last argument |
3581 // ----------------------------------- | 3566 // ----------------------------------- |
3582 if (FLAG_debug_code) { | 3567 if (FLAG_debug_code) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3614 __ SmiToInteger32(rdx, rdx); | 3599 __ SmiToInteger32(rdx, rdx); |
3615 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 3600 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
3616 __ andp(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); | 3601 __ andp(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); |
3617 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); | 3602 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); |
3618 | 3603 |
3619 __ bind(&no_info); | 3604 __ bind(&no_info); |
3620 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); | 3605 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); |
3621 | 3606 |
3622 // Subclassing | 3607 // Subclassing |
3623 __ bind(&subclassing); | 3608 __ bind(&subclassing); |
3624 switch (argument_count()) { | 3609 StackArgumentsAccessor args(rsp, rax); |
3625 case ANY: | 3610 __ movp(args.GetReceiverOperand(), rdi); |
3626 case MORE_THAN_ONE: { | 3611 __ addp(rax, Immediate(3)); |
3627 StackArgumentsAccessor args(rsp, rax); | |
3628 __ movp(args.GetReceiverOperand(), rdi); | |
3629 __ addp(rax, Immediate(3)); | |
3630 break; | |
3631 } | |
3632 case NONE: { | |
3633 StackArgumentsAccessor args(rsp, 0); | |
3634 __ movp(args.GetReceiverOperand(), rdi); | |
3635 __ Set(rax, 3); | |
3636 break; | |
3637 } | |
3638 case ONE: { | |
3639 StackArgumentsAccessor args(rsp, 1); | |
3640 __ movp(args.GetReceiverOperand(), rdi); | |
3641 __ Set(rax, 4); | |
3642 break; | |
3643 } | |
3644 } | |
3645 __ PopReturnAddressTo(rcx); | 3612 __ PopReturnAddressTo(rcx); |
3646 __ Push(rdx); | 3613 __ Push(rdx); |
3647 __ Push(rbx); | 3614 __ Push(rbx); |
3648 __ PushReturnAddressFrom(rcx); | 3615 __ PushReturnAddressFrom(rcx); |
3649 __ JumpToExternalReference(ExternalReference(Runtime::kNewArray, isolate())); | 3616 __ JumpToExternalReference(ExternalReference(Runtime::kNewArray, isolate())); |
3650 } | 3617 } |
3651 | 3618 |
3652 | 3619 |
3653 void InternalArrayConstructorStub::GenerateCase( | 3620 void InternalArrayConstructorStub::GenerateCase( |
3654 MacroAssembler* masm, ElementsKind kind) { | 3621 MacroAssembler* masm, ElementsKind kind) { |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4895 kStackUnwindSpace, nullptr, return_value_operand, | 4862 kStackUnwindSpace, nullptr, return_value_operand, |
4896 NULL); | 4863 NULL); |
4897 } | 4864 } |
4898 | 4865 |
4899 #undef __ | 4866 #undef __ |
4900 | 4867 |
4901 } // namespace internal | 4868 } // namespace internal |
4902 } // namespace v8 | 4869 } // namespace v8 |
4903 | 4870 |
4904 #endif // V8_TARGET_ARCH_X64 | 4871 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |