From 9e7af9efc5857b3c7e23a77d257f3dfbea597753 Mon Sep 17 00:00:00 2001 From: Michael Stanton Date: Thu, 25 Jun 2015 10:35:56 +0200 Subject: [PATCH] Vector ICs: Like megamorphic keyed koads, use a dummy vector for stores It's useful for the megamorphic keyed store case to not require a vector and slot as input. Analogous to the load case, we have a dummy one-ic-slot vector to aid. Since the only kind of MISS is for megamorphic cache stub failures, we don't need the real vector. The reason is that megamorphic cache stub failures don't result in any change to the type feedback vector state. BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/1210583002 Cr-Commit-Position: refs/heads/master@{#29280} --- src/heap/heap.cc | 28 +++++++++++++++++++++------- src/heap/heap.h | 1 + src/ic/arm/ic-arm.cc | 18 ++++++++++++++++-- src/ic/arm64/ic-arm64.cc | 18 ++++++++++++++++-- src/ic/ia32/ic-ia32.cc | 18 ++++++++++++++++++ src/ic/mips/ic-mips.cc | 18 ++++++++++++++++-- src/ic/mips64/ic-mips64.cc | 18 ++++++++++++++++-- src/ic/x64/ic-x64.cc | 17 +++++++++++++++-- 8 files changed, 119 insertions(+), 17 deletions(-) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index bad4528ff4..27c24f34b1 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -3353,13 +3353,27 @@ void Heap::CreateInitialObjects() { // Number of queued microtasks stored in Isolate::pending_microtask_count(). set_microtask_queue(empty_fixed_array()); - FeedbackVectorSpec spec(0, Code::KEYED_LOAD_IC); - Handle dummy_vector = - factory->NewTypeFeedbackVector(&spec); - dummy_vector->Set(FeedbackVectorICSlot(0), - *TypeFeedbackVector::MegamorphicSentinel(isolate()), - SKIP_WRITE_BARRIER); - set_keyed_load_dummy_vector(*dummy_vector); + { + FeedbackVectorSpec spec(0, Code::KEYED_LOAD_IC); + Handle dummy_vector = + factory->NewTypeFeedbackVector(&spec); + dummy_vector->Set(FeedbackVectorICSlot(0), + *TypeFeedbackVector::MegamorphicSentinel(isolate()), + SKIP_WRITE_BARRIER); + set_keyed_load_dummy_vector(*dummy_vector); + } + + if (FLAG_vector_stores) { + FeedbackVectorSpec spec(0, Code::KEYED_STORE_IC); + Handle dummy_vector = + factory->NewTypeFeedbackVector(&spec); + dummy_vector->Set(FeedbackVectorICSlot(0), + *TypeFeedbackVector::MegamorphicSentinel(isolate()), + SKIP_WRITE_BARRIER); + set_keyed_store_dummy_vector(*dummy_vector); + } else { + set_keyed_store_dummy_vector(empty_fixed_array()); + } set_detached_contexts(empty_fixed_array()); set_retained_maps(ArrayList::cast(empty_fixed_array())); diff --git a/src/heap/heap.h b/src/heap/heap.h index 3f6d8267b3..a57a46d85e 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -187,6 +187,7 @@ namespace internal { V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad) \ V(FixedArray, microtask_queue, MicrotaskQueue) \ V(FixedArray, keyed_load_dummy_vector, KeyedLoadDummyVector) \ + V(FixedArray, keyed_store_dummy_vector, KeyedStoreDummyVector) \ V(FixedArray, detached_contexts, DetachedContexts) \ V(ArrayList, retained_maps, RetainedMaps) \ V(WeakHashTable, weak_object_to_code_table, WeakObjectToCodeTable) \ diff --git a/src/ic/arm/ic-arm.cc b/src/ic/arm/ic-arm.cc index 3ecdc31a62..5d761dfee9 100644 --- a/src/ic/arm/ic-arm.cc +++ b/src/ic/arm/ic-arm.cc @@ -419,9 +419,9 @@ void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { DCHECK(!AreAliased(vector, slot, r4, r5, r6, r9)); Handle dummy_vector = Handle::cast( masm->isolate()->factory()->keyed_load_dummy_vector()); - int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); __ LoadRoot(vector, Heap::kKeyedLoadDummyVectorRootIndex); - __ mov(slot, Operand(Smi::FromInt(int_slot))); + __ mov(slot, Operand(Smi::FromInt(slot_index))); Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::LOAD_IC)); @@ -665,6 +665,20 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ ldr(r4, FieldMemOperand(key, HeapObject::kMapOffset)); __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(r4, &slow); + + if (FLAG_vector_stores) { + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Register vector = VectorStoreICDescriptor::VectorRegister(); + Register slot = VectorStoreICDescriptor::SlotRegister(); + DCHECK(!AreAliased(vector, slot, r3, r4, r5, r6)); + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ LoadRoot(vector, Heap::kKeyedStoreDummyVectorRootIndex); + __ mov(slot, Operand(Smi::FromInt(slot_index))); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe( diff --git a/src/ic/arm64/ic-arm64.cc b/src/ic/arm64/ic-arm64.cc index e0bf48b260..e8ce317f0d 100644 --- a/src/ic/arm64/ic-arm64.cc +++ b/src/ic/arm64/ic-arm64.cc @@ -397,9 +397,9 @@ static void GenerateKeyedLoadWithNameKey(MacroAssembler* masm, Register key, DCHECK(!AreAliased(vector, slot, scratch1, scratch2, scratch3, scratch4)); Handle dummy_vector = Handle::cast( masm->isolate()->factory()->keyed_load_dummy_vector()); - int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); __ LoadRoot(vector, Heap::kKeyedLoadDummyVectorRootIndex); - __ Mov(slot, Operand(Smi::FromInt(int_slot))); + __ Mov(slot, Operand(Smi::FromInt(slot_index))); Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::LOAD_IC)); @@ -663,6 +663,20 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ Ldr(x10, FieldMemOperand(key, HeapObject::kMapOffset)); __ Ldrb(x10, FieldMemOperand(x10, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(x10, &slow); + + if (FLAG_vector_stores) { + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Register vector = VectorStoreICDescriptor::VectorRegister(); + Register slot = VectorStoreICDescriptor::SlotRegister(); + DCHECK(!AreAliased(vector, slot, x3, x4, x5, x6)); + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ LoadRoot(vector, Heap::kKeyedStoreDummyVectorRootIndex); + __ Mov(slot, Operand(Smi::FromInt(slot_index))); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe( diff --git a/src/ic/ia32/ic-ia32.cc b/src/ic/ia32/ic-ia32.cc index 6d54b074d2..4d6a00e050 100644 --- a/src/ic/ia32/ic-ia32.cc +++ b/src/ic/ia32/ic-ia32.cc @@ -553,10 +553,28 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ mov(ebx, FieldOperand(key, HeapObject::kMapOffset)); __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(ebx, &slow); + + + if (FLAG_vector_stores) { + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ push(Immediate(Smi::FromInt(slot))); + __ push(Immediate(dummy_vector)); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe( masm, Code::STORE_IC, flags, false, receiver, key, ebx, no_reg); + + if (FLAG_vector_stores) { + __ pop(VectorStoreICDescriptor::VectorRegister()); + __ pop(VectorStoreICDescriptor::SlotRegister()); + } + // Cache miss. __ jmp(&miss); diff --git a/src/ic/mips/ic-mips.cc b/src/ic/mips/ic-mips.cc index 7dbaad788a..a888e0b43d 100644 --- a/src/ic/mips/ic-mips.cc +++ b/src/ic/mips/ic-mips.cc @@ -426,9 +426,9 @@ void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { DCHECK(!AreAliased(vector, slot, t0, t1, t2, t5)); Handle dummy_vector = Handle::cast( masm->isolate()->factory()->keyed_load_dummy_vector()); - int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); __ LoadRoot(vector, Heap::kKeyedLoadDummyVectorRootIndex); - __ li(slot, Operand(Smi::FromInt(int_slot))); + __ li(slot, Operand(Smi::FromInt(slot_index))); Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::LOAD_IC)); @@ -662,6 +662,20 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ lw(t0, FieldMemOperand(key, HeapObject::kMapOffset)); __ lb(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(t0, &slow); + + if (FLAG_vector_stores) { + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Register vector = VectorStoreICDescriptor::VectorRegister(); + Register slot = VectorStoreICDescriptor::SlotRegister(); + DCHECK(!AreAliased(vector, slot, a3, t0, t1, t2)); + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ LoadRoot(vector, Heap::kKeyedStoreDummyVectorRootIndex); + __ li(slot, Operand(Smi::FromInt(slot_index))); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe( diff --git a/src/ic/mips64/ic-mips64.cc b/src/ic/mips64/ic-mips64.cc index 770fa77808..92bb970668 100644 --- a/src/ic/mips64/ic-mips64.cc +++ b/src/ic/mips64/ic-mips64.cc @@ -424,9 +424,9 @@ void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { DCHECK(!AreAliased(vector, slot, a4, a5, a6, t1)); Handle dummy_vector = Handle::cast( masm->isolate()->factory()->keyed_load_dummy_vector()); - int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); __ LoadRoot(vector, Heap::kKeyedLoadDummyVectorRootIndex); - __ li(slot, Operand(Smi::FromInt(int_slot))); + __ li(slot, Operand(Smi::FromInt(slot_index))); Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::LOAD_IC)); @@ -664,6 +664,20 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ ld(a4, FieldMemOperand(key, HeapObject::kMapOffset)); __ lb(a4, FieldMemOperand(a4, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(a4, &slow); + + if (FLAG_vector_stores) { + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Register vector = LoadWithVectorDescriptor::VectorRegister(); + Register slot = LoadWithVectorDescriptor::SlotRegister(); + DCHECK(!AreAliased(vector, slot, a3, a4, a5, a6)); + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ LoadRoot(vector, Heap::kKeyedStoreDummyVectorRootIndex); + __ li(slot, Operand(Smi::FromInt(slot_index))); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe( diff --git a/src/ic/x64/ic-x64.cc b/src/ic/x64/ic-x64.cc index 40aa231fd3..129f089a12 100644 --- a/src/ic/x64/ic-x64.cc +++ b/src/ic/x64/ic-x64.cc @@ -340,9 +340,9 @@ void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { DCHECK(!AreAliased(megamorphic_scratch, vector, slot)); Handle dummy_vector = Handle::cast( masm->isolate()->factory()->keyed_load_dummy_vector()); - int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); __ Move(vector, dummy_vector); - __ Move(slot, Smi::FromInt(int_slot)); + __ Move(slot, Smi::FromInt(slot_index)); Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::LOAD_IC)); @@ -556,6 +556,19 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, __ movp(r9, FieldOperand(key, HeapObject::kMapOffset)); __ movzxbp(r9, FieldOperand(r9, Map::kInstanceTypeOffset)); __ JumpIfNotUniqueNameInstanceType(r9, &slow_with_tagged_index); + + if (FLAG_vector_stores) { + Register vector = VectorStoreICDescriptor::VectorRegister(); + Register slot = VectorStoreICDescriptor::SlotRegister(); + // The handlers in the stub cache expect a vector and slot. Since we won't + // change the IC from any downstream misses, a dummy vector can be used. + Handle dummy_vector = Handle::cast( + masm->isolate()->factory()->keyed_store_dummy_vector()); + int slot_index = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); + __ Move(vector, dummy_vector); + __ Move(slot, Smi::FromInt(slot_index)); + } + Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( Code::ComputeHandlerFlags(Code::STORE_IC)); masm->isolate()->stub_cache()->GenerateProbe(