Commit 3cfef1e0 authored by yangguo@chromium.org's avatar yangguo@chromium.org

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
parent 33c28c71
...@@ -1063,7 +1063,7 @@ HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { ...@@ -1063,7 +1063,7 @@ HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
HValue* true_value = NULL; HValue* true_value = NULL;
HValue* false_value = NULL; HValue* false_value = NULL;
switch (stub->GetMode()) { switch (stub->mode()) {
case ToBooleanStub::RESULT_AS_SMI: case ToBooleanStub::RESULT_AS_SMI:
true_value = graph()->GetConstant1(); true_value = graph()->GetConstant1();
false_value = graph()->GetConstant0(); false_value = graph()->GetConstant0();
...@@ -1079,7 +1079,7 @@ HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { ...@@ -1079,7 +1079,7 @@ HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
} }
IfBuilder if_true(this); IfBuilder if_true(this);
if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); if_true.If<HBranch>(GetParameter(0), stub->types());
if_true.Then(); if_true.Then();
if_true.Return(true_value); if_true.Return(true_value);
if_true.Else(); if_true.Else();
......
...@@ -810,15 +810,17 @@ OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT ...@@ -810,15 +810,17 @@ OStream& ArrayConstructorStubBase::BasePrintName(OStream& os, // NOLINT
bool ToBooleanStub::UpdateStatus(Handle<Object> object) { bool ToBooleanStub::UpdateStatus(Handle<Object> object) {
Types old_types(types_); Types new_types = types();
bool to_boolean_value = types_.UpdateStatus(object); Types old_types = new_types;
TraceTransition(old_types, 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; return to_boolean_value;
} }
void ToBooleanStub::PrintState(OStream& os) const { // NOLINT void ToBooleanStub::PrintState(OStream& os) const { // NOLINT
os << types_; os << types();
} }
......
...@@ -644,9 +644,9 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub { ...@@ -644,9 +644,9 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub {
public: public:
static const int kMaximumSlots = 64; static const int kMaximumSlots = 64;
FastNewContextStub(Isolate* isolate, int slots) FastNewContextStub(Isolate* isolate, int slots) : HydrogenCodeStub(isolate) {
: HydrogenCodeStub(isolate), slots_(slots) { DCHECK(slots > 0 && slots <= kMaximumSlots);
DCHECK(slots_ > 0 && slots_ <= kMaximumSlots); set_sub_minor_key(SlotsBits::encode(slots));
} }
virtual Handle<Code> GenerateCode() V8_OVERRIDE; virtual Handle<Code> GenerateCode() V8_OVERRIDE;
...@@ -656,16 +656,17 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub { ...@@ -656,16 +656,17 @@ class FastNewContextStub V8_FINAL : public HydrogenCodeStub {
static void InstallDescriptors(Isolate* isolate); static void InstallDescriptors(Isolate* isolate);
int slots() const { return slots_; } int slots() const { return SlotsBits::decode(sub_minor_key()); }
virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; }
virtual int NotMissMinorKey() const V8_OVERRIDE { return slots_; }
// Parameters accessed via CodeStubGraphBuilder::GetParameter() // Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kFunction = 0; static const int kFunction = 0;
private: private:
int slots_; virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; }
class SlotsBits : public BitField<int, 0, 8> {};
DISALLOW_COPY_AND_ASSIGN(FastNewContextStub);
}; };
...@@ -673,11 +674,12 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub { ...@@ -673,11 +674,12 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub {
public: public:
FastCloneShallowArrayStub(Isolate* isolate, FastCloneShallowArrayStub(Isolate* isolate,
AllocationSiteMode allocation_site_mode) AllocationSiteMode allocation_site_mode)
: HydrogenCodeStub(isolate), : HydrogenCodeStub(isolate) {
allocation_site_mode_(allocation_site_mode) {} set_sub_minor_key(AllocationSiteModeBits::encode(allocation_site_mode));
}
AllocationSiteMode allocation_site_mode() const { AllocationSiteMode allocation_site_mode() const {
return allocation_site_mode_; return AllocationSiteModeBits::decode(sub_minor_key());
} }
virtual Handle<Code> GenerateCode(); virtual Handle<Code> GenerateCode();
...@@ -688,14 +690,11 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub { ...@@ -688,14 +690,11 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub {
static void InstallDescriptors(Isolate* isolate); static void InstallDescriptors(Isolate* isolate);
private: private:
AllocationSiteMode allocation_site_mode_; virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; }
class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {};
// Ensure data fits within available bits.
virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; } DISALLOW_COPY_AND_ASSIGN(FastCloneShallowArrayStub);
int NotMissMinorKey() const {
return AllocationSiteModeBits::encode(allocation_site_mode_);
}
}; };
...@@ -2498,15 +2497,20 @@ class ToBooleanStub: public HydrogenCodeStub { ...@@ -2498,15 +2497,20 @@ class ToBooleanStub: public HydrogenCodeStub {
}; };
ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types()) 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) ToBooleanStub(Isolate* isolate, ExtraICState state)
: HydrogenCodeStub(isolate), : HydrogenCodeStub(isolate) {
types_(static_cast<byte>(state)), set_sub_minor_key(TypesBits::encode(static_cast<byte>(state)) |
mode_(RESULT_AS_SMI) {} ResultModeBits::encode(RESULT_AS_SMI));
}
bool UpdateStatus(Handle<Object> object); bool UpdateStatus(Handle<Object> object);
Types GetTypes() { return types_; } Types types() const { return Types(TypesBits::decode(sub_minor_key())); }
ResultMode GetMode() { return mode_; } ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); }
virtual Handle<Code> GenerateCode() V8_OVERRIDE; virtual Handle<Code> GenerateCode() V8_OVERRIDE;
virtual void InitializeInterfaceDescriptor( virtual void InitializeInterfaceDescriptor(
...@@ -2527,10 +2531,10 @@ class ToBooleanStub: public HydrogenCodeStub { ...@@ -2527,10 +2531,10 @@ class ToBooleanStub: public HydrogenCodeStub {
return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); return ToBooleanStub(isolate, UNINITIALIZED).GetCode();
} }
virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); } virtual ExtraICState GetExtraICState() const { return types().ToIntegral(); }
virtual InlineCacheState GetICState() const { virtual InlineCacheState GetICState() const {
if (types_.IsEmpty()) { if (types().IsEmpty()) {
return ::v8::internal::UNINITIALIZED; return ::v8::internal::UNINITIALIZED;
} else { } else {
return MONOMORPHIC; return MONOMORPHIC;
...@@ -2538,19 +2542,17 @@ class ToBooleanStub: public HydrogenCodeStub { ...@@ -2538,19 +2542,17 @@ class ToBooleanStub: public HydrogenCodeStub {
} }
private: private:
class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {};
class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
virtual Major MajorKey() const V8_OVERRIDE { return ToBoolean; } 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) ToBooleanStub(Isolate* isolate, InitializationState init_state)
: HydrogenCodeStub(isolate, init_state), mode_(RESULT_AS_SMI) {} : HydrogenCodeStub(isolate, init_state) {
set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI));
}
Types types_; class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {};
ResultMode mode_; class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
DISALLOW_COPY_AND_ASSIGN(ToBooleanStub);
}; };
...@@ -2559,21 +2561,21 @@ OStream& operator<<(OStream& os, const ToBooleanStub::Types& t); ...@@ -2559,21 +2561,21 @@ OStream& operator<<(OStream& os, const ToBooleanStub::Types& t);
class ElementsTransitionAndStoreStub : public HydrogenCodeStub { class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
public: public:
ElementsTransitionAndStoreStub(Isolate* isolate, ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind,
ElementsKind from_kind, ElementsKind to_kind, bool is_jsarray,
ElementsKind to_kind,
bool is_jsarray,
KeyedAccessStoreMode store_mode) KeyedAccessStoreMode store_mode)
: HydrogenCodeStub(isolate), : HydrogenCodeStub(isolate) {
from_kind_(from_kind), set_sub_minor_key(FromBits::encode(from_kind) | ToBits::encode(to_kind) |
to_kind_(to_kind), IsJSArrayBits::encode(is_jsarray) |
is_jsarray_(is_jsarray), StoreModeBits::encode(store_mode));
store_mode_(store_mode) {} }
ElementsKind from_kind() const { return from_kind_; } ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); }
ElementsKind to_kind() const { return to_kind_; } ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); }
bool is_jsarray() const { return is_jsarray_; } bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); }
KeyedAccessStoreMode store_mode() const { return store_mode_; } KeyedAccessStoreMode store_mode() const {
return StoreModeBits::decode(sub_minor_key());
}
virtual Handle<Code> GenerateCode() V8_OVERRIDE; virtual Handle<Code> GenerateCode() V8_OVERRIDE;
...@@ -2601,25 +2603,14 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub { ...@@ -2601,25 +2603,14 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
} }
private: private:
class FromBits: public BitField<ElementsKind, 0, 8> {};
class ToBits: public BitField<ElementsKind, 8, 8> {};
class IsJSArrayBits: public BitField<bool, 16, 1> {};
class StoreModeBits: public BitField<KeyedAccessStoreMode, 17, 4> {};
virtual Major MajorKey() const V8_OVERRIDE { virtual Major MajorKey() const V8_OVERRIDE {
return ElementsTransitionAndStore; 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_; class FromBits : public BitField<ElementsKind, 0, 8> {};
ElementsKind to_kind_; class ToBits : public BitField<ElementsKind, 8, 8> {};
bool is_jsarray_; class IsJSArrayBits : public BitField<bool, 16, 1> {};
KeyedAccessStoreMode store_mode_; class StoreModeBits : public BitField<KeyedAccessStoreMode, 17, 4> {};
DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment