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

Side by Side Diff: src/x64/code-stubs-x64.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: slot_count = FLAG_vector_ics ? 2 : 1. 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
OLDNEW
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.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/isolate.h" 15 #include "src/isolate.h"
15 #include "src/jsregexp.h" 16 #include "src/jsregexp.h"
16 #include "src/regexp-macro-assembler.h" 17 #include "src/regexp-macro-assembler.h"
17 #include "src/runtime/runtime.h" 18 #include "src/runtime/runtime.h"
18 19
19 namespace v8 { 20 namespace v8 {
20 namespace internal { 21 namespace internal {
21 22
22 23
23 static void InitializeArrayConstructorDescriptor( 24 static void InitializeArrayConstructorDescriptor(
(...skipping 4306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4330 __ PopReturnAddressTo(rcx); 4331 __ PopReturnAddressTo(rcx);
4331 int additional_offset = 4332 int additional_offset =
4332 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; 4333 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0;
4333 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); 4334 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset));
4334 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. 4335 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack.
4335 } 4336 }
4336 4337
4337 4338
4338 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { 4339 void LoadICTrampolineStub::Generate(MacroAssembler* masm) {
4339 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4340 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4340 VectorLoadStub stub(isolate(), state()); 4341 VectorRawLoadStub stub(isolate(), state());
4341 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4342 stub.GenerateForTrampoline(masm);
4342 } 4343 }
4343 4344
4344 4345
4345 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { 4346 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) {
4346 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4347 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4347 VectorKeyedLoadStub stub(isolate()); 4348 VectorRawKeyedLoadStub stub(isolate());
4348 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4349 stub.GenerateForTrampoline(masm);
4349 } 4350 }
4350 4351
4351 4352
4353 static void HandlePolymorphic(MacroAssembler* masm, Register receiver,
4354 Register key, Register vector, Register slot,
4355 Register feedback, Register receiver_map,
4356 Register length, Register element0,
4357 Register scratch1, Label* miss) {
4358 Label next, next_loop, prepare_next;
4359
4360 // feedback initially contains vector[slot] and is a FixedArray.
4361 Register counter = scratch1;
4362 Register array_map = element0;
4363
4364 // length is in integer32 form.
4365 // We prefetched the first element. Examine that outside of the loop.
4366 __ cmpp(receiver_map, FieldOperand(array_map, WeakCell::kValueOffset));
4367 __ j(not_equal, &next);
4368 __ movp(feedback, FieldOperand(feedback, FixedArray::OffsetOfElementAt(1)));
4369 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
4370 __ jmp(feedback);
4371
4372 __ bind(&next);
4373
4374 // Polymorphic, we have to loop from 2 to length by twos.
4375 __ movp(counter, Immediate(2));
4376 __ cmpl(counter, length);
4377 __ j(greater_equal, miss);
4378
4379 __ bind(&next_loop);
4380 __ movp(array_map, FieldOperand(feedback, counter, times_pointer_size,
4381 FixedArray::kHeaderSize));
4382 __ cmpp(receiver_map, FieldOperand(array_map, WeakCell::kValueOffset));
4383 __ j(not_equal, &prepare_next);
4384 __ movp(feedback, FieldOperand(feedback, counter, times_pointer_size,
4385 FixedArray::kHeaderSize + kPointerSize));
4386 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
4387 __ jmp(feedback);
4388
4389 __ bind(&prepare_next);
4390 __ addl(counter, Immediate(2));
4391 __ cmpl(counter, length);
4392 __ j(less, &next_loop);
4393
4394 // We exhausted our array of map handler pairs.
4395 __ jmp(miss);
4396 }
4397
4398
4399 static void HandleMonoOrPolyName(MacroAssembler* masm, Register receiver,
4400 Register key, Register vector, Register slot,
4401 Register feedback, Register receiver_map,
4402 Register scratch2, Register scratch3,
4403 Register scratch4, Label* miss) {
4404 Label next, next_loop, prepare_next;
4405
4406 // feedback initially contains vector[slot] and is a FixedArray.
4407 Register length = scratch2;
4408 Register counter = scratch3;
4409 Register array_map = scratch4;
4410
4411 // Try monomorphic case without loading array length.
4412 __ movp(array_map, FieldOperand(feedback, FixedArray::OffsetOfElementAt(0)));
4413 __ cmpp(receiver_map, FieldOperand(array_map, WeakCell::kValueOffset));
4414 __ j(not_equal, &next);
4415 __ movp(feedback, FieldOperand(feedback, FixedArray::OffsetOfElementAt(1)));
4416 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
4417 __ jmp(feedback);
4418
4419 // Polymorphic, we have to loop from 2 to length by twos.
4420 __ bind(&next);
4421 __ movp(length, FieldOperand(feedback, FixedArray::kLengthOffset));
4422 __ SmiToInteger32(length, length);
4423 __ cmpl(length, Immediate(2));
4424 __ j(equal, miss);
4425 __ movp(counter, Immediate(2));
4426
4427 __ bind(&next_loop);
4428 __ movp(array_map, FieldOperand(feedback, counter, times_pointer_size,
4429 FixedArray::kHeaderSize));
4430 __ cmpp(receiver_map, FieldOperand(array_map, WeakCell::kValueOffset));
4431 __ j(not_equal, &prepare_next);
4432 __ movp(feedback, FieldOperand(feedback, counter, times_pointer_size,
4433 FixedArray::kHeaderSize + kPointerSize));
4434 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
4435 __ jmp(feedback);
4436
4437 __ bind(&prepare_next);
4438 __ addl(counter, Immediate(2));
4439 __ cmpl(counter, length);
4440 __ j(less, &next_loop);
4441
4442 // We exhausted our array of map handler pairs.
4443 __ jmp(miss);
4444 }
4445
4446
4447 void VectorRawLoadStub::Generate(MacroAssembler* masm) {
4448 GenerateImpl(masm, false);
4449 }
4450
4451
4452 void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4453 GenerateImpl(masm, true);
4454 }
4455
4456
4457 void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4458 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // rdx
4459 Register name = VectorLoadICDescriptor::NameRegister(); // rcx
4460 Register vector = VectorLoadICDescriptor::VectorRegister(); // rbx
4461 Register slot = VectorLoadICDescriptor::SlotRegister(); // rax
4462 Factory* factory = masm->isolate()->factory();
4463 Register scratch = rdi;
4464 Register integer_slot = r8;
4465
4466 __ SmiToInteger32(integer_slot, slot);
4467 __ movp(scratch, FieldOperand(vector, integer_slot, times_pointer_size,
4468 FixedArray::kHeaderSize));
4469
4470 // Is it a weak cell?
4471 Label try_array;
4472 Label megamorphic, smi_key, key_okay, miss;
4473 Register receiver_map = r9;
4474 Register weak_value_or_length = r11;
4475 Label load_smi_map, weak_compare;
4476
4477 __ JumpIfSmi(receiver, &load_smi_map);
4478 __ movp(receiver_map, FieldOperand(receiver, 0));
4479 __ bind(&weak_compare);
4480
4481 STATIC_ASSERT(FixedArray::kLengthOffset == WeakCell::kValueOffset);
4482 __ movp(weak_value_or_length, FieldOperand(scratch, WeakCell::kValueOffset));
4483 __ cmpp(receiver_map, weak_value_or_length);
4484 __ j(not_equal, &try_array);
4485 __ movp(scratch, FieldOperand(vector, integer_slot, times_pointer_size,
4486 FixedArray::kHeaderSize + kPointerSize));
4487 __ leap(scratch, FieldOperand(scratch, Code::kHeaderSize));
4488 __ jmp(scratch);
4489 __ int3(); // We shouldn't get here.
Toon Verwaest 2015/03/11 17:55:02 Same here
mvstanton 2015/03/12 17:05:34 Done.
4490
4491 // Is it a fixed array?
4492 __ bind(&try_array);
4493 __ Cmp(scratch, factory->megamorphic_symbol());
4494 __ j(equal, &megamorphic);
4495
4496 __ movp(r15, FieldOperand(scratch, FixedArray::OffsetOfElementAt(0)));
4497 __ JumpIfSmi(r15, &miss);
4498 // Is it an array or a weak cell? The only way to know is to make
4499 // sure that weak_value_or_length is a smi. If we have a weak cell then
4500 // weak_value_or_length will be undefined.
4501 __ JumpIfNotSmi(weak_value_or_length, &miss);
4502 __ SmiToInteger32(weak_value_or_length, weak_value_or_length);
4503 __ cmpl(weak_value_or_length, Immediate(2));
4504 __ j(less, &miss);
4505 // We have a polymorphic handler, and we know the length, and have
4506 // prefetched the first weak cell that holds a map.
4507 HandlePolymorphic(masm, receiver, name, vector, slot, scratch, receiver_map,
4508 weak_value_or_length, r15, integer_slot, &miss);
4509 __ int3(); // We shouldn't get here.
4510
4511 __ bind(&megamorphic);
4512 Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags(
4513 Code::ComputeHandlerFlags(Code::LOAD_IC));
4514 masm->isolate()->stub_cache()->GenerateProbe(
4515 masm, Code::LOAD_IC, code_flags, false, receiver, name, scratch, no_reg);
4516
4517 __ bind(&miss);
4518 LoadIC::GenerateMiss(masm);
4519
4520 __ bind(&load_smi_map);
4521 __ Move(receiver_map, masm->isolate()->factory()->heap_number_map());
4522 __ jmp(&weak_compare);
4523 }
4524
4525
4526 void VectorRawKeyedLoadStub::Generate(MacroAssembler* masm) {
4527 GenerateImpl(masm, false);
4528 }
4529
4530
4531 void VectorRawKeyedLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4532 GenerateImpl(masm, true);
4533 }
4534
4535
4536 void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4537 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // rdx
4538 Register key = VectorLoadICDescriptor::NameRegister(); // rcx
4539 Register vector = VectorLoadICDescriptor::VectorRegister(); // rbx
4540 Register slot = VectorLoadICDescriptor::SlotRegister(); // rax
4541 Factory* factory = masm->isolate()->factory();
4542 Register scratch = rdi;
4543 Register integer_slot = r8;
4544
4545 __ SmiToInteger32(integer_slot, slot);
4546 __ movp(scratch, FieldOperand(vector, integer_slot, times_pointer_size,
4547 FixedArray::kHeaderSize));
4548
4549 // Is it a weak cell?
4550 Label try_name, try_array, try_megamorphic;
4551 Label not_array, smi_key, key_okay, miss;
4552 Register receiver_map = r9;
4553 Register weak_value_or_length = r11;
4554 Label load_smi_map, weak_compare;
4555
4556 __ JumpIfSmi(receiver, &load_smi_map);
4557 __ movp(receiver_map, FieldOperand(receiver, 0));
4558 __ bind(&weak_compare);
4559
4560 STATIC_ASSERT(FixedArray::kLengthOffset == WeakCell::kValueOffset);
4561 __ movp(weak_value_or_length, FieldOperand(scratch, WeakCell::kValueOffset));
4562 __ cmpp(receiver_map, weak_value_or_length);
4563 __ j(not_equal, &try_name);
4564 __ JumpIfNotSmi(key, &miss);
4565 __ movp(scratch, FieldOperand(vector, integer_slot, times_pointer_size,
4566 FixedArray::kHeaderSize + kPointerSize));
4567 __ leap(scratch, FieldOperand(scratch, Code::kHeaderSize));
4568 __ jmp(scratch);
4569 __ int3(); // We shouldn't get here.
4570
4571 __ bind(&try_name);
4572 // We might have a name in scratch, and a fixed array in the next slot.
4573 __ cmpp(key, scratch);
4574 __ j(not_equal, &try_megamorphic);
4575 // If the name comparison succeeded, we know we have a fixed array with
4576 // at least one map/handler pair.
4577 __ movp(scratch, FieldOperand(vector, integer_slot, times_pointer_size,
4578 FixedArray::kHeaderSize + kPointerSize));
4579 HandleMonoOrPolyName(masm, receiver, key, vector, slot, scratch, receiver_map,
4580 weak_value_or_length, integer_slot, r15, &miss);
4581 __ int3();
4582
4583 __ bind(&try_megamorphic);
4584 __ Cmp(scratch, factory->megamorphic_symbol());
4585 __ j(not_equal, &try_array);
4586 Handle<Code> megamorphic_stub =
4587 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate());
4588 __ jmp(megamorphic_stub, RelocInfo::CODE_TARGET);
4589 __ int3(); // We shouldn't get here.
4590
4591 // Is it a fixed array?
4592 __ bind(&try_array);
4593 __ movp(r15, FieldOperand(scratch, FixedArray::OffsetOfElementAt(0)));
4594 __ JumpIfSmi(r15, &miss);
4595 // Is it an array or a weak cell? The only way to know is to make
4596 // sure that weak_value_or_length is a smi > 0 (because our vector arrays
4597 // have a minimum size of 2).
4598 __ JumpIfNotSmi(weak_value_or_length, &miss);
4599 __ SmiToInteger32(weak_value_or_length, weak_value_or_length);
4600 __ cmpl(weak_value_or_length, Immediate(2));
4601 __ j(less, &miss);
4602 // We have a polymorphic element handler, and we know the length.
4603 __ JumpIfNotSmi(key, &miss);
4604 // We have also prefetched the first weak cell that holds a map in the
4605 // array.
4606 HandlePolymorphic(masm, receiver, key, vector, slot, scratch, receiver_map,
4607 weak_value_or_length, r15, integer_slot, &miss);
4608 __ int3(); // We shouldn't get here.
4609
4610 __ bind(&miss);
4611 KeyedLoadIC::GenerateMiss(masm);
4612
4613 __ bind(&load_smi_map);
4614 __ Move(receiver_map, masm->isolate()->factory()->heap_number_map());
4615 __ jmp(&weak_compare);
4616 }
4617
4618
4352 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 4619 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
4353 EmitLoadTypeFeedbackVector(masm, rbx); 4620 EmitLoadTypeFeedbackVector(masm, rbx);
4354 CallICStub stub(isolate(), state()); 4621 CallICStub stub(isolate(), state());
4355 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4622 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4356 } 4623 }
4357 4624
4358 4625
4359 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { 4626 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) {
4360 EmitLoadTypeFeedbackVector(masm, rbx); 4627 EmitLoadTypeFeedbackVector(masm, rbx);
4361 CallIC_ArrayStub stub(isolate(), state()); 4628 CallIC_ArrayStub stub(isolate(), state());
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
5148 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, 5415 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg,
5149 kStackSpace, nullptr, return_value_operand, NULL); 5416 kStackSpace, nullptr, return_value_operand, NULL);
5150 } 5417 }
5151 5418
5152 5419
5153 #undef __ 5420 #undef __
5154 5421
5155 } } // namespace v8::internal 5422 } } // namespace v8::internal
5156 5423
5157 #endif // V8_TARGET_ARCH_X64 5424 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698