From 528aa288bfa494f46356c0beb6ec9cb37daf8675 Mon Sep 17 00:00:00 2001 From: "chunyang.dai" Date: Tue, 19 May 2015 02:56:41 -0700 Subject: [PATCH] X87: Now that vector ics are established for load, keyed load and call ics, let's remove dead code behind the flag. port 323ced9e272e234d19db13d407b5bb9da266681d (r28422). original commit message: BUG= Review URL: https://codereview.chromium.org/1142713007 Cr-Commit-Position: refs/heads/master@{#28467} --- src/ic/x87/handler-compiler-x87.cc | 7 ++-- src/ic/x87/ic-x87.cc | 59 ++++++++++++----------------- src/x87/code-stubs-x87.cc | 30 ++++++--------- src/x87/debug-x87.cc | 6 +-- src/x87/full-codegen-x87.cc | 76 ++++++++++++-------------------------- src/x87/lithium-codegen-x87.cc | 30 +-------------- src/x87/lithium-x87.cc | 14 ------- src/x87/lithium-x87.h | 21 ----------- 8 files changed, 66 insertions(+), 177 deletions(-) diff --git a/src/ic/x87/handler-compiler-x87.cc b/src/ic/x87/handler-compiler-x87.cc index e9c8e4f..32ca191 100644 --- a/src/ic/x87/handler-compiler-x87.cc +++ b/src/ic/x87/handler-compiler-x87.cc @@ -130,10 +130,9 @@ void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype( void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype( MacroAssembler* masm, Register receiver, Register scratch1, Register scratch2, Label* miss_label) { - DCHECK(!FLAG_vector_ics); - __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); - __ mov(eax, scratch1); - __ ret(0); + // TODO(mvstanton): This isn't used on ia32. Move all the other + // platform implementations into a code stub so this method can be removed. + UNREACHABLE(); } diff --git a/src/ic/x87/ic-x87.cc b/src/ic/x87/ic-x87.cc index 92005bd..13173fc 100644 --- a/src/ic/x87/ic-x87.cc +++ b/src/ic/x87/ic-x87.cc @@ -399,26 +399,21 @@ void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { Immediate(isolate->factory()->hash_table_map())); __ j(equal, &probe_dictionary); - if (FLAG_vector_ics) { - // When vector ics are in use, 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( - isolate->factory()->keyed_load_dummy_vector()); - int slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); - __ push(Immediate(Smi::FromInt(slot))); - __ push(Immediate(dummy_vector)); - } + // 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( + isolate->factory()->keyed_load_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::LOAD_IC)); masm->isolate()->stub_cache()->GenerateProbe(masm, Code::KEYED_LOAD_IC, flags, false, receiver, key, ebx, edi); - if (FLAG_vector_ics) { - __ pop(VectorLoadICDescriptor::VectorRegister()); - __ pop(VectorLoadICDescriptor::SlotRegister()); - } + __ pop(VectorLoadICDescriptor::VectorRegister()); + __ pop(VectorLoadICDescriptor::SlotRegister()); // Cache miss. GenerateMiss(masm); @@ -733,26 +728,18 @@ void LoadIC::GenerateNormal(MacroAssembler* masm) { static void LoadIC_PushArgs(MacroAssembler* masm) { Register receiver = LoadDescriptor::ReceiverRegister(); Register name = LoadDescriptor::NameRegister(); - if (FLAG_vector_ics) { - Register slot = VectorLoadICDescriptor::SlotRegister(); - Register vector = VectorLoadICDescriptor::VectorRegister(); - DCHECK(!edi.is(receiver) && !edi.is(name) && !edi.is(slot) && - !edi.is(vector)); - - __ pop(edi); - __ push(receiver); - __ push(name); - __ push(slot); - __ push(vector); - __ push(edi); - } else { - DCHECK(!ebx.is(receiver) && !ebx.is(name)); - - __ pop(ebx); - __ push(receiver); - __ push(name); - __ push(ebx); - } + + Register slot = VectorLoadICDescriptor::SlotRegister(); + Register vector = VectorLoadICDescriptor::VectorRegister(); + DCHECK(!edi.is(receiver) && !edi.is(name) && !edi.is(slot) && + !edi.is(vector)); + + __ pop(edi); + __ push(receiver); + __ push(name); + __ push(slot); + __ push(vector); + __ push(edi); } @@ -764,7 +751,7 @@ void LoadIC::GenerateMiss(MacroAssembler* masm) { // Perform tail call to the entry. ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate()); - int arg_count = FLAG_vector_ics ? 4 : 2; + int arg_count = 4; __ TailCallExternalReference(ref, arg_count, 1); } @@ -794,7 +781,7 @@ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { // Perform tail call to the entry. ExternalReference ref = ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate()); - int arg_count = FLAG_vector_ics ? 4 : 2; + int arg_count = 4; __ TailCallExternalReference(ref, arg_count, 1); } diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 971dd4a..b12c651 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -333,20 +333,15 @@ void MathPowStub::Generate(MacroAssembler* masm) { void FunctionPrototypeStub::Generate(MacroAssembler* masm) { Label miss; Register receiver = LoadDescriptor::ReceiverRegister(); + // With careful management, we won't have to save slot and vector on + // the stack. Simply handle the possibly missing case first. + // TODO(mvstanton): this code can be more efficient. + __ cmp(FieldOperand(receiver, JSFunction::kPrototypeOrInitialMapOffset), + Immediate(isolate()->factory()->the_hole_value())); + __ j(equal, &miss); + __ TryGetFunctionPrototype(receiver, eax, ebx, &miss); + __ ret(0); - if (FLAG_vector_ics) { - // With careful management, we won't have to save slot and vector on - // the stack. Simply handle the possibly missing case first. - // TODO(mvstanton): this code can be more efficient. - __ cmp(FieldOperand(receiver, JSFunction::kPrototypeOrInitialMapOffset), - Immediate(isolate()->factory()->the_hole_value())); - __ j(equal, &miss); - __ TryGetFunctionPrototype(receiver, eax, ebx, &miss); - __ ret(0); - } else { - NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, eax, - ebx, &miss); - } __ bind(&miss); PropertyAccessCompiler::TailCallBuiltin( masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); @@ -393,9 +388,8 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) { DCHECK(!scratch.is(receiver) && !scratch.is(index)); Register result = eax; DCHECK(!result.is(scratch)); - DCHECK(!FLAG_vector_ics || - (!scratch.is(VectorLoadICDescriptor::VectorRegister()) && - result.is(VectorLoadICDescriptor::SlotRegister()))); + DCHECK(!scratch.is(VectorLoadICDescriptor::VectorRegister()) && + result.is(VectorLoadICDescriptor::SlotRegister())); // StringCharAtGenerator doesn't use the result register until it's passed // the different miss possibilities. If it did, we would have a conflict @@ -2664,7 +2658,7 @@ void StringCharCodeAtGenerator::GenerateSlow( index_not_number_, DONT_DO_SMI_CHECK); call_helper.BeforeCall(masm); - if (FLAG_vector_ics && embed_mode == PART_OF_IC_HANDLER) { + if (embed_mode == PART_OF_IC_HANDLER) { __ push(VectorLoadICDescriptor::VectorRegister()); __ push(VectorLoadICDescriptor::SlotRegister()); } @@ -2683,7 +2677,7 @@ void StringCharCodeAtGenerator::GenerateSlow( __ mov(index_, eax); } __ pop(object_); - if (FLAG_vector_ics && embed_mode == PART_OF_IC_HANDLER) { + if (embed_mode == PART_OF_IC_HANDLER) { __ pop(VectorLoadICDescriptor::SlotRegister()); __ pop(VectorLoadICDescriptor::VectorRegister()); } diff --git a/src/x87/debug-x87.cc b/src/x87/debug-x87.cc index 0bbee14..02902ee 100644 --- a/src/x87/debug-x87.cc +++ b/src/x87/debug-x87.cc @@ -182,10 +182,8 @@ void DebugCodegen::GenerateLoadICDebugBreak(MacroAssembler* masm) { // Register state for IC load call (from ic-x87.cc). Register receiver = LoadDescriptor::ReceiverRegister(); Register name = LoadDescriptor::NameRegister(); - RegList regs = receiver.bit() | name.bit(); - if (FLAG_vector_ics) { - regs |= VectorLoadICTrampolineDescriptor::SlotRegister().bit(); - } + RegList regs = receiver.bit() | name.bit() | + VectorLoadICTrampolineDescriptor::SlotRegister().bit(); Generate_DebugBreakCallHelper(masm, regs, 0, false); } diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 5c51fe3..703ec75 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -1252,13 +1252,9 @@ void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { Handle home_object_symbol(isolate()->heap()->home_object_symbol()); __ mov(LoadDescriptor::NameRegister(), home_object_symbol); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); - CallLoadIC(NOT_CONTEXTUAL); - } else { - CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); + CallLoadIC(NOT_CONTEXTUAL); __ cmp(eax, isolate()->factory()->undefined_value()); Label done; @@ -1333,10 +1329,8 @@ void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, // load IC call. __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); ContextualMode mode = (typeof_state == INSIDE_TYPEOF) ? NOT_CONTEXTUAL @@ -1421,10 +1415,8 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { Comment cmnt(masm_, "[ Global variable"); __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); __ mov(LoadDescriptor::NameRegister(), var->name()); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); CallGlobalLoadIC(var->name()); context()->Plug(eax); break; @@ -2116,10 +2108,8 @@ void FullCodeGenerator::VisitYield(Yield* expr) { // result = receiver[f](arg); __ bind(&l_call); __ mov(load_receiver, Operand(esp, kPointerSize)); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); Handle ic = CodeFactory::KeyedLoadIC(isolate()).code(); CallIC(ic, TypeFeedbackId::None()); __ mov(edi, eax); @@ -2136,10 +2126,8 @@ void FullCodeGenerator::VisitYield(Yield* expr) { __ Move(load_receiver, eax); // result __ mov(load_name, isolate()->factory()->done_string()); // "done" - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); CallLoadIC(NOT_CONTEXTUAL); // result.done in eax Handle bool_ic = ToBooleanStub::GetUninitialized(isolate()); CallIC(bool_ic); @@ -2150,10 +2138,8 @@ void FullCodeGenerator::VisitYield(Yield* expr) { __ pop(load_receiver); // result __ mov(load_name, isolate()->factory()->value_string()); // "value" - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); CallLoadIC(NOT_CONTEXTUAL); // result.value in eax context()->DropAndPlug(2, eax); // drop iter and g break; @@ -2291,13 +2277,9 @@ void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { DCHECK(!prop->IsSuperAccess()); __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); - CallLoadIC(NOT_CONTEXTUAL); - } else { - CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); + CallLoadIC(NOT_CONTEXTUAL); } @@ -2316,13 +2298,9 @@ void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { SetSourcePosition(prop->position()); Handle ic = CodeFactory::KeyedLoadIC(isolate()).code(); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); - CallIC(ic); - } else { - CallIC(ic, prop->PropertyFeedbackId()); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); + CallIC(ic); } @@ -4543,13 +4521,9 @@ void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { // Load the function from the receiver. __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); - CallLoadIC(NOT_CONTEXTUAL); - } else { - CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); + CallLoadIC(NOT_CONTEXTUAL); } @@ -4988,10 +4962,8 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { Comment cmnt(masm_, "[ Global variable"); __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); - if (FLAG_vector_ics) { - __ mov(VectorLoadICDescriptor::SlotRegister(), - Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); - } + __ mov(VectorLoadICDescriptor::SlotRegister(), + Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); // Use a regular load, not a contextual load, to avoid a reference // error. CallLoadIC(NOT_CONTEXTUAL); diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index cee37cf..ca42917 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -3144,7 +3144,6 @@ void LCodeGen::DoReturn(LReturn* instr) { template void LCodeGen::EmitVectorLoadICRegisters(T* instr) { - DCHECK(FLAG_vector_ics); Register vector_register = ToRegister(instr->temp_vector()); Register slot_register = VectorLoadICDescriptor::SlotRegister(); DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); @@ -3167,9 +3166,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->result()).is(eax)); __ mov(LoadDescriptor::NameRegister(), instr->name()); - if (FLAG_vector_ics) { - EmitVectorLoadICRegisters(instr); - } + EmitVectorLoadICRegisters(instr); ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; Handle ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, PREMONOMORPHIC).code(); @@ -3280,9 +3277,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { DCHECK(ToRegister(instr->result()).is(eax)); __ mov(LoadDescriptor::NameRegister(), instr->name()); - if (FLAG_vector_ics) { - EmitVectorLoadICRegisters(instr); - } + EmitVectorLoadICRegisters(instr); Handle ic = CodeFactory::LoadICInOptimizedCode( isolate(), NOT_CONTEXTUAL, instr->hydrogen()->initialization_state()).code(); @@ -3751,27 +3746,6 @@ void LCodeGen::CallKnownFunction(Handle function, } -void LCodeGen::DoTailCallThroughMegamorphicCache( - LTailCallThroughMegamorphicCache* instr) { - Register receiver = ToRegister(instr->receiver()); - Register name = ToRegister(instr->name()); - DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); - DCHECK(name.is(LoadDescriptor::NameRegister())); - Register scratch = ebx; - Register extra = edi; - DCHECK(!scratch.is(receiver) && !scratch.is(name)); - DCHECK(!extra.is(receiver) && !extra.is(name)); - - // The probe will tail call to a handler if found. - // If --vector-ics is on, then it knows to pop the two args first. - isolate()->stub_cache()->GenerateProbe(masm(), Code::LOAD_IC, - instr->hydrogen()->flags(), false, - receiver, name, scratch, extra); - - LoadIC::GenerateMiss(masm()); -} - - void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { DCHECK(ToRegister(instr->result()).is(eax)); diff --git a/src/x87/lithium-x87.cc b/src/x87/lithium-x87.cc index 82d746f..233d12c 100644 --- a/src/x87/lithium-x87.cc +++ b/src/x87/lithium-x87.cc @@ -1164,20 +1164,6 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( } -LInstruction* LChunkBuilder::DoTailCallThroughMegamorphicCache( - HTailCallThroughMegamorphicCache* instr) { - LOperand* context = UseFixed(instr->context(), esi); - LOperand* receiver_register = - UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister()); - LOperand* name_register = - UseFixed(instr->name(), LoadDescriptor::NameRegister()); - - // Not marked as call. It can't deoptimize, and it never returns. - return new (zone()) LTailCallThroughMegamorphicCache( - context, receiver_register, name_register); -} - - LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { LOperand* context = UseFixed(instr->context(), esi); LOperand* function = UseFixed(instr->function(), edi); diff --git a/src/x87/lithium-x87.h b/src/x87/lithium-x87.h index e1b5c48..cc4620d 100644 --- a/src/x87/lithium-x87.h +++ b/src/x87/lithium-x87.h @@ -156,7 +156,6 @@ class LCodeGen; V(StringCompareAndBranch) \ V(SubI) \ V(TaggedToI) \ - V(TailCallThroughMegamorphicCache) \ V(ThisFunction) \ V(ToFastProperties) \ V(TransitionElementsKind) \ @@ -486,26 +485,6 @@ class LCallStub final : public LTemplateInstruction<1, 1, 0> { }; -class LTailCallThroughMegamorphicCache final - : public LTemplateInstruction<0, 3, 0> { - public: - LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver, - LOperand* name) { - inputs_[0] = context; - inputs_[1] = receiver; - inputs_[2] = name; - } - - LOperand* context() { return inputs_[0]; } - LOperand* receiver() { return inputs_[1]; } - LOperand* name() { return inputs_[2]; } - - DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache, - "tail-call-through-megamorphic-cache") - DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache) -}; - - class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> { public: bool HasInterestingComment(LCodeGen* gen) const override { return false; } -- 2.7.4