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

Side by Side 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: REBASE 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8107 matching lines...) Expand 10 before | Expand all | Expand 10 after
8118 }; 8118 };
8119 8119
8120 8120
8121 class AllocationSite: public Struct { 8121 class AllocationSite: public Struct {
8122 public: 8122 public:
8123 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; 8123 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
8124 static const double kPretenureRatio; 8124 static const double kPretenureRatio;
8125 static const int kPretenureMinimumCreated = 100; 8125 static const int kPretenureMinimumCreated = 100;
8126 8126
8127 // Values for pretenure decision field. 8127 // Values for pretenure decision field.
8128 enum { 8128 enum PretenureDecision {
8129 kUndecided = 0, 8129 kUndecided = 0,
8130 kDontTenure = 1, 8130 kDontTenure = 1,
8131 kTenure = 2, 8131 kTenure = 2,
8132 kZombie = 3 8132 kZombie = 3,
8133 kLastPretenureDecisionValue = kZombie
8133 }; 8134 };
8134 8135
8135 DECL_ACCESSORS(transition_info, Object) 8136 DECL_ACCESSORS(transition_info, Object)
8136 // nested_site threads a list of sites that represent nested literals 8137 // nested_site threads a list of sites that represent nested literals
8137 // walked in a particular order. So [[1, 2], 1, 2] will have one 8138 // walked in a particular order. So [[1, 2], 1, 2] will have one
8138 // nested_site, but [[1, 2], 3, [4]] will have a list of two. 8139 // nested_site, but [[1, 2], 3, [4]] will have a list of two.
8139 DECL_ACCESSORS(nested_site, Object) 8140 DECL_ACCESSORS(nested_site, Object)
8140 DECL_ACCESSORS(memento_found_count, Smi) 8141 DECL_ACCESSORS(pretenure_data, Smi)
8141 DECL_ACCESSORS(memento_create_count, Smi) 8142 DECL_ACCESSORS(pretenure_create_count, Smi)
8142 // TODO(mvstanton): we don't need a whole integer to record pretenure
8143 // decision. Consider sharing space with memento_found_count.
8144 DECL_ACCESSORS(pretenure_decision, Smi)
8145 DECL_ACCESSORS(dependent_code, DependentCode) 8143 DECL_ACCESSORS(dependent_code, DependentCode)
8146 DECL_ACCESSORS(weak_next, Object) 8144 DECL_ACCESSORS(weak_next, Object)
8147 8145
8148 inline void Initialize(); 8146 inline void Initialize();
8149 8147
8150 // This method is expensive, it should only be called for reporting. 8148 // This method is expensive, it should only be called for reporting.
8151 bool IsNestedSite(); 8149 bool IsNestedSite();
8152 8150
8151 // transition_info bitfields, for constructed array transition info.
8153 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; 8152 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {};
8154 class UnusedBits: public BitField<int, 15, 14> {}; 8153 class UnusedBits: public BitField<int, 15, 14> {};
8155 class DoNotInlineBit: public BitField<bool, 29, 1> {}; 8154 class DoNotInlineBit: public BitField<bool, 29, 1> {};
8156 8155
8156 // Bitfields for pretenure_data
8157 class MementoFoundCountBits: public BitField<int, 0, 28> {};
8158 class PretenureDecisionBits: public BitField<PretenureDecision, 28, 2> {};
8159 STATIC_ASSERT(PretenureDecisionBits::kMax >= kLastPretenureDecisionValue);
8160
8157 // Increments the mementos found counter and returns true when the first 8161 // Increments the mementos found counter and returns true when the first
8158 // memento was found for a given allocation site. 8162 // memento was found for a given allocation site.
8159 inline bool IncrementMementoFoundCount(); 8163 inline bool IncrementMementoFoundCount();
8160 8164
8161 inline void IncrementMementoCreateCount(); 8165 inline void IncrementMementoCreateCount();
8162 8166
8163 PretenureFlag GetPretenureMode(); 8167 PretenureFlag GetPretenureMode();
8164 8168
8165 void ResetPretenureDecision(); 8169 void ResetPretenureDecision();
8166 8170
8171 PretenureDecision pretenure_decision() {
8172 int value = pretenure_data()->value();
8173 return PretenureDecisionBits::decode(value);
8174 }
8175
8176 void set_pretenure_decision(PretenureDecision decision) {
8177 int value = pretenure_data()->value();
8178 set_pretenure_data(
8179 Smi::FromInt(PretenureDecisionBits::update(value, decision)),
8180 SKIP_WRITE_BARRIER);
8181 }
8182
8183 int memento_found_count() {
8184 int value = pretenure_data()->value();
8185 return MementoFoundCountBits::decode(value);
8186 }
8187
8188 inline void set_memento_found_count(int count);
8189
8190 int memento_create_count() {
8191 return pretenure_create_count()->value();
8192 }
8193
8194 void set_memento_create_count(int count) {
8195 set_pretenure_create_count(Smi::FromInt(count), SKIP_WRITE_BARRIER);
8196 }
8197
8167 // The pretenuring decision is made during gc, and the zombie state allows 8198 // The pretenuring decision is made during gc, and the zombie state allows
8168 // us to recognize when an allocation site is just being kept alive because 8199 // us to recognize when an allocation site is just being kept alive because
8169 // a later traversal of new space may discover AllocationMementos that point 8200 // a later traversal of new space may discover AllocationMementos that point
8170 // to this AllocationSite. 8201 // to this AllocationSite.
8171 bool IsZombie() { 8202 bool IsZombie() {
8172 return pretenure_decision()->value() == kZombie; 8203 return pretenure_decision() == kZombie;
8173 } 8204 }
8174 8205
8175 inline void MarkZombie(); 8206 inline void MarkZombie();
8176 8207
8177 inline bool DigestPretenuringFeedback(); 8208 inline bool DigestPretenuringFeedback();
8178 8209
8179 ElementsKind GetElementsKind() { 8210 ElementsKind GetElementsKind() {
8180 ASSERT(!SitePointsToLiteral()); 8211 ASSERT(!SitePointsToLiteral());
8181 int value = Smi::cast(transition_info())->value(); 8212 int value = Smi::cast(transition_info())->value();
8182 return ElementsKindBits::decode(value); 8213 return ElementsKindBits::decode(value);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
8220 DECLARE_VERIFIER(AllocationSite) 8251 DECLARE_VERIFIER(AllocationSite)
8221 8252
8222 static inline AllocationSite* cast(Object* obj); 8253 static inline AllocationSite* cast(Object* obj);
8223 static inline AllocationSiteMode GetMode( 8254 static inline AllocationSiteMode GetMode(
8224 ElementsKind boilerplate_elements_kind); 8255 ElementsKind boilerplate_elements_kind);
8225 static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind to); 8256 static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind to);
8226 static inline bool CanTrack(InstanceType type); 8257 static inline bool CanTrack(InstanceType type);
8227 8258
8228 static const int kTransitionInfoOffset = HeapObject::kHeaderSize; 8259 static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
8229 static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize; 8260 static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize;
8230 static const int kMementoFoundCountOffset = kNestedSiteOffset + kPointerSize; 8261 static const int kPretenureDataOffset = kNestedSiteOffset + kPointerSize;
8231 static const int kMementoCreateCountOffset = 8262 static const int kPretenureCreateCountOffset =
8232 kMementoFoundCountOffset + kPointerSize; 8263 kPretenureDataOffset + kPointerSize;
8233 static const int kPretenureDecisionOffset =
8234 kMementoCreateCountOffset + kPointerSize;
8235 static const int kDependentCodeOffset = 8264 static const int kDependentCodeOffset =
8236 kPretenureDecisionOffset + kPointerSize; 8265 kPretenureCreateCountOffset + kPointerSize;
8237 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; 8266 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
8238 static const int kSize = kWeakNextOffset + kPointerSize; 8267 static const int kSize = kWeakNextOffset + kPointerSize;
8239 8268
8240 // During mark compact we need to take special care for the dependent code 8269 // During mark compact we need to take special care for the dependent code
8241 // field. 8270 // field.
8242 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; 8271 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset;
8243 static const int kPointerFieldsEndOffset = kDependentCodeOffset; 8272 static const int kPointerFieldsEndOffset = kDependentCodeOffset;
8244 8273
8245 // For other visitors, use the fixed body descriptor below. 8274 // For other visitors, use the fixed body descriptor below.
8246 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, 8275 typedef FixedBodyDescriptor<HeapObject::kHeaderSize,
8247 kDependentCodeOffset + kPointerSize, 8276 kDependentCodeOffset + kPointerSize,
8248 kSize> BodyDescriptor; 8277 kSize> BodyDescriptor;
8249 8278
8250 private: 8279 private:
8251 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); 8280 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason);
8252 bool PretenuringDecisionMade() { 8281 bool PretenuringDecisionMade() {
8253 return pretenure_decision()->value() != kUndecided; 8282 return pretenure_decision() != kUndecided;
8254 } 8283 }
8255 8284
8256 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); 8285 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite);
8257 }; 8286 };
8258 8287
8259 8288
8260 class AllocationMemento: public Struct { 8289 class AllocationMemento: public Struct {
8261 public: 8290 public:
8262 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; 8291 static const int kAllocationSiteOffset = HeapObject::kHeaderSize;
8263 static const int kSize = kAllocationSiteOffset + kPointerSize; 8292 static const int kSize = kAllocationSiteOffset + kPointerSize;
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
10629 } else { 10658 } else {
10630 value &= ~(1 << bit_position); 10659 value &= ~(1 << bit_position);
10631 } 10660 }
10632 return value; 10661 return value;
10633 } 10662 }
10634 }; 10663 };
10635 10664
10636 } } // namespace v8::internal 10665 } } // namespace v8::internal
10637 10666
10638 #endif // V8_OBJECTS_H_ 10667 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698