Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 988653003: Use platform specific stubs for vector-based Load/KeyedLoad. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Included the MIPs port from Paul and Akos. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM 7 #if V8_TARGET_ARCH_ARM
8 8
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/code-stubs.h" 11 #include "src/code-stubs.h"
12 #include "src/codegen.h" 12 #include "src/codegen.h"
13 #include "src/ic/handler-compiler.h" 13 #include "src/ic/handler-compiler.h"
14 #include "src/ic/ic.h" 14 #include "src/ic/ic.h"
15 #include "src/ic/stub-cache.h"
15 #include "src/isolate.h" 16 #include "src/isolate.h"
16 #include "src/jsregexp.h" 17 #include "src/jsregexp.h"
17 #include "src/regexp-macro-assembler.h" 18 #include "src/regexp-macro-assembler.h"
18 #include "src/runtime/runtime.h" 19 #include "src/runtime/runtime.h"
19 20
20 namespace v8 { 21 namespace v8 {
21 namespace internal { 22 namespace internal {
22 23
23 24
24 static void InitializeArrayConstructorDescriptor( 25 static void InitializeArrayConstructorDescriptor(
(...skipping 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after
4316 } 4317 }
4317 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); 4318 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE);
4318 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); 4319 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2));
4319 __ add(sp, sp, r1); 4320 __ add(sp, sp, r1);
4320 __ Ret(); 4321 __ Ret();
4321 } 4322 }
4322 4323
4323 4324
4324 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { 4325 void LoadICTrampolineStub::Generate(MacroAssembler* masm) {
4325 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4326 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4326 VectorLoadStub stub(isolate(), state()); 4327 VectorRawLoadStub stub(isolate(), state());
4327 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4328 stub.GenerateForTrampoline(masm);
4328 } 4329 }
4329 4330
4330 4331
4331 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { 4332 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) {
4332 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4333 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4333 VectorKeyedLoadStub stub(isolate()); 4334 VectorRawKeyedLoadStub stub(isolate());
4334 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4335 stub.GenerateForTrampoline(masm);
4335 } 4336 }
4336 4337
4337 4338
4338 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 4339 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
4339 EmitLoadTypeFeedbackVector(masm, r2); 4340 EmitLoadTypeFeedbackVector(masm, r2);
4340 CallICStub stub(isolate(), state()); 4341 CallICStub stub(isolate(), state());
4341 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4342 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
4342 } 4343 }
4343 4344
4344 4345
4345 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { 4346 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) {
4346 EmitLoadTypeFeedbackVector(masm, r2); 4347 EmitLoadTypeFeedbackVector(masm, r2);
4347 CallIC_ArrayStub stub(isolate(), state()); 4348 CallIC_ArrayStub stub(isolate(), state());
4348 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4349 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
4349 } 4350 }
4350 4351
4351 4352
4353 void VectorRawLoadStub::Generate(MacroAssembler* masm) {
4354 GenerateImpl(masm, false);
4355 }
4356
4357
4358 void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4359 GenerateImpl(masm, true);
4360 }
4361
4362
4363 static void HandleArrayCases(MacroAssembler* masm, Register receiver,
4364 Register key, Register vector, Register slot,
4365 Register feedback, Register scratch1,
4366 Register scratch2, Register scratch3,
4367 bool is_polymorphic, Label* miss) {
4368 // feedback initially contains the feedback array
4369 Label next_loop, prepare_next;
4370 Label load_smi_map, compare_map;
4371 Label start_polymorphic;
4372
4373 Register receiver_map = scratch1;
4374 Register cached_map = scratch2;
4375
4376 // Receiver might not be a heap object.
4377 __ JumpIfSmi(receiver, &load_smi_map);
4378 __ ldr(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4379 __ bind(&compare_map);
4380 __ ldr(cached_map,
4381 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0)));
4382 __ ldr(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4383 __ cmp(receiver_map, cached_map);
4384 __ b(ne, &start_polymorphic);
4385 // found, now call handler.
4386 Register handler = feedback;
4387 __ ldr(handler, FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1)));
4388 __ add(pc, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4389
4390
4391 Register length = scratch3;
4392 __ bind(&start_polymorphic);
4393 __ ldr(length, FieldMemOperand(feedback, FixedArray::kLengthOffset));
4394 if (!is_polymorphic) {
4395 // If the IC could be monomorphic we have to make sure we don't go past the
4396 // end of the feedback array.
4397 __ cmp(length, Operand(Smi::FromInt(2)));
4398 __ b(eq, miss);
4399 }
4400
4401 Register too_far = length;
4402 Register pointer_reg = feedback;
4403
4404 // +-----+------+------+-----+-----+ ... ----+
4405 // | map | len | wm0 | h0 | wm1 | hN |
4406 // +-----+------+------+-----+-----+ ... ----+
4407 // 0 1 2 len-1
4408 // ^ ^
4409 // | |
4410 // pointer_reg too_far
4411 // aka feedback scratch3
4412 // also need receiver_map (aka scratch1)
4413 // use cached_map (scratch2) to look in the weak map values.
4414 __ add(too_far, feedback, Operand::PointerOffsetFromSmiKey(length));
4415 __ add(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
4416 __ add(pointer_reg, feedback,
4417 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag));
4418
4419 __ bind(&next_loop);
4420 __ ldr(cached_map, MemOperand(pointer_reg));
4421 __ ldr(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4422 __ cmp(receiver_map, cached_map);
4423 __ b(ne, &prepare_next);
4424 __ ldr(handler, MemOperand(pointer_reg, kPointerSize));
4425 __ add(pc, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4426
4427 __ bind(&prepare_next);
4428 __ add(pointer_reg, pointer_reg, Operand(kPointerSize * 2));
4429 __ cmp(pointer_reg, too_far);
4430 __ b(lt, &next_loop);
4431
4432 // We exhausted our array of map handler pairs.
4433 __ jmp(miss);
4434
4435 __ bind(&load_smi_map);
4436 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
4437 __ jmp(&compare_map);
4438 }
4439
4440
4441 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
4442 Register key, Register vector, Register slot,
4443 Register weak_cell, Register scratch,
4444 Label* miss) {
4445 // feedback initially contains the feedback array
4446 Label compare_smi_map;
4447 Register receiver_map = scratch;
4448 Register cached_map = weak_cell;
4449
4450 // Move the weak map into the weak_cell register.
4451 __ ldr(cached_map, FieldMemOperand(weak_cell, WeakCell::kValueOffset));
4452
4453 // Receiver might not be a heap object.
4454 __ JumpIfSmi(receiver, &compare_smi_map);
4455 __ ldr(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4456 __ cmp(cached_map, receiver_map);
4457 __ b(ne, miss);
4458
4459 Register handler = weak_cell;
4460 __ add(handler, vector, Operand::PointerOffsetFromSmiKey(slot));
4461 __ ldr(handler,
4462 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4463 __ add(pc, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4464
4465 // In microbenchmarks, it made sense to unroll this code so that the call to
4466 // the handler is duplicated for a HeapObject receiver and a Smi receiver.
4467 __ bind(&compare_smi_map);
4468 __ CompareRoot(weak_cell, Heap::kHeapNumberMapRootIndex);
4469 __ b(ne, miss);
4470 __ add(handler, vector, Operand::PointerOffsetFromSmiKey(slot));
4471 __ ldr(handler,
4472 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4473 __ add(pc, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4474 }
4475
4476
4477 void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4478 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r1
4479 Register name = VectorLoadICDescriptor::NameRegister(); // r2
4480 Register vector = VectorLoadICDescriptor::VectorRegister(); // r3
4481 Register slot = VectorLoadICDescriptor::SlotRegister(); // r0
4482 Register feedback = r4;
4483 Register scratch1 = r5;
4484
4485 __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot));
4486 __ ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4487
4488 // Is it a weak cell?
4489 Label try_array;
4490 Label not_array, smi_key, key_okay, miss;
4491 __ ldr(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4492 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
4493 __ b(ne, &try_array);
4494 HandleMonomorphicCase(masm, receiver, name, vector, slot, feedback, scratch1,
4495 &miss);
4496
4497 // Is it a fixed array?
4498 __ bind(&try_array);
4499 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4500 __ b(ne, &not_array);
4501 HandleArrayCases(masm, receiver, name, vector, slot, feedback, scratch1, r8,
4502 r9, true, &miss);
4503
4504 __ bind(&not_array);
4505 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4506 __ b(ne, &miss);
4507 Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags(
4508 Code::ComputeHandlerFlags(Code::LOAD_IC));
4509 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::LOAD_IC, code_flags,
4510 false, receiver, name, feedback,
4511 scratch1, r8, r9);
4512
4513 __ bind(&miss);
4514 LoadIC::GenerateMiss(masm);
4515 }
4516
4517
4518 void VectorRawKeyedLoadStub::Generate(MacroAssembler* masm) {
4519 GenerateImpl(masm, false);
4520 }
4521
4522
4523 void VectorRawKeyedLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4524 GenerateImpl(masm, true);
4525 }
4526
4527
4528 void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4529 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r1
4530 Register key = VectorLoadICDescriptor::NameRegister(); // r2
4531 Register vector = VectorLoadICDescriptor::VectorRegister(); // r3
4532 Register slot = VectorLoadICDescriptor::SlotRegister(); // r0
4533 Register feedback = r4;
4534 Register scratch1 = r5;
4535
4536 __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot));
4537 __ ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4538
4539 // Is it a weak cell?
4540 Label try_array;
4541 Label not_array, smi_key, key_okay, miss;
4542 __ ldr(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4543 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
4544 __ b(ne, &try_array);
4545 __ JumpIfNotSmi(key, &miss);
4546 HandleMonomorphicCase(masm, receiver, key, vector, slot, feedback, scratch1,
4547 &miss);
4548
4549 __ bind(&try_array);
4550 // Is it a fixed array?
4551 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4552 __ b(ne, &not_array);
4553 // We have a polymorphic element handler.
4554 __ JumpIfNotSmi(key, &miss);
4555
4556 Label polymorphic, try_poly_name;
4557 __ bind(&polymorphic);
4558 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r8,
4559 r9, true, &miss);
4560
4561 __ bind(&not_array);
4562 // Is it generic?
4563 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4564 __ b(ne, &try_poly_name);
4565 Handle<Code> megamorphic_stub =
4566 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate());
4567 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET);
4568
4569 __ bind(&try_poly_name);
4570 // We might have a name in feedback, and a fixed array in the next slot.
4571 __ cmp(key, feedback);
4572 __ b(ne, &miss);
4573 // If the name comparison succeeded, we know we have a fixed array with
4574 // at least one map/handler pair.
4575 __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot));
4576 __ ldr(feedback,
4577 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize));
4578 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r8,
4579 r9, false, &miss);
4580
4581 __ bind(&miss);
4582 KeyedLoadIC::GenerateMiss(masm);
4583 }
4584
4585
4352 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 4586 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
4353 if (masm->isolate()->function_entry_hook() != NULL) { 4587 if (masm->isolate()->function_entry_hook() != NULL) {
4354 ProfileEntryHookStub stub(masm->isolate()); 4588 ProfileEntryHookStub stub(masm->isolate());
4355 int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize; 4589 int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize;
4356 PredictableCodeSizeScope predictable(masm, code_size); 4590 PredictableCodeSizeScope predictable(masm, code_size);
4357 __ push(lr); 4591 __ push(lr);
4358 __ CallStub(&stub); 4592 __ CallStub(&stub);
4359 __ pop(lr); 4593 __ pop(lr);
4360 } 4594 }
4361 } 4595 }
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
5050 kStackUnwindSpace, NULL, 5284 kStackUnwindSpace, NULL,
5051 MemOperand(fp, 6 * kPointerSize), NULL); 5285 MemOperand(fp, 6 * kPointerSize), NULL);
5052 } 5286 }
5053 5287
5054 5288
5055 #undef __ 5289 #undef __
5056 5290
5057 } } // namespace v8::internal 5291 } } // namespace v8::internal
5058 5292
5059 #endif // V8_TARGET_ARCH_ARM 5293 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698