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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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" |
11 #include "src/ic/handler-compiler.h" | 11 #include "src/ic/handler-compiler.h" |
12 #include "src/ic/ic.h" | 12 #include "src/ic/ic.h" |
13 #include "src/ic/stub-cache.h" | 13 #include "src/ic/stub-cache.h" |
14 #include "src/isolate.h" | 14 #include "src/isolate.h" |
15 #include "src/regexp/jsregexp.h" | 15 #include "src/regexp/jsregexp.h" |
16 #include "src/regexp/regexp-macro-assembler.h" | 16 #include "src/regexp/regexp-macro-assembler.h" |
17 #include "src/runtime/runtime.h" | 17 #include "src/runtime/runtime.h" |
18 | 18 |
19 #include "src/arm64/code-stubs-arm64.h" | 19 #include "src/arm64/code-stubs-arm64.h" |
20 #include "src/arm64/frames-arm64.h" | 20 #include "src/arm64/frames-arm64.h" |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
| 25 #define __ ACCESS_MASM(masm) |
25 | 26 |
26 static void InitializeArrayConstructorDescriptor( | 27 void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) { |
27 Isolate* isolate, CodeStubDescriptor* descriptor, | 28 __ Mov(x5, Operand(x0, LSL, kPointerSizeLog2)); |
28 int constant_stack_parameter_count) { | 29 __ Str(x1, MemOperand(jssp, x5)); |
29 // cp: context | 30 __ Push(x1); |
30 // x1: function | 31 __ Push(x2); |
31 // x2: allocation site with elements kind | 32 __ Add(x0, x0, Operand(3)); |
32 // x0: number of arguments to the constructor function | 33 __ TailCallRuntime(Runtime::kArrayConstructor); |
33 Address deopt_handler = Runtime::FunctionForId( | |
34 Runtime::kArrayConstructor)->entry; | |
35 | |
36 if (constant_stack_parameter_count == 0) { | |
37 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | |
38 JS_FUNCTION_STUB_MODE); | |
39 } else { | |
40 descriptor->Initialize(x0, deopt_handler, constant_stack_parameter_count, | |
41 JS_FUNCTION_STUB_MODE); | |
42 } | |
43 } | 34 } |
44 | 35 |
45 | |
46 void ArrayNArgumentsConstructorStub::InitializeDescriptor( | |
47 CodeStubDescriptor* descriptor) { | |
48 InitializeArrayConstructorDescriptor(isolate(), descriptor, -1); | |
49 } | |
50 | |
51 | |
52 static void InitializeInternalArrayConstructorDescriptor( | |
53 Isolate* isolate, CodeStubDescriptor* descriptor, | |
54 int constant_stack_parameter_count) { | |
55 Address deopt_handler = Runtime::FunctionForId( | |
56 Runtime::kInternalArrayConstructor)->entry; | |
57 | |
58 if (constant_stack_parameter_count == 0) { | |
59 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | |
60 JS_FUNCTION_STUB_MODE); | |
61 } else { | |
62 descriptor->Initialize(x0, deopt_handler, constant_stack_parameter_count, | |
63 JS_FUNCTION_STUB_MODE); | |
64 } | |
65 } | |
66 | |
67 | |
68 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 36 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
69 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; | 37 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; |
70 descriptor->Initialize(x0, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 38 descriptor->Initialize(x0, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
71 } | 39 } |
72 | 40 |
73 void FastFunctionBindStub::InitializeDescriptor( | 41 void FastFunctionBindStub::InitializeDescriptor( |
74 CodeStubDescriptor* descriptor) { | 42 CodeStubDescriptor* descriptor) { |
75 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; | 43 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; |
76 descriptor->Initialize(x0, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 44 descriptor->Initialize(x0, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
77 } | 45 } |
78 | 46 |
79 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | |
80 CodeStubDescriptor* descriptor) { | |
81 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | |
82 } | |
83 | |
84 | |
85 #define __ ACCESS_MASM(masm) | |
86 | |
87 | |
88 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 47 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
89 ExternalReference miss) { | 48 ExternalReference miss) { |
90 // Update the static counter each time a new code stub is generated. | 49 // Update the static counter each time a new code stub is generated. |
91 isolate()->counters()->code_stubs()->Increment(); | 50 isolate()->counters()->code_stubs()->Increment(); |
92 | 51 |
93 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); | 52 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); |
94 int param_count = descriptor.GetRegisterParameterCount(); | 53 int param_count = descriptor.GetRegisterParameterCount(); |
95 { | 54 { |
96 // Call the runtime system in a fresh internal frame. | 55 // Call the runtime system in a fresh internal frame. |
97 FrameScope scope(masm, StackFrame::INTERNAL); | 56 FrameScope scope(masm, StackFrame::INTERNAL); |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 932 |
974 | 933 |
975 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 934 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
976 // It is important that the following stubs are generated in this order | 935 // It is important that the following stubs are generated in this order |
977 // because pregenerated stubs can only call other pregenerated stubs. | 936 // because pregenerated stubs can only call other pregenerated stubs. |
978 // RecordWriteStub uses StoreBufferOverflowStub, which in turn uses | 937 // RecordWriteStub uses StoreBufferOverflowStub, which in turn uses |
979 // CEntryStub. | 938 // CEntryStub. |
980 CEntryStub::GenerateAheadOfTime(isolate); | 939 CEntryStub::GenerateAheadOfTime(isolate); |
981 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 940 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
982 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 941 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
983 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 942 CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); |
984 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); | 943 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
985 CreateWeakCellStub::GenerateAheadOfTime(isolate); | 944 CreateWeakCellStub::GenerateAheadOfTime(isolate); |
986 BinaryOpICStub::GenerateAheadOfTime(isolate); | 945 BinaryOpICStub::GenerateAheadOfTime(isolate); |
987 StoreRegistersStateStub::GenerateAheadOfTime(isolate); | 946 StoreRegistersStateStub::GenerateAheadOfTime(isolate); |
988 RestoreRegistersStateStub::GenerateAheadOfTime(isolate); | 947 RestoreRegistersStateStub::GenerateAheadOfTime(isolate); |
989 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 948 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
990 StoreFastElementStub::GenerateAheadOfTime(isolate); | 949 StoreFastElementStub::GenerateAheadOfTime(isolate); |
991 TypeofStub::GenerateAheadOfTime(isolate); | 950 TypeofStub::GenerateAheadOfTime(isolate); |
992 } | 951 } |
993 | 952 |
(...skipping 3432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4426 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4385 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
4427 T stub(isolate, kind); | 4386 T stub(isolate, kind); |
4428 stub.GetCode(); | 4387 stub.GetCode(); |
4429 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 4388 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
4430 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 4389 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
4431 stub1.GetCode(); | 4390 stub1.GetCode(); |
4432 } | 4391 } |
4433 } | 4392 } |
4434 } | 4393 } |
4435 | 4394 |
4436 | 4395 void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
4437 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | |
4438 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 4396 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
4439 isolate); | 4397 isolate); |
4440 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 4398 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
4441 isolate); | 4399 isolate); |
4442 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 4400 ArrayNArgumentsConstructorStub stub(isolate); |
4443 isolate); | 4401 stub.GetCode(); |
4444 } | |
4445 | |
4446 | |
4447 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | |
4448 Isolate* isolate) { | |
4449 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; | 4402 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; |
4450 for (int i = 0; i < 2; i++) { | 4403 for (int i = 0; i < 2; i++) { |
4451 // For internal arrays we only need a few things | 4404 // For internal arrays we only need a few things |
4452 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 4405 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
4453 stubh1.GetCode(); | 4406 stubh1.GetCode(); |
4454 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 4407 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
4455 stubh2.GetCode(); | 4408 stubh2.GetCode(); |
4456 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | |
4457 stubh3.GetCode(); | |
4458 } | 4409 } |
4459 } | 4410 } |
4460 | 4411 |
4461 | 4412 |
4462 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 4413 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
4463 MacroAssembler* masm, | 4414 MacroAssembler* masm, |
4464 AllocationSiteOverrideMode mode) { | 4415 AllocationSiteOverrideMode mode) { |
4465 Register argc = x0; | 4416 Register argc = x0; |
4466 if (argument_count() == ANY) { | 4417 if (argument_count() == ANY) { |
4467 Label zero_case, n_case; | 4418 Label zero_case, n_case; |
4468 __ Cbz(argc, &zero_case); | 4419 __ Cbz(argc, &zero_case); |
4469 __ Cmp(argc, 1); | 4420 __ Cmp(argc, 1); |
4470 __ B(ne, &n_case); | 4421 __ B(ne, &n_case); |
4471 | 4422 |
4472 // One argument. | 4423 // One argument. |
4473 CreateArrayDispatchOneArgument(masm, mode); | 4424 CreateArrayDispatchOneArgument(masm, mode); |
4474 | 4425 |
4475 __ Bind(&zero_case); | 4426 __ Bind(&zero_case); |
4476 // No arguments. | 4427 // No arguments. |
4477 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4428 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4478 | 4429 |
4479 __ Bind(&n_case); | 4430 __ Bind(&n_case); |
4480 // N arguments. | 4431 // N arguments. |
4481 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4432 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
4482 | 4433 __ TailCallStub(&stub); |
4483 } else if (argument_count() == NONE) { | 4434 } else if (argument_count() == NONE) { |
4484 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4435 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4485 } else if (argument_count() == ONE) { | 4436 } else if (argument_count() == ONE) { |
4486 CreateArrayDispatchOneArgument(masm, mode); | 4437 CreateArrayDispatchOneArgument(masm, mode); |
4487 } else if (argument_count() == MORE_THAN_ONE) { | 4438 } else if (argument_count() == MORE_THAN_ONE) { |
4488 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4439 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
| 4440 __ TailCallStub(&stub); |
4489 } else { | 4441 } else { |
4490 UNREACHABLE(); | 4442 UNREACHABLE(); |
4491 } | 4443 } |
4492 } | 4444 } |
4493 | 4445 |
4494 | 4446 |
4495 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 4447 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
4496 ASM_LOCATION("ArrayConstructorStub::Generate"); | 4448 ASM_LOCATION("ArrayConstructorStub::Generate"); |
4497 // ----------- S t a t e ------------- | 4449 // ----------- S t a t e ------------- |
4498 // -- x0 : argc (only if argument_count() is ANY or MORE_THAN_ONE) | 4450 // -- x0 : argc (only if argument_count() is ANY or MORE_THAN_ONE) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4557 case NONE: | 4509 case NONE: |
4558 __ Poke(constructor, 0 * kPointerSize); | 4510 __ Poke(constructor, 0 * kPointerSize); |
4559 __ Mov(x0, Operand(3)); | 4511 __ Mov(x0, Operand(3)); |
4560 break; | 4512 break; |
4561 case ONE: | 4513 case ONE: |
4562 __ Poke(constructor, 1 * kPointerSize); | 4514 __ Poke(constructor, 1 * kPointerSize); |
4563 __ Mov(x0, Operand(4)); | 4515 __ Mov(x0, Operand(4)); |
4564 break; | 4516 break; |
4565 } | 4517 } |
4566 __ Push(new_target, allocation_site); | 4518 __ Push(new_target, allocation_site); |
4567 __ JumpToExternalReference(ExternalReference(Runtime::kNewArray, isolate())); | 4519 __ JumpToExternalReference( |
| 4520 ExternalReference(Runtime::kArrayConstructor, isolate())); |
4568 } | 4521 } |
4569 | 4522 |
4570 | 4523 |
4571 void InternalArrayConstructorStub::GenerateCase( | 4524 void InternalArrayConstructorStub::GenerateCase( |
4572 MacroAssembler* masm, ElementsKind kind) { | 4525 MacroAssembler* masm, ElementsKind kind) { |
4573 Label zero_case, n_case; | 4526 Label zero_case, n_case; |
4574 Register argc = x0; | 4527 Register argc = x0; |
4575 | 4528 |
4576 __ Cbz(argc, &zero_case); | 4529 __ Cbz(argc, &zero_case); |
4577 __ CompareAndBranch(argc, 1, ne, &n_case); | 4530 __ CompareAndBranch(argc, 1, ne, &n_case); |
(...skipping 15 matching lines...) Expand all Loading... |
4593 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); | 4546 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); |
4594 __ TailCallStub(&stub1); | 4547 __ TailCallStub(&stub1); |
4595 | 4548 |
4596 __ Bind(&zero_case); | 4549 __ Bind(&zero_case); |
4597 // No arguments. | 4550 // No arguments. |
4598 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); | 4551 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); |
4599 __ TailCallStub(&stub0); | 4552 __ TailCallStub(&stub0); |
4600 | 4553 |
4601 __ Bind(&n_case); | 4554 __ Bind(&n_case); |
4602 // N arguments. | 4555 // N arguments. |
4603 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); | 4556 ArrayNArgumentsConstructorStub stubN(isolate()); |
4604 __ TailCallStub(&stubN); | 4557 __ TailCallStub(&stubN); |
4605 } | 4558 } |
4606 | 4559 |
4607 | 4560 |
4608 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { | 4561 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
4609 // ----------- S t a t e ------------- | 4562 // ----------- S t a t e ------------- |
4610 // -- x0 : argc | 4563 // -- x0 : argc |
4611 // -- x1 : constructor | 4564 // -- x1 : constructor |
4612 // -- sp[0] : return address | 4565 // -- sp[0] : return address |
4613 // -- sp[4] : last argument | 4566 // -- sp[4] : last argument |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5822 kStackUnwindSpace, NULL, spill_offset, | 5775 kStackUnwindSpace, NULL, spill_offset, |
5823 return_value_operand, NULL); | 5776 return_value_operand, NULL); |
5824 } | 5777 } |
5825 | 5778 |
5826 #undef __ | 5779 #undef __ |
5827 | 5780 |
5828 } // namespace internal | 5781 } // namespace internal |
5829 } // namespace v8 | 5782 } // namespace v8 |
5830 | 5783 |
5831 #endif // V8_TARGET_ARCH_ARM64 | 5784 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |