OLD | NEW |
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 8087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8098 enum AllocationSiteMode { | 8098 enum AllocationSiteMode { |
8099 DONT_TRACK_ALLOCATION_SITE, | 8099 DONT_TRACK_ALLOCATION_SITE, |
8100 TRACK_ALLOCATION_SITE, | 8100 TRACK_ALLOCATION_SITE, |
8101 LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE | 8101 LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE |
8102 }; | 8102 }; |
8103 | 8103 |
8104 | 8104 |
8105 class AllocationSite: public Struct { | 8105 class AllocationSite: public Struct { |
8106 public: | 8106 public: |
8107 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; | 8107 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; |
| 8108 static const double kPretenureRatio; |
| 8109 static const int kPretenureMinimumCreated = 100; |
| 8110 |
| 8111 // Values for pretenure decision field. |
| 8112 enum { |
| 8113 kUndecided = 0, |
| 8114 kDontTenure = 1, |
| 8115 kTenure = 2, |
| 8116 kZombie = 3 |
| 8117 }; |
8108 | 8118 |
8109 DECL_ACCESSORS(transition_info, Object) | 8119 DECL_ACCESSORS(transition_info, Object) |
8110 // nested_site threads a list of sites that represent nested literals | 8120 // nested_site threads a list of sites that represent nested literals |
8111 // walked in a particular order. So [[1, 2], 1, 2] will have one | 8121 // walked in a particular order. So [[1, 2], 1, 2] will have one |
8112 // nested_site, but [[1, 2], 3, [4]] will have a list of two. | 8122 // nested_site, but [[1, 2], 3, [4]] will have a list of two. |
8113 DECL_ACCESSORS(nested_site, Object) | 8123 DECL_ACCESSORS(nested_site, Object) |
8114 DECL_ACCESSORS(memento_found_count, Smi) | 8124 DECL_ACCESSORS(memento_found_count, Smi) |
8115 DECL_ACCESSORS(memento_create_count, Smi) | 8125 DECL_ACCESSORS(memento_create_count, Smi) |
| 8126 // TODO(mvstanton): we don't need a whole integer to record pretenure |
| 8127 // decision. Consider sharing space with memento_found_count. |
8116 DECL_ACCESSORS(pretenure_decision, Smi) | 8128 DECL_ACCESSORS(pretenure_decision, Smi) |
8117 DECL_ACCESSORS(dependent_code, DependentCode) | 8129 DECL_ACCESSORS(dependent_code, DependentCode) |
8118 DECL_ACCESSORS(weak_next, Object) | 8130 DECL_ACCESSORS(weak_next, Object) |
8119 | 8131 |
8120 inline void Initialize(); | 8132 inline void Initialize(); |
8121 | 8133 |
8122 bool HasNestedSites() { | |
8123 return nested_site()->IsAllocationSite(); | |
8124 } | |
8125 | |
8126 // This method is expensive, it should only be called for reporting. | 8134 // This method is expensive, it should only be called for reporting. |
8127 bool IsNestedSite(); | 8135 bool IsNestedSite(); |
8128 | 8136 |
8129 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; | 8137 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; |
8130 class UnusedBits: public BitField<int, 15, 14> {}; | 8138 class UnusedBits: public BitField<int, 15, 14> {}; |
8131 class DoNotInlineBit: public BitField<bool, 29, 1> {}; | 8139 class DoNotInlineBit: public BitField<bool, 29, 1> {}; |
8132 | 8140 |
| 8141 inline void IncrementMementoFoundCount(); |
| 8142 |
| 8143 inline void IncrementMementoCreateCount(); |
| 8144 |
| 8145 PretenureFlag GetPretenureMode() { |
| 8146 int mode = pretenure_decision()->value(); |
| 8147 // Zombie objects "decide" to be untenured. |
| 8148 return (mode == kTenure) ? TENURED : NOT_TENURED; |
| 8149 } |
| 8150 |
| 8151 // The pretenuring decision is made during gc, and the zombie state allows |
| 8152 // us to recognize when an allocation site is just being kept alive because |
| 8153 // a later traversal of new space may discover AllocationMementos that point |
| 8154 // to this AllocationSite. |
| 8155 bool IsZombie() { |
| 8156 return pretenure_decision()->value() == kZombie; |
| 8157 } |
| 8158 |
| 8159 inline void MarkZombie(); |
| 8160 |
| 8161 inline bool DigestPretenuringFeedback(); |
| 8162 |
8133 ElementsKind GetElementsKind() { | 8163 ElementsKind GetElementsKind() { |
8134 ASSERT(!SitePointsToLiteral()); | 8164 ASSERT(!SitePointsToLiteral()); |
8135 int value = Smi::cast(transition_info())->value(); | 8165 int value = Smi::cast(transition_info())->value(); |
8136 return ElementsKindBits::decode(value); | 8166 return ElementsKindBits::decode(value); |
8137 } | 8167 } |
8138 | 8168 |
8139 void SetElementsKind(ElementsKind kind) { | 8169 void SetElementsKind(ElementsKind kind) { |
8140 int value = Smi::cast(transition_info())->value(); | 8170 int value = Smi::cast(transition_info())->value(); |
8141 set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)), | 8171 set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)), |
8142 SKIP_WRITE_BARRIER); | 8172 SKIP_WRITE_BARRIER); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8196 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; | 8226 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; |
8197 static const int kPointerFieldsEndOffset = kDependentCodeOffset; | 8227 static const int kPointerFieldsEndOffset = kDependentCodeOffset; |
8198 | 8228 |
8199 // For other visitors, use the fixed body descriptor below. | 8229 // For other visitors, use the fixed body descriptor below. |
8200 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, | 8230 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, |
8201 kDependentCodeOffset + kPointerSize, | 8231 kDependentCodeOffset + kPointerSize, |
8202 kSize> BodyDescriptor; | 8232 kSize> BodyDescriptor; |
8203 | 8233 |
8204 private: | 8234 private: |
8205 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); | 8235 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); |
| 8236 bool PretenuringDecisionMade() { |
| 8237 return pretenure_decision()->value() != kUndecided; |
| 8238 } |
| 8239 |
8206 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); | 8240 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); |
8207 }; | 8241 }; |
8208 | 8242 |
8209 | 8243 |
8210 class AllocationMemento: public Struct { | 8244 class AllocationMemento: public Struct { |
8211 public: | 8245 public: |
8212 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; | 8246 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; |
8213 static const int kSize = kAllocationSiteOffset + kPointerSize; | 8247 static const int kSize = kAllocationSiteOffset + kPointerSize; |
8214 | 8248 |
8215 DECL_ACCESSORS(allocation_site, Object) | 8249 DECL_ACCESSORS(allocation_site, Object) |
8216 | 8250 |
8217 bool IsValid() { return allocation_site()->IsAllocationSite(); } | 8251 bool IsValid() { |
| 8252 return allocation_site()->IsAllocationSite() && |
| 8253 !AllocationSite::cast(allocation_site())->IsZombie(); |
| 8254 } |
8218 AllocationSite* GetAllocationSite() { | 8255 AllocationSite* GetAllocationSite() { |
8219 ASSERT(IsValid()); | 8256 ASSERT(IsValid()); |
8220 return AllocationSite::cast(allocation_site()); | 8257 return AllocationSite::cast(allocation_site()); |
8221 } | 8258 } |
8222 | 8259 |
8223 DECLARE_PRINTER(AllocationMemento) | 8260 DECLARE_PRINTER(AllocationMemento) |
8224 DECLARE_VERIFIER(AllocationMemento) | 8261 DECLARE_VERIFIER(AllocationMemento) |
8225 | 8262 |
8226 // Returns NULL if no AllocationMemento is available for object. | 8263 // Returns NULL if no AllocationMemento is available for object. |
8227 static AllocationMemento* FindForJSObject(JSObject* object, | 8264 static AllocationMemento* FindForJSObject(JSObject* object, |
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10576 } else { | 10613 } else { |
10577 value &= ~(1 << bit_position); | 10614 value &= ~(1 << bit_position); |
10578 } | 10615 } |
10579 return value; | 10616 return value; |
10580 } | 10617 } |
10581 }; | 10618 }; |
10582 | 10619 |
10583 } } // namespace v8::internal | 10620 } } // namespace v8::internal |
10584 | 10621 |
10585 #endif // V8_OBJECTS_H_ | 10622 #endif // V8_OBJECTS_H_ |
OLD | NEW |