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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/ic/handler-compiler.h" | 12 #include "src/ic/handler-compiler.h" |
13 #include "src/ic/ic.h" | 13 #include "src/ic/ic.h" |
14 #include "src/ic/stub-cache.h" | 14 #include "src/ic/stub-cache.h" |
15 #include "src/isolate.h" | 15 #include "src/isolate.h" |
16 #include "src/regexp/jsregexp.h" | 16 #include "src/regexp/jsregexp.h" |
17 #include "src/regexp/regexp-macro-assembler.h" | 17 #include "src/regexp/regexp-macro-assembler.h" |
18 #include "src/runtime/runtime.h" | 18 #include "src/runtime/runtime.h" |
19 #include "src/x87/code-stubs-x87.h" | 19 #include "src/x87/code-stubs-x87.h" |
20 #include "src/x87/frames-x87.h" | 20 #include "src/x87/frames-x87.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 __ pop(ecx); |
28 int constant_stack_parameter_count) { | 29 __ mov(MemOperand(esp, eax, times_4, 0), edi); |
29 // register state | 30 __ push(edi); |
30 // eax -- number of arguments | 31 __ push(ebx); |
31 // edi -- function | 32 __ push(ecx); |
32 // ebx -- allocation site with elements kind | 33 __ add(eax, Immediate(3)); |
33 Address deopt_handler = Runtime::FunctionForId( | 34 __ TailCallRuntime(Runtime::kNewArray); |
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(eax, deopt_handler, constant_stack_parameter_count, | |
41 JS_FUNCTION_STUB_MODE); | |
42 } | |
43 } | 35 } |
44 | 36 |
45 | |
46 static void InitializeInternalArrayConstructorDescriptor( | |
47 Isolate* isolate, CodeStubDescriptor* descriptor, | |
48 int constant_stack_parameter_count) { | |
49 // register state | |
50 // eax -- number of arguments | |
51 // edi -- constructor function | |
52 Address deopt_handler = Runtime::FunctionForId( | |
53 Runtime::kInternalArrayConstructor)->entry; | |
54 | |
55 if (constant_stack_parameter_count == 0) { | |
56 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | |
57 JS_FUNCTION_STUB_MODE); | |
58 } else { | |
59 descriptor->Initialize(eax, deopt_handler, constant_stack_parameter_count, | |
60 JS_FUNCTION_STUB_MODE); | |
61 } | |
62 } | |
63 | |
64 | |
65 void ArrayNArgumentsConstructorStub::InitializeDescriptor( | |
66 CodeStubDescriptor* descriptor) { | |
67 InitializeArrayConstructorDescriptor(isolate(), descriptor, -1); | |
68 } | |
69 | |
70 | |
71 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 37 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
72 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; | 38 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; |
73 descriptor->Initialize(eax, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 39 descriptor->Initialize(eax, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
74 } | 40 } |
75 | 41 |
76 void FastFunctionBindStub::InitializeDescriptor( | 42 void FastFunctionBindStub::InitializeDescriptor( |
77 CodeStubDescriptor* descriptor) { | 43 CodeStubDescriptor* descriptor) { |
78 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; | 44 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; |
79 descriptor->Initialize(eax, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 45 descriptor->Initialize(eax, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
80 } | 46 } |
81 | 47 |
82 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | |
83 CodeStubDescriptor* descriptor) { | |
84 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | |
85 } | |
86 | |
87 | |
88 #define __ ACCESS_MASM(masm) | |
89 | |
90 | |
91 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 48 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
92 ExternalReference miss) { | 49 ExternalReference miss) { |
93 // Update the static counter each time a new code stub is generated. | 50 // Update the static counter each time a new code stub is generated. |
94 isolate()->counters()->code_stubs()->Increment(); | 51 isolate()->counters()->code_stubs()->Increment(); |
95 | 52 |
96 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); | 53 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); |
97 int param_count = descriptor.GetRegisterParameterCount(); | 54 int param_count = descriptor.GetRegisterParameterCount(); |
98 { | 55 { |
99 // Call the runtime system in a fresh internal frame. | 56 // Call the runtime system in a fresh internal frame. |
100 FrameScope scope(masm, StackFrame::INTERNAL); | 57 FrameScope scope(masm, StackFrame::INTERNAL); |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 bool CEntryStub::NeedsImmovableCode() { | 1441 bool CEntryStub::NeedsImmovableCode() { |
1485 return false; | 1442 return false; |
1486 } | 1443 } |
1487 | 1444 |
1488 | 1445 |
1489 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 1446 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
1490 CEntryStub::GenerateAheadOfTime(isolate); | 1447 CEntryStub::GenerateAheadOfTime(isolate); |
1491 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 1448 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
1492 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 1449 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
1493 // It is important that the store buffer overflow stubs are generated first. | 1450 // It is important that the store buffer overflow stubs are generated first. |
1494 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 1451 CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); |
1495 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); | 1452 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
1496 CreateWeakCellStub::GenerateAheadOfTime(isolate); | 1453 CreateWeakCellStub::GenerateAheadOfTime(isolate); |
1497 BinaryOpICStub::GenerateAheadOfTime(isolate); | 1454 BinaryOpICStub::GenerateAheadOfTime(isolate); |
1498 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 1455 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
1499 StoreFastElementStub::GenerateAheadOfTime(isolate); | 1456 StoreFastElementStub::GenerateAheadOfTime(isolate); |
1500 TypeofStub::GenerateAheadOfTime(isolate); | 1457 TypeofStub::GenerateAheadOfTime(isolate); |
1501 } | 1458 } |
1502 | 1459 |
1503 | 1460 |
1504 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 1461 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3943 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 3900 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
3944 T stub(isolate, kind); | 3901 T stub(isolate, kind); |
3945 stub.GetCode(); | 3902 stub.GetCode(); |
3946 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 3903 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
3947 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 3904 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
3948 stub1.GetCode(); | 3905 stub1.GetCode(); |
3949 } | 3906 } |
3950 } | 3907 } |
3951 } | 3908 } |
3952 | 3909 |
3953 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 3910 void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
3954 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 3911 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
3955 isolate); | 3912 isolate); |
3956 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 3913 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
3957 isolate); | 3914 isolate); |
3958 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 3915 ArrayNArgumentsConstructorStub stub(isolate); |
3959 isolate); | 3916 stub.GetCode(); |
3960 } | |
3961 | 3917 |
3962 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | |
3963 Isolate* isolate) { | |
3964 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; | 3918 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; |
3965 for (int i = 0; i < 2; i++) { | 3919 for (int i = 0; i < 2; i++) { |
3966 // For internal arrays we only need a few things | 3920 // For internal arrays we only need a few things |
3967 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 3921 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
3968 stubh1.GetCode(); | 3922 stubh1.GetCode(); |
3969 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 3923 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
3970 stubh2.GetCode(); | 3924 stubh2.GetCode(); |
3971 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | |
3972 stubh3.GetCode(); | |
3973 } | 3925 } |
3974 } | 3926 } |
3975 | 3927 |
3976 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 3928 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
3977 MacroAssembler* masm, AllocationSiteOverrideMode mode) { | 3929 MacroAssembler* masm, AllocationSiteOverrideMode mode) { |
3978 if (argument_count() == ANY) { | 3930 if (argument_count() == ANY) { |
3979 Label not_zero_case, not_one_case; | 3931 Label not_zero_case, not_one_case; |
3980 __ test(eax, eax); | 3932 __ test(eax, eax); |
3981 __ j(not_zero, ¬_zero_case); | 3933 __ j(not_zero, ¬_zero_case); |
3982 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 3934 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
3983 | 3935 |
3984 __ bind(¬_zero_case); | 3936 __ bind(¬_zero_case); |
3985 __ cmp(eax, 1); | 3937 __ cmp(eax, 1); |
3986 __ j(greater, ¬_one_case); | 3938 __ j(greater, ¬_one_case); |
3987 CreateArrayDispatchOneArgument(masm, mode); | 3939 CreateArrayDispatchOneArgument(masm, mode); |
3988 | 3940 |
3989 __ bind(¬_one_case); | 3941 __ bind(¬_one_case); |
3990 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 3942 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
| 3943 __ TailCallStub(&stub); |
3991 } else if (argument_count() == NONE) { | 3944 } else if (argument_count() == NONE) { |
3992 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 3945 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
3993 } else if (argument_count() == ONE) { | 3946 } else if (argument_count() == ONE) { |
3994 CreateArrayDispatchOneArgument(masm, mode); | 3947 CreateArrayDispatchOneArgument(masm, mode); |
3995 } else if (argument_count() == MORE_THAN_ONE) { | 3948 } else if (argument_count() == MORE_THAN_ONE) { |
3996 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 3949 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
| 3950 __ TailCallStub(&stub); |
3997 } else { | 3951 } else { |
3998 UNREACHABLE(); | 3952 UNREACHABLE(); |
3999 } | 3953 } |
4000 } | 3954 } |
4001 | 3955 |
4002 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 3956 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
4003 // ----------- S t a t e ------------- | 3957 // ----------- S t a t e ------------- |
4004 // -- eax : argc (only if argument_count() is ANY or MORE_THAN_ONE) | 3958 // -- eax : argc (only if argument_count() is ANY or MORE_THAN_ONE) |
4005 // -- ebx : AllocationSite or undefined | 3959 // -- ebx : AllocationSite or undefined |
4006 // -- edi : constructor | 3960 // -- edi : constructor |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 InternalArraySingleArgumentConstructorStub stub1_holey( | 4050 InternalArraySingleArgumentConstructorStub stub1_holey( |
4097 isolate(), GetHoleyElementsKind(kind)); | 4051 isolate(), GetHoleyElementsKind(kind)); |
4098 __ TailCallStub(&stub1_holey); | 4052 __ TailCallStub(&stub1_holey); |
4099 } | 4053 } |
4100 | 4054 |
4101 __ bind(&normal_sequence); | 4055 __ bind(&normal_sequence); |
4102 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); | 4056 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); |
4103 __ TailCallStub(&stub1); | 4057 __ TailCallStub(&stub1); |
4104 | 4058 |
4105 __ bind(¬_one_case); | 4059 __ bind(¬_one_case); |
4106 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); | 4060 ArrayNArgumentsConstructorStub stubN(isolate()); |
4107 __ TailCallStub(&stubN); | 4061 __ TailCallStub(&stubN); |
4108 } | 4062 } |
4109 | 4063 |
4110 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { | 4064 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
4111 // ----------- S t a t e ------------- | 4065 // ----------- S t a t e ------------- |
4112 // -- eax : argc | 4066 // -- eax : argc |
4113 // -- edi : constructor | 4067 // -- edi : constructor |
4114 // -- esp[0] : return address | 4068 // -- esp[0] : return address |
4115 // -- esp[4] : last argument | 4069 // -- esp[4] : last argument |
4116 // ----------------------------------- | 4070 // ----------------------------------- |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5296 kStackUnwindSpace, nullptr, return_value_operand, | 5250 kStackUnwindSpace, nullptr, return_value_operand, |
5297 NULL); | 5251 NULL); |
5298 } | 5252 } |
5299 | 5253 |
5300 #undef __ | 5254 #undef __ |
5301 | 5255 |
5302 } // namespace internal | 5256 } // namespace internal |
5303 } // namespace v8 | 5257 } // namespace v8 |
5304 | 5258 |
5305 #endif // V8_TARGET_ARCH_X87 | 5259 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |