Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: src/objects.h

Issue 132063004: More efficient use of space in AllocationSite. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Just eliminate one word. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index f98c025ddd3ec0de5ac66198180dd0765406d3cc..f8db8ba30d407937eda36a3a08aad09fcf5533dc 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -8122,11 +8122,12 @@ class AllocationSite: public Struct {
static const int kPretenureMinimumCreated = 100;
// Values for pretenure decision field.
- enum {
+ enum PretenureDecision {
kUndecided = 0,
kDontTenure = 1,
kTenure = 2,
- kZombie = 3
+ kZombie = 3,
+ kLastPretenureDecisionValue = kZombie
};
DECL_ACCESSORS(transition_info, Object)
@@ -8134,11 +8135,8 @@ class AllocationSite: public Struct {
// walked in a particular order. So [[1, 2], 1, 2] will have one
// nested_site, but [[1, 2], 3, [4]] will have a list of two.
DECL_ACCESSORS(nested_site, Object)
- DECL_ACCESSORS(memento_found_count, Smi)
- DECL_ACCESSORS(memento_create_count, Smi)
- // TODO(mvstanton): we don't need a whole integer to record pretenure
- // decision. Consider sharing space with memento_found_count.
- DECL_ACCESSORS(pretenure_decision, Smi)
+ DECL_ACCESSORS(pretenure_data, Smi)
+ DECL_ACCESSORS(pretenure_create_count, Smi)
DECL_ACCESSORS(dependent_code, DependentCode)
DECL_ACCESSORS(weak_next, Object)
@@ -8147,10 +8145,16 @@ class AllocationSite: public Struct {
// This method is expensive, it should only be called for reporting.
bool IsNestedSite();
+ // transition_info bitfields, for constructed array transition info.
class ElementsKindBits: public BitField<ElementsKind, 0, 15> {};
class UnusedBits: public BitField<int, 15, 14> {};
class DoNotInlineBit: public BitField<bool, 29, 1> {};
+ // Bitfields for pretenure_data
+ class MementoFoundCountBits: public BitField<int, 0, 28> {};
+ class PretenureDecisionBits: public BitField<PretenureDecision, 28, 2> {};
+ STATIC_ASSERT(PretenureDecisionBits::kMax >= kLastPretenureDecisionValue);
+
// Increments the mementos found counter and returns true when the first
// memento was found for a given allocation site.
inline bool IncrementMementoFoundCount();
@@ -8158,9 +8162,35 @@ class AllocationSite: public Struct {
inline void IncrementMementoCreateCount();
PretenureFlag GetPretenureMode() {
- int mode = pretenure_decision()->value();
// Zombie objects "decide" to be untenured.
- return (mode == kTenure) ? TENURED : NOT_TENURED;
+ return (pretenure_decision() == kTenure) ? TENURED : NOT_TENURED;
+ }
+
+ PretenureDecision pretenure_decision() {
+ int value = pretenure_data()->value();
+ return PretenureDecisionBits::decode(value);
+ }
+
+ void set_pretenure_decision(PretenureDecision decision) {
+ int value = pretenure_data()->value();
+ set_pretenure_data(
+ Smi::FromInt(PretenureDecisionBits::update(value, decision)),
+ SKIP_WRITE_BARRIER);
+ }
+
+ int memento_found_count() {
+ int value = pretenure_data()->value();
+ return MementoFoundCountBits::decode(value);
+ }
+
+ inline void set_memento_found_count(int count);
+
+ int memento_create_count() {
+ return pretenure_create_count()->value();
+ }
+
+ void set_memento_create_count(int count) {
+ set_pretenure_create_count(Smi::FromInt(count), SKIP_WRITE_BARRIER);
}
// The pretenuring decision is made during gc, and the zombie state allows
@@ -8168,7 +8198,7 @@ class AllocationSite: public Struct {
// a later traversal of new space may discover AllocationMementos that point
// to this AllocationSite.
bool IsZombie() {
- return pretenure_decision()->value() == kZombie;
+ return pretenure_decision() == kZombie;
}
inline void MarkZombie();
@@ -8226,13 +8256,11 @@ class AllocationSite: public Struct {
static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize;
- static const int kMementoFoundCountOffset = kNestedSiteOffset + kPointerSize;
- static const int kMementoCreateCountOffset =
- kMementoFoundCountOffset + kPointerSize;
- static const int kPretenureDecisionOffset =
- kMementoCreateCountOffset + kPointerSize;
+ static const int kPretenureDataOffset = kNestedSiteOffset + kPointerSize;
+ static const int kPretenureCreateCountOffset =
+ kPretenureDataOffset + kPointerSize;
static const int kDependentCodeOffset =
- kPretenureDecisionOffset + kPointerSize;
+ kPretenureCreateCountOffset + kPointerSize;
static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
static const int kSize = kWeakNextOffset + kPointerSize;
@@ -8249,7 +8277,7 @@ class AllocationSite: public Struct {
private:
inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason);
bool PretenuringDecisionMade() {
- return pretenure_decision()->value() != kUndecided;
+ return pretenure_decision() != kUndecided;
}
DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite);
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/objects.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698