From 3cfef1e09efa6085e90e1390c2d0eae24627dc03 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Thu, 28 Aug 2014 07:02:53 +0000 Subject: [PATCH] Sub-minor-key-ify four HydrogenCodeStubs. - FastNewContextStub - FastCloneShallowArrayStub - ToBooleanStub - ElementsTransitionAndStoreStub. R=mvstanton@chromium.org Review URL: https://codereview.chromium.org/513653003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23474 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/code-stubs-hydrogen.cc | 4 +- src/code-stubs.cc | 10 ++-- src/code-stubs.h | 117 +++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 69 deletions(-) diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index ce645da1ae..859310db4a 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -1063,7 +1063,7 @@ HValue* CodeStubGraphBuilder::BuildCodeInitializedStub() { HValue* true_value = NULL; HValue* false_value = NULL; - switch (stub->GetMode()) { + switch (stub->mode()) { case ToBooleanStub::RESULT_AS_SMI: true_value = graph()->GetConstant1(); false_value = graph()->GetConstant0(); @@ -1079,7 +1079,7 @@ HValue* CodeStubGraphBuilder::BuildCodeInitializedStub() { } IfBuilder if_true(this); - if_true.If(GetParameter(0), stub->GetTypes()); + if_true.If(GetParameter(0), stub->types()); if_true.Then(); if_true.Return(true_value); if_true.Else(); diff --git a/src/code-stubs.cc b/src/code-stubs.cc index e6209f5ca7..862997941d 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -810,15 +810,17 @@ OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT bool ToBooleanStub::UpdateStatus(Handle object) { - Types old_types(types_); - bool to_boolean_value = types_.UpdateStatus(object); - TraceTransition(old_types, types_); + Types new_types = types(); + Types old_types = new_types; + bool to_boolean_value = new_types.UpdateStatus(object); + TraceTransition(old_types, new_types); + set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToByte())); return to_boolean_value; } void ToBooleanStub::PrintState(OStream& os) const { // NOLINT - os << types_; + os << types(); } diff --git a/src/code-stubs.h b/src/code-stubs.h index 45b64d226d..a3f0bf7aa2 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -644,9 +644,9 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub { public: static const int kMaximumSlots = 64; - FastNewContextStub(Isolate* isolate, int slots) - : HydrogenCodeStub(isolate), slots_(slots) { - DCHECK(slots_ > 0 && slots_ <= kMaximumSlots); + FastNewContextStub(Isolate* isolate, int slots) : HydrogenCodeStub(isolate) { + DCHECK(slots > 0 && slots <= kMaximumSlots); + set_sub_minor_key(SlotsBits::encode(slots)); } virtual Handle GenerateCode() V8_OVERRIDE; @@ -656,16 +656,17 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub { static void InstallDescriptors(Isolate* isolate); - int slots() const { return slots_; } - - virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; } - virtual int NotMissMinorKey() const V8_OVERRIDE { return slots_; } + int slots() const { return SlotsBits::decode(sub_minor_key()); } // Parameters accessed via CodeStubGraphBuilder::GetParameter() static const int kFunction = 0; private: - int slots_; + virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; } + + class SlotsBits : public BitField {}; + + DISALLOW_COPY_AND_ASSIGN(FastNewContextStub); }; @@ -673,11 +674,12 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub { public: FastCloneShallowArrayStub(Isolate* isolate, AllocationSiteMode allocation_site_mode) - : HydrogenCodeStub(isolate), - allocation_site_mode_(allocation_site_mode) {} + : HydrogenCodeStub(isolate) { + set_sub_minor_key(AllocationSiteModeBits::encode(allocation_site_mode)); + } AllocationSiteMode allocation_site_mode() const { - return allocation_site_mode_; + return AllocationSiteModeBits::decode(sub_minor_key()); } virtual Handle GenerateCode(); @@ -688,14 +690,11 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub { static void InstallDescriptors(Isolate* isolate); private: - AllocationSiteMode allocation_site_mode_; + virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; } class AllocationSiteModeBits: public BitField {}; - // Ensure data fits within available bits. - virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; } - int NotMissMinorKey() const { - return AllocationSiteModeBits::encode(allocation_site_mode_); - } + + DISALLOW_COPY_AND_ASSIGN(FastCloneShallowArrayStub); }; @@ -2498,15 +2497,20 @@ class ToBooleanStub: public HydrogenCodeStub { }; ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types()) - : HydrogenCodeStub(isolate), types_(types), mode_(mode) {} + : HydrogenCodeStub(isolate) { + set_sub_minor_key(TypesBits::encode(types.ToByte()) | + ResultModeBits::encode(mode)); + } + ToBooleanStub(Isolate* isolate, ExtraICState state) - : HydrogenCodeStub(isolate), - types_(static_cast(state)), - mode_(RESULT_AS_SMI) {} + : HydrogenCodeStub(isolate) { + set_sub_minor_key(TypesBits::encode(static_cast(state)) | + ResultModeBits::encode(RESULT_AS_SMI)); + } bool UpdateStatus(Handle object); - Types GetTypes() { return types_; } - ResultMode GetMode() { return mode_; } + Types types() const { return Types(TypesBits::decode(sub_minor_key())); } + ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); } virtual Handle GenerateCode() V8_OVERRIDE; virtual void InitializeInterfaceDescriptor( @@ -2527,10 +2531,10 @@ class ToBooleanStub: public HydrogenCodeStub { return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); } - virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); } + virtual ExtraICState GetExtraICState() const { return types().ToIntegral(); } virtual InlineCacheState GetICState() const { - if (types_.IsEmpty()) { + if (types().IsEmpty()) { return ::v8::internal::UNINITIALIZED; } else { return MONOMORPHIC; @@ -2538,19 +2542,17 @@ class ToBooleanStub: public HydrogenCodeStub { } private: + virtual Major MajorKey() const V8_OVERRIDE { return ToBoolean; } + + ToBooleanStub(Isolate* isolate, InitializationState init_state) + : HydrogenCodeStub(isolate, init_state) { + set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI)); + } + class TypesBits : public BitField {}; class ResultModeBits : public BitField {}; - virtual Major MajorKey() const V8_OVERRIDE { return ToBoolean; } - int NotMissMinorKey() const { - return TypesBits::encode(types_.ToByte()) | ResultModeBits::encode(mode_); - } - - ToBooleanStub(Isolate* isolate, InitializationState init_state) - : HydrogenCodeStub(isolate, init_state), mode_(RESULT_AS_SMI) {} - - Types types_; - ResultMode mode_; + DISALLOW_COPY_AND_ASSIGN(ToBooleanStub); }; @@ -2559,21 +2561,21 @@ OStream& operator<<(OStream& os, const ToBooleanStub::Types& t); class ElementsTransitionAndStoreStub : public HydrogenCodeStub { public: - ElementsTransitionAndStoreStub(Isolate* isolate, - ElementsKind from_kind, - ElementsKind to_kind, - bool is_jsarray, + ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, + ElementsKind to_kind, bool is_jsarray, KeyedAccessStoreMode store_mode) - : HydrogenCodeStub(isolate), - from_kind_(from_kind), - to_kind_(to_kind), - is_jsarray_(is_jsarray), - store_mode_(store_mode) {} + : HydrogenCodeStub(isolate) { + set_sub_minor_key(FromBits::encode(from_kind) | ToBits::encode(to_kind) | + IsJSArrayBits::encode(is_jsarray) | + StoreModeBits::encode(store_mode)); + } - ElementsKind from_kind() const { return from_kind_; } - ElementsKind to_kind() const { return to_kind_; } - bool is_jsarray() const { return is_jsarray_; } - KeyedAccessStoreMode store_mode() const { return store_mode_; } + ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); } + ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); } + bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); } + KeyedAccessStoreMode store_mode() const { + return StoreModeBits::decode(sub_minor_key()); + } virtual Handle GenerateCode() V8_OVERRIDE; @@ -2601,25 +2603,14 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub { } private: - class FromBits: public BitField {}; - class ToBits: public BitField {}; - class IsJSArrayBits: public BitField {}; - class StoreModeBits: public BitField {}; - virtual Major MajorKey() const V8_OVERRIDE { return ElementsTransitionAndStore; } - int NotMissMinorKey() const { - return FromBits::encode(from_kind_) | - ToBits::encode(to_kind_) | - IsJSArrayBits::encode(is_jsarray_) | - StoreModeBits::encode(store_mode_); - } - ElementsKind from_kind_; - ElementsKind to_kind_; - bool is_jsarray_; - KeyedAccessStoreMode store_mode_; + class FromBits : public BitField {}; + class ToBits : public BitField {}; + class IsJSArrayBits : public BitField {}; + class StoreModeBits : public BitField {}; DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); };