| 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 8116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8127 kDontTenure = 1, | 8127 kDontTenure = 1, |
| 8128 kTenure = 2, | 8128 kTenure = 2, |
| 8129 kZombie = 3 | 8129 kZombie = 3 |
| 8130 }; | 8130 }; |
| 8131 | 8131 |
| 8132 DECL_ACCESSORS(transition_info, Object) | 8132 DECL_ACCESSORS(transition_info, Object) |
| 8133 // nested_site threads a list of sites that represent nested literals | 8133 // nested_site threads a list of sites that represent nested literals |
| 8134 // walked in a particular order. So [[1, 2], 1, 2] will have one | 8134 // walked in a particular order. So [[1, 2], 1, 2] will have one |
| 8135 // nested_site, but [[1, 2], 3, [4]] will have a list of two. | 8135 // nested_site, but [[1, 2], 3, [4]] will have a list of two. |
| 8136 DECL_ACCESSORS(nested_site, Object) | 8136 DECL_ACCESSORS(nested_site, Object) |
| 8137 DECL_ACCESSORS(memento_found_count, Smi) | 8137 DECL_ACCESSORS(pretenure_data, Smi) |
| 8138 DECL_ACCESSORS(memento_create_count, Smi) | |
| 8139 // TODO(mvstanton): we don't need a whole integer to record pretenure | |
| 8140 // decision. Consider sharing space with memento_found_count. | |
| 8141 DECL_ACCESSORS(pretenure_decision, Smi) | |
| 8142 DECL_ACCESSORS(dependent_code, DependentCode) | 8138 DECL_ACCESSORS(dependent_code, DependentCode) |
| 8143 DECL_ACCESSORS(weak_next, Object) | 8139 DECL_ACCESSORS(weak_next, Object) |
| 8144 | 8140 |
| 8145 inline void Initialize(); | 8141 inline void Initialize(); |
| 8146 | 8142 |
| 8147 // This method is expensive, it should only be called for reporting. | 8143 // This method is expensive, it should only be called for reporting. |
| 8148 bool IsNestedSite(); | 8144 bool IsNestedSite(); |
| 8149 | 8145 |
| 8150 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; | 8146 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; |
| 8151 class UnusedBits: public BitField<int, 15, 14> {}; | 8147 class UnusedBits: public BitField<int, 15, 14> {}; |
| 8152 class DoNotInlineBit: public BitField<bool, 29, 1> {}; | 8148 class DoNotInlineBit: public BitField<bool, 29, 1> {}; |
| 8153 | 8149 |
| 8150 // Bitfields for pretenure_data |
| 8151 class MementoCreateCountBits: public BitField<int, 0, 14> {}; |
| 8152 class MementoFoundCountBits: public BitField<int, 15, 14> {}; |
| 8153 class PretenureDecisionBits: public BitField<int, 28, 2> {}; |
| 8154 |
| 8154 // Increments the mementos found counter and returns true when the first | 8155 // Increments the mementos found counter and returns true when the first |
| 8155 // memento was found for a given allocation site. | 8156 // memento was found for a given allocation site. |
| 8156 inline bool IncrementMementoFoundCount(); | 8157 inline bool IncrementMementoFoundCount(); |
| 8157 | 8158 |
| 8158 inline void IncrementMementoCreateCount(); | 8159 inline void IncrementMementoCreateCount(); |
| 8159 | 8160 |
| 8160 PretenureFlag GetPretenureMode() { | 8161 PretenureFlag GetPretenureMode() { |
| 8161 int mode = pretenure_decision()->value(); | 8162 int mode = pretenure_decision(); |
| 8162 // Zombie objects "decide" to be untenured. | 8163 // Zombie objects "decide" to be untenured. |
| 8163 return (mode == kTenure) ? TENURED : NOT_TENURED; | 8164 return (mode == kTenure) ? TENURED : NOT_TENURED; |
| 8164 } | 8165 } |
| 8165 | 8166 |
| 8167 int pretenure_decision() { |
| 8168 int value = pretenure_data()->value(); |
| 8169 return PretenureDecisionBits::decode(value); |
| 8170 } |
| 8171 |
| 8172 void set_pretenure_decision(int decision) { |
| 8173 int value = pretenure_data()->value(); |
| 8174 set_pretenure_data( |
| 8175 Smi::FromInt(PretenureDecisionBits::update(value, decision)), |
| 8176 SKIP_WRITE_BARRIER); |
| 8177 } |
| 8178 |
| 8179 int memento_found_count() { |
| 8180 int value = pretenure_data()->value(); |
| 8181 return MementoFoundCountBits::decode(value); |
| 8182 } |
| 8183 |
| 8184 void set_memento_found_count(int count) { |
| 8185 int value = pretenure_data()->value(); |
| 8186 if (count >= MementoFoundCountBits::kMax) return; |
| 8187 set_pretenure_data( |
| 8188 Smi::FromInt(MementoFoundCountBits::update(value, count)), |
| 8189 SKIP_WRITE_BARRIER); |
| 8190 } |
| 8191 |
| 8192 int memento_create_count() { |
| 8193 int value = pretenure_data()->value(); |
| 8194 return MementoCreateCountBits::decode(value); |
| 8195 } |
| 8196 |
| 8197 void set_memento_create_count(int count) { |
| 8198 int value = pretenure_data()->value(); |
| 8199 if (count >= MementoCreateCountBits::kMax) return; |
| 8200 set_pretenure_data( |
| 8201 Smi::FromInt(MementoCreateCountBits::update(value, count)), |
| 8202 SKIP_WRITE_BARRIER); |
| 8203 } |
| 8204 |
| 8166 // The pretenuring decision is made during gc, and the zombie state allows | 8205 // The pretenuring decision is made during gc, and the zombie state allows |
| 8167 // us to recognize when an allocation site is just being kept alive because | 8206 // us to recognize when an allocation site is just being kept alive because |
| 8168 // a later traversal of new space may discover AllocationMementos that point | 8207 // a later traversal of new space may discover AllocationMementos that point |
| 8169 // to this AllocationSite. | 8208 // to this AllocationSite. |
| 8170 bool IsZombie() { | 8209 bool IsZombie() { |
| 8171 return pretenure_decision()->value() == kZombie; | 8210 return pretenure_decision() == kZombie; |
| 8172 } | 8211 } |
| 8173 | 8212 |
| 8174 inline void MarkZombie(); | 8213 inline void MarkZombie(); |
| 8175 | 8214 |
| 8176 inline bool DigestPretenuringFeedback(); | 8215 inline bool DigestPretenuringFeedback(); |
| 8177 | 8216 |
| 8178 ElementsKind GetElementsKind() { | 8217 ElementsKind GetElementsKind() { |
| 8179 ASSERT(!SitePointsToLiteral()); | 8218 ASSERT(!SitePointsToLiteral()); |
| 8180 int value = Smi::cast(transition_info())->value(); | 8219 int value = Smi::cast(transition_info())->value(); |
| 8181 return ElementsKindBits::decode(value); | 8220 return ElementsKindBits::decode(value); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8219 DECLARE_VERIFIER(AllocationSite) | 8258 DECLARE_VERIFIER(AllocationSite) |
| 8220 | 8259 |
| 8221 static inline AllocationSite* cast(Object* obj); | 8260 static inline AllocationSite* cast(Object* obj); |
| 8222 static inline AllocationSiteMode GetMode( | 8261 static inline AllocationSiteMode GetMode( |
| 8223 ElementsKind boilerplate_elements_kind); | 8262 ElementsKind boilerplate_elements_kind); |
| 8224 static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind to); | 8263 static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind to); |
| 8225 static inline bool CanTrack(InstanceType type); | 8264 static inline bool CanTrack(InstanceType type); |
| 8226 | 8265 |
| 8227 static const int kTransitionInfoOffset = HeapObject::kHeaderSize; | 8266 static const int kTransitionInfoOffset = HeapObject::kHeaderSize; |
| 8228 static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize; | 8267 static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize; |
| 8229 static const int kMementoFoundCountOffset = kNestedSiteOffset + kPointerSize; | 8268 static const int kPretenureDataOffset = |
| 8230 static const int kMementoCreateCountOffset = | 8269 kNestedSiteOffset + kPointerSize; |
| 8231 kMementoFoundCountOffset + kPointerSize; | |
| 8232 static const int kPretenureDecisionOffset = | |
| 8233 kMementoCreateCountOffset + kPointerSize; | |
| 8234 static const int kDependentCodeOffset = | 8270 static const int kDependentCodeOffset = |
| 8235 kPretenureDecisionOffset + kPointerSize; | 8271 kPretenureDataOffset + kPointerSize; |
| 8236 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; | 8272 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; |
| 8237 static const int kSize = kWeakNextOffset + kPointerSize; | 8273 static const int kSize = kWeakNextOffset + kPointerSize; |
| 8238 | 8274 |
| 8239 // During mark compact we need to take special care for the dependent code | 8275 // During mark compact we need to take special care for the dependent code |
| 8240 // field. | 8276 // field. |
| 8241 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; | 8277 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; |
| 8242 static const int kPointerFieldsEndOffset = kDependentCodeOffset; | 8278 static const int kPointerFieldsEndOffset = kDependentCodeOffset; |
| 8243 | 8279 |
| 8244 // For other visitors, use the fixed body descriptor below. | 8280 // For other visitors, use the fixed body descriptor below. |
| 8245 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, | 8281 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, |
| 8246 kDependentCodeOffset + kPointerSize, | 8282 kDependentCodeOffset + kPointerSize, |
| 8247 kSize> BodyDescriptor; | 8283 kSize> BodyDescriptor; |
| 8248 | 8284 |
| 8249 private: | 8285 private: |
| 8250 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); | 8286 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); |
| 8251 bool PretenuringDecisionMade() { | 8287 bool PretenuringDecisionMade() { |
| 8252 return pretenure_decision()->value() != kUndecided; | 8288 return pretenure_decision() != kUndecided; |
| 8253 } | 8289 } |
| 8254 | 8290 |
| 8255 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); | 8291 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); |
| 8256 }; | 8292 }; |
| 8257 | 8293 |
| 8258 | 8294 |
| 8259 class AllocationMemento: public Struct { | 8295 class AllocationMemento: public Struct { |
| 8260 public: | 8296 public: |
| 8261 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; | 8297 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; |
| 8262 static const int kSize = kAllocationSiteOffset + kPointerSize; | 8298 static const int kSize = kAllocationSiteOffset + kPointerSize; |
| (...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10627 } else { | 10663 } else { |
| 10628 value &= ~(1 << bit_position); | 10664 value &= ~(1 << bit_position); |
| 10629 } | 10665 } |
| 10630 return value; | 10666 return value; |
| 10631 } | 10667 } |
| 10632 }; | 10668 }; |
| 10633 | 10669 |
| 10634 } } // namespace v8::internal | 10670 } } // namespace v8::internal |
| 10635 | 10671 |
| 10636 #endif // V8_OBJECTS_H_ | 10672 #endif // V8_OBJECTS_H_ |
| OLD | NEW |