OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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/ppc/code-stubs-ppc.h" | 16 #include "src/ppc/code-stubs-ppc.h" |
17 #include "src/regexp/jsregexp.h" | 17 #include "src/regexp/jsregexp.h" |
18 #include "src/regexp/regexp-macro-assembler.h" | 18 #include "src/regexp/regexp-macro-assembler.h" |
19 #include "src/runtime/runtime.h" | 19 #include "src/runtime/runtime.h" |
20 | 20 |
21 namespace v8 { | 21 namespace v8 { |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
| 24 #define __ ACCESS_MASM(masm) |
24 | 25 |
25 static void InitializeArrayConstructorDescriptor( | 26 void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) { |
26 Isolate* isolate, CodeStubDescriptor* descriptor, | 27 __ ShiftLeftImm(r0, r3, Operand(kPointerSizeLog2)); |
27 int constant_stack_parameter_count) { | 28 __ StorePX(r4, MemOperand(sp, r0)); |
28 Address deopt_handler = | 29 __ push(r4); |
29 Runtime::FunctionForId(Runtime::kArrayConstructor)->entry; | 30 __ push(r5); |
30 | 31 __ addi(r3, r3, Operand(3)); |
31 if (constant_stack_parameter_count == 0) { | 32 __ TailCallRuntime(Runtime::kNewArray); |
32 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | |
33 JS_FUNCTION_STUB_MODE); | |
34 } else { | |
35 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, | |
36 JS_FUNCTION_STUB_MODE); | |
37 } | |
38 } | 33 } |
39 | 34 |
40 | |
41 static void InitializeInternalArrayConstructorDescriptor( | |
42 Isolate* isolate, CodeStubDescriptor* descriptor, | |
43 int constant_stack_parameter_count) { | |
44 Address deopt_handler = | |
45 Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry; | |
46 | |
47 if (constant_stack_parameter_count == 0) { | |
48 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | |
49 JS_FUNCTION_STUB_MODE); | |
50 } else { | |
51 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, | |
52 JS_FUNCTION_STUB_MODE); | |
53 } | |
54 } | |
55 | |
56 | |
57 void ArrayNArgumentsConstructorStub::InitializeDescriptor( | |
58 CodeStubDescriptor* descriptor) { | |
59 InitializeArrayConstructorDescriptor(isolate(), descriptor, -1); | |
60 } | |
61 | |
62 | |
63 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 35 void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
64 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; | 36 Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry; |
65 descriptor->Initialize(r3, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 37 descriptor->Initialize(r3, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
66 } | 38 } |
67 | 39 |
68 void FastFunctionBindStub::InitializeDescriptor( | 40 void FastFunctionBindStub::InitializeDescriptor( |
69 CodeStubDescriptor* descriptor) { | 41 CodeStubDescriptor* descriptor) { |
70 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; | 42 Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry; |
71 descriptor->Initialize(r3, deopt_handler, -1, JS_FUNCTION_STUB_MODE); | 43 descriptor->Initialize(r3, deopt_handler, -1, JS_FUNCTION_STUB_MODE); |
72 } | 44 } |
73 | 45 |
74 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | |
75 CodeStubDescriptor* descriptor) { | |
76 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | |
77 } | |
78 | |
79 | |
80 #define __ ACCESS_MASM(masm) | |
81 | |
82 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 46 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
83 Condition cond); | 47 Condition cond); |
84 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, | 48 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
85 Register rhs, Label* lhs_not_nan, | 49 Register rhs, Label* lhs_not_nan, |
86 Label* slow, bool strict); | 50 Label* slow, bool strict); |
87 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, | 51 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
88 Register rhs); | 52 Register rhs); |
89 | 53 |
90 | 54 |
91 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 55 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 } | 939 } |
976 | 940 |
977 | 941 |
978 bool CEntryStub::NeedsImmovableCode() { return true; } | 942 bool CEntryStub::NeedsImmovableCode() { return true; } |
979 | 943 |
980 | 944 |
981 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 945 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
982 CEntryStub::GenerateAheadOfTime(isolate); | 946 CEntryStub::GenerateAheadOfTime(isolate); |
983 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 947 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
984 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 948 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
985 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 949 CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); |
986 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); | 950 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
987 CreateWeakCellStub::GenerateAheadOfTime(isolate); | 951 CreateWeakCellStub::GenerateAheadOfTime(isolate); |
988 BinaryOpICStub::GenerateAheadOfTime(isolate); | 952 BinaryOpICStub::GenerateAheadOfTime(isolate); |
989 StoreRegistersStateStub::GenerateAheadOfTime(isolate); | 953 StoreRegistersStateStub::GenerateAheadOfTime(isolate); |
990 RestoreRegistersStateStub::GenerateAheadOfTime(isolate); | 954 RestoreRegistersStateStub::GenerateAheadOfTime(isolate); |
991 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 955 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
992 StoreFastElementStub::GenerateAheadOfTime(isolate); | 956 StoreFastElementStub::GenerateAheadOfTime(isolate); |
993 TypeofStub::GenerateAheadOfTime(isolate); | 957 TypeofStub::GenerateAheadOfTime(isolate); |
994 } | 958 } |
995 | 959 |
(...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4287 T stub(isolate, kind); | 4251 T stub(isolate, kind); |
4288 stub.GetCode(); | 4252 stub.GetCode(); |
4289 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 4253 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
4290 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 4254 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
4291 stub1.GetCode(); | 4255 stub1.GetCode(); |
4292 } | 4256 } |
4293 } | 4257 } |
4294 } | 4258 } |
4295 | 4259 |
4296 | 4260 |
4297 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 4261 void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
4298 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 4262 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
4299 isolate); | 4263 isolate); |
4300 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 4264 ArrayNArgumentsConstructorStub stub(isolate); |
4301 isolate); | 4265 stub.GetCode(); |
4302 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | |
4303 isolate); | |
4304 } | |
4305 | |
4306 | |
4307 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | |
4308 Isolate* isolate) { | |
4309 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; | 4266 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; |
4310 for (int i = 0; i < 2; i++) { | 4267 for (int i = 0; i < 2; i++) { |
4311 // For internal arrays we only need a few things | 4268 // For internal arrays we only need a few things |
4312 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 4269 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
4313 stubh1.GetCode(); | 4270 stubh1.GetCode(); |
4314 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 4271 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
4315 stubh2.GetCode(); | 4272 stubh2.GetCode(); |
4316 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | |
4317 stubh3.GetCode(); | |
4318 } | 4273 } |
4319 } | 4274 } |
4320 | 4275 |
4321 | 4276 |
4322 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 4277 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
4323 MacroAssembler* masm, AllocationSiteOverrideMode mode) { | 4278 MacroAssembler* masm, AllocationSiteOverrideMode mode) { |
4324 if (argument_count() == ANY) { | 4279 if (argument_count() == ANY) { |
4325 Label not_zero_case, not_one_case; | 4280 Label not_zero_case, not_one_case; |
4326 __ cmpi(r3, Operand::Zero()); | 4281 __ cmpi(r3, Operand::Zero()); |
4327 __ bne(¬_zero_case); | 4282 __ bne(¬_zero_case); |
4328 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4283 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4329 | 4284 |
4330 __ bind(¬_zero_case); | 4285 __ bind(¬_zero_case); |
4331 __ cmpi(r3, Operand(1)); | 4286 __ cmpi(r3, Operand(1)); |
4332 __ bgt(¬_one_case); | 4287 __ bgt(¬_one_case); |
4333 CreateArrayDispatchOneArgument(masm, mode); | 4288 CreateArrayDispatchOneArgument(masm, mode); |
4334 | 4289 |
4335 __ bind(¬_one_case); | 4290 __ bind(¬_one_case); |
4336 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4291 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
| 4292 __ TailCallStub(&stub); |
4337 } else if (argument_count() == NONE) { | 4293 } else if (argument_count() == NONE) { |
4338 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4294 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4339 } else if (argument_count() == ONE) { | 4295 } else if (argument_count() == ONE) { |
4340 CreateArrayDispatchOneArgument(masm, mode); | 4296 CreateArrayDispatchOneArgument(masm, mode); |
4341 } else if (argument_count() == MORE_THAN_ONE) { | 4297 } else if (argument_count() == MORE_THAN_ONE) { |
4342 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4298 ArrayNArgumentsConstructorStub stub(masm->isolate()); |
| 4299 __ TailCallStub(&stub); |
4343 } else { | 4300 } else { |
4344 UNREACHABLE(); | 4301 UNREACHABLE(); |
4345 } | 4302 } |
4346 } | 4303 } |
4347 | 4304 |
4348 | 4305 |
4349 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 4306 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
4350 // ----------- S t a t e ------------- | 4307 // ----------- S t a t e ------------- |
4351 // -- r3 : argc (only if argument_count() == ANY) | 4308 // -- r3 : argc (only if argument_count() == ANY) |
4352 // -- r4 : constructor | 4309 // -- r4 : constructor |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4416 } | 4373 } |
4417 | 4374 |
4418 | 4375 |
4419 void InternalArrayConstructorStub::GenerateCase(MacroAssembler* masm, | 4376 void InternalArrayConstructorStub::GenerateCase(MacroAssembler* masm, |
4420 ElementsKind kind) { | 4377 ElementsKind kind) { |
4421 __ cmpli(r3, Operand(1)); | 4378 __ cmpli(r3, Operand(1)); |
4422 | 4379 |
4423 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); | 4380 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); |
4424 __ TailCallStub(&stub0, lt); | 4381 __ TailCallStub(&stub0, lt); |
4425 | 4382 |
4426 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); | 4383 ArrayNArgumentsConstructorStub stubN(isolate()); |
4427 __ TailCallStub(&stubN, gt); | 4384 __ TailCallStub(&stubN, gt); |
4428 | 4385 |
4429 if (IsFastPackedElementsKind(kind)) { | 4386 if (IsFastPackedElementsKind(kind)) { |
4430 // We might need to create a holey array | 4387 // We might need to create a holey array |
4431 // look at the first argument | 4388 // look at the first argument |
4432 __ LoadP(r6, MemOperand(sp, 0)); | 4389 __ LoadP(r6, MemOperand(sp, 0)); |
4433 __ cmpi(r6, Operand::Zero()); | 4390 __ cmpi(r6, Operand::Zero()); |
4434 | 4391 |
4435 InternalArraySingleArgumentConstructorStub stub1_holey( | 4392 InternalArraySingleArgumentConstructorStub stub1_holey( |
4436 isolate(), GetHoleyElementsKind(kind)); | 4393 isolate(), GetHoleyElementsKind(kind)); |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5638 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5595 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
5639 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5596 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5640 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5597 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5641 } | 5598 } |
5642 | 5599 |
5643 #undef __ | 5600 #undef __ |
5644 } // namespace internal | 5601 } // namespace internal |
5645 } // namespace v8 | 5602 } // namespace v8 |
5646 | 5603 |
5647 #endif // V8_TARGET_ARCH_PPC | 5604 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |