From: dcarney Date: Wed, 25 Feb 2015 19:32:36 +0000 (-0800) Subject: emit premonomorphic ics for keyed loads/stores in optimized code X-Git-Tag: upstream/4.7.83~4178 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1e2aa524cbba83add14d976bf6194d5f02df9e8;p=platform%2Fupstream%2Fv8.git emit premonomorphic ics for keyed loads/stores in optimized code R=verwaest@chromium.org BUG= Review URL: https://codereview.chromium.org/945313003 Cr-Commit-Position: refs/heads/master@{#26862} --- diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index ef1abbb..201120a 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3452,7 +3452,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); } @@ -4536,8 +4538,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); } diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index 2f91698..5926013 100644 --- a/src/arm64/lithium-codegen-arm64.cc +++ b/src/arm64/lithium-codegen-arm64.cc @@ -3697,7 +3697,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); DCHECK(ToRegister(instr->result()).Is(x0)); @@ -5386,8 +5388,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/src/code-factory.cc b/src/code-factory.cc index 9693d24..6fa2e56 100644 --- a/src/code-factory.cc +++ b/src/code-factory.cc @@ -40,12 +40,14 @@ Callable CodeFactory::KeyedLoadIC(Isolate* isolate) { // static -Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) { +Callable CodeFactory::KeyedLoadICInOptimizedCode( + Isolate* isolate, InlineCacheState initialization_state) { + auto code = KeyedLoadIC::initialize_stub_in_optimized_code( + isolate, initialization_state); if (FLAG_vector_ics) { - return Callable(KeyedLoadIC::initialize_stub_in_optimized_code(isolate), - VectorLoadICDescriptor(isolate)); + return Callable(code, VectorLoadICDescriptor(isolate)); } - return CodeFactory::KeyedLoadIC(isolate); + return Callable(code, LoadDescriptor(isolate)); } @@ -77,10 +79,19 @@ Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) { // static Callable CodeFactory::KeyedStoreIC(Isolate* isolate, LanguageMode language_mode) { - Handle ic = is_strict(language_mode) - ? isolate->builtins()->KeyedStoreIC_Initialize_Strict() - : isolate->builtins()->KeyedStoreIC_Initialize(); - return Callable(ic, StoreDescriptor(isolate)); + return Callable( + KeyedStoreIC::initialize_stub(isolate, language_mode, UNINITIALIZED), + StoreDescriptor(isolate)); +} + + +// static +Callable CodeFactory::KeyedStoreICInOptimizedCode( + Isolate* isolate, LanguageMode language_mode, + InlineCacheState initialization_state) { + return Callable(KeyedStoreIC::initialize_stub(isolate, language_mode, + initialization_state), + StoreDescriptor(isolate)); } diff --git a/src/code-factory.h b/src/code-factory.h index 2263662..e1f2efa 100644 --- a/src/code-factory.h +++ b/src/code-factory.h @@ -36,13 +36,17 @@ class CodeFactory FINAL { static Callable LoadICInOptimizedCode(Isolate* isolate, ContextualMode mode, InlineCacheState initialization_state); static Callable KeyedLoadIC(Isolate* isolate); - static Callable KeyedLoadICInOptimizedCode(Isolate* isolate); + static Callable KeyedLoadICInOptimizedCode( + Isolate* isolate, InlineCacheState initialization_state); static Callable CallIC(Isolate* isolate, int argc, CallICState::CallType call_type); static Callable CallICInOptimizedCode(Isolate* isolate, int argc, CallICState::CallType call_type); static Callable StoreIC(Isolate* isolate, LanguageMode mode); static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode); + static Callable KeyedStoreICInOptimizedCode( + Isolate* isolate, LanguageMode mode, + InlineCacheState initialization_state); static Callable CompareIC(Isolate* isolate, Token::Value op); diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 770edf0..b585016 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -291,7 +291,8 @@ void JSGenericLowering::LowerJSToObject(Node* node) { void JSGenericLowering::LowerJSLoadProperty(Node* node) { const LoadPropertyParameters& p = LoadPropertyParametersOf(node->op()); - Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); + Callable callable = + CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED); if (FLAG_vector_ics) { node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); node->InsertInput(zone(), 3, @@ -317,7 +318,8 @@ void JSGenericLowering::LowerJSLoadNamed(Node* node) { void JSGenericLowering::LowerJSStoreProperty(Node* node) { LanguageMode language_mode = OpParameter(node); - Callable callable = CodeFactory::KeyedStoreIC(isolate(), language_mode); + Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), language_mode, UNINITIALIZED); ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 6468a2c..a9eb57d 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -6794,11 +6794,14 @@ class HLoadKeyed FINAL class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> { public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HLoadKeyedGeneric, HValue*, - HValue*); + DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadKeyedGeneric, HValue*, + HValue*, InlineCacheState); HValue* object() const { return OperandAt(0); } HValue* key() const { return OperandAt(1); } HValue* context() const { return OperandAt(2); } + InlineCacheState initialization_state() const { + return initialization_state_; + } FeedbackVectorICSlot slot() const { return slot_; } Handle feedback_vector() const { return feedback_vector_; @@ -6823,8 +6826,10 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> { DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) private: - HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) - : slot_(FeedbackVectorICSlot::Invalid()) { + HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key, + InlineCacheState initialization_state) + : slot_(FeedbackVectorICSlot::Invalid()), + initialization_state_(initialization_state) { set_representation(Representation::Tagged()); SetOperandAt(0, obj); SetOperandAt(1, key); @@ -6834,6 +6839,7 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> { Handle feedback_vector_; FeedbackVectorICSlot slot_; + InlineCacheState initialization_state_; }; @@ -7233,14 +7239,18 @@ class HStoreKeyed FINAL class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, - HValue*, HValue*, LanguageMode); + DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HStoreKeyedGeneric, HValue*, + HValue*, HValue*, LanguageMode, + InlineCacheState); HValue* object() const { return OperandAt(0); } HValue* key() const { return OperandAt(1); } HValue* value() const { return OperandAt(2); } HValue* context() const { return OperandAt(3); } LanguageMode language_mode() const { return language_mode_; } + InlineCacheState initialization_state() const { + return initialization_state_; + } Representation RequiredInputRepresentation(int index) OVERRIDE { // tagged[tagged] = tagged @@ -7253,8 +7263,10 @@ class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { private: HStoreKeyedGeneric(HValue* context, HValue* object, HValue* key, - HValue* value, LanguageMode language_mode) - : language_mode_(language_mode) { + HValue* value, LanguageMode language_mode, + InlineCacheState initialization_state) + : language_mode_(language_mode), + initialization_state_(initialization_state) { SetOperandAt(0, object); SetOperandAt(1, key); SetOperandAt(2, value); @@ -7263,6 +7275,7 @@ class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { } LanguageMode language_mode_; + InlineCacheState initialization_state_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 9d5fe3c..e37a1ce 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6861,7 +6861,8 @@ HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( HValue* key, HValue* value) { if (access_type == LOAD) { - HLoadKeyedGeneric* result = New(object, key); + HLoadKeyedGeneric* result = + New(object, key, PREMONOMORPHIC); if (FLAG_vector_ics) { Handle current_shared = function_state()->compilation_info()->shared_info(); @@ -6872,8 +6873,8 @@ HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( } return result; } else { - return New(object, key, value, - function_language_mode()); + return New(object, key, value, function_language_mode(), + PREMONOMORPHIC); } } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index bffd7cf..53888c0 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3244,7 +3244,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4355,8 +4357,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/src/ic/ic.cc b/src/ic/ic.cc index ef8e069..0d40ea6 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -944,9 +944,6 @@ Handle LoadIC::initialize_stub(Isolate* isolate, Handle LoadIC::initialize_stub_in_optimized_code( Isolate* isolate, ExtraICState extra_state, State initialization_state) { - DCHECK(initialization_state == UNINITIALIZED || - initialization_state == PREMONOMORPHIC || - initialization_state == MEGAMORPHIC); if (FLAG_vector_ics) { return VectorLoadStub(isolate, LoadICState(extra_state)).GetCode(); } @@ -964,11 +961,45 @@ Handle KeyedLoadIC::initialize_stub(Isolate* isolate) { } -Handle KeyedLoadIC::initialize_stub_in_optimized_code(Isolate* isolate) { +Handle KeyedLoadIC::initialize_stub_in_optimized_code( + Isolate* isolate, State initialization_state) { if (FLAG_vector_ics) { return VectorKeyedLoadStub(isolate).GetCode(); } - return initialize_stub(isolate); + switch (initialization_state) { + case UNINITIALIZED: + return isolate->builtins()->KeyedLoadIC_Initialize(); + case PREMONOMORPHIC: + return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); + case MEGAMORPHIC: + return isolate->builtins()->KeyedLoadIC_Megamorphic(); + default: + UNREACHABLE(); + } + return Handle(); +} + + +Handle KeyedStoreIC::initialize_stub(Isolate* isolate, + LanguageMode language_mode, + State initialization_state) { + switch (initialization_state) { + case UNINITIALIZED: + return is_strict(language_mode) + ? isolate->builtins()->KeyedStoreIC_Initialize_Strict() + : isolate->builtins()->KeyedStoreIC_Initialize(); + case PREMONOMORPHIC: + return is_strict(language_mode) + ? isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict() + : isolate->builtins()->KeyedStoreIC_PreMonomorphic(); + case MEGAMORPHIC: + return is_strict(language_mode) + ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() + : isolate->builtins()->KeyedStoreIC_Megamorphic(); + default: + UNREACHABLE(); + } + return Handle(); } diff --git a/src/ic/ic.h b/src/ic/ic.h index 773e9d0..3025f72 100644 --- a/src/ic/ic.h +++ b/src/ic/ic.h @@ -481,7 +481,8 @@ class KeyedLoadIC : public LoadIC { (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); static Handle initialize_stub(Isolate* isolate); - static Handle initialize_stub_in_optimized_code(Isolate* isolate); + static Handle initialize_stub_in_optimized_code( + Isolate* isolate, State initialization_state); static Handle ChooseMegamorphicStub(Isolate* isolate); static Handle pre_monomorphic_stub(Isolate* isolate); @@ -632,6 +633,10 @@ class KeyedStoreIC : public StoreIC { LanguageMode language_mode); static void GenerateSloppyArguments(MacroAssembler* masm); + static Handle initialize_stub(Isolate* isolate, + LanguageMode language_mode, + State initialization_state); + protected: virtual Handle pre_monomorphic_stub() const { return pre_monomorphic_stub(isolate(), language_mode()); diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 07e48db..dbf5416 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3392,7 +3392,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4517,8 +4519,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index 74dfc0f..fe907b6 100644 --- a/src/mips64/lithium-codegen-mips64.cc +++ b/src/mips64/lithium-codegen-mips64.cc @@ -3407,7 +3407,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4570,8 +4572,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 0345ca4..33fc465 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -3313,7 +3313,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4534,8 +4536,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index 3421dca..f6f5958 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -3508,7 +3508,9 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = CodeFactory::KeyedLoadICInOptimizedCode(isolate()).code(); + Handle ic = + CodeFactory::KeyedLoadICInOptimizedCode( + isolate(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4805,8 +4807,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = - CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code(); + Handle ic = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), instr->language_mode(), + instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); }