Chromium Code Reviews| 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 8086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8097 enum AllocationSiteMode { | 8097 enum AllocationSiteMode { |
| 8098 DONT_TRACK_ALLOCATION_SITE, | 8098 DONT_TRACK_ALLOCATION_SITE, |
| 8099 TRACK_ALLOCATION_SITE, | 8099 TRACK_ALLOCATION_SITE, |
| 8100 LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE | 8100 LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE |
| 8101 }; | 8101 }; |
| 8102 | 8102 |
| 8103 | 8103 |
| 8104 class AllocationSite: public Struct { | 8104 class AllocationSite: public Struct { |
| 8105 public: | 8105 public: |
| 8106 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; | 8106 static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; |
| 8107 static const int kUndecided = 0; | |
| 8108 static const int kDontTenure = 1; | |
| 8109 static const int kTenure = 2; | |
| 8110 static const int kZombie = 3; | |
|
Hannes Payer (out of office)
2013/11/21 20:52:24
Right now the state diagram (should) looks like th
mvstanton
2013/11/22 11:18:51
Thx. I made these 4 state values into an enum to i
| |
| 8107 | 8111 |
| 8108 DECL_ACCESSORS(transition_info, Object) | 8112 DECL_ACCESSORS(transition_info, Object) |
| 8109 // nested_site threads a list of sites that represent nested literals | 8113 // nested_site threads a list of sites that represent nested literals |
| 8110 // walked in a particular order. So [[1, 2], 1, 2] will have one | 8114 // walked in a particular order. So [[1, 2], 1, 2] will have one |
| 8111 // nested_site, but [[1, 2], 3, [4]] will have a list of two. | 8115 // nested_site, but [[1, 2], 3, [4]] will have a list of two. |
| 8112 DECL_ACCESSORS(nested_site, Object) | 8116 DECL_ACCESSORS(nested_site, Object) |
| 8113 DECL_ACCESSORS(memento_found_count, Smi) | 8117 DECL_ACCESSORS(memento_found_count, Smi) |
| 8114 DECL_ACCESSORS(memento_create_count, Smi) | 8118 DECL_ACCESSORS(memento_create_count, Smi) |
| 8115 DECL_ACCESSORS(pretenure_decision, Smi) | 8119 DECL_ACCESSORS(pretenure_decision, Smi) |
| 8116 DECL_ACCESSORS(dependent_code, DependentCode) | 8120 DECL_ACCESSORS(dependent_code, DependentCode) |
| 8117 DECL_ACCESSORS(weak_next, Object) | 8121 DECL_ACCESSORS(weak_next, Object) |
| 8118 | 8122 |
| 8119 inline void Initialize(); | 8123 inline void Initialize(); |
| 8120 | 8124 |
| 8121 bool HasNestedSites() { | |
| 8122 return nested_site()->IsAllocationSite(); | |
| 8123 } | |
| 8124 | |
| 8125 // This method is expensive, it should only be called for reporting. | 8125 // This method is expensive, it should only be called for reporting. |
| 8126 bool IsNestedSite(); | 8126 bool IsNestedSite(); |
| 8127 | 8127 |
| 8128 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; | 8128 class ElementsKindBits: public BitField<ElementsKind, 0, 15> {}; |
| 8129 class UnusedBits: public BitField<int, 15, 14> {}; | 8129 class UnusedBits: public BitField<int, 15, 14> {}; |
| 8130 class DoNotInlineBit: public BitField<bool, 29, 1> {}; | 8130 class DoNotInlineBit: public BitField<bool, 29, 1> {}; |
| 8131 | 8131 |
|
Hannes Payer (out of office)
2013/11/21 20:52:24
Can we have newlines between the methods?
mvstanton
2013/11/22 11:18:51
Done.
| |
| 8132 inline void IncrementMementoFoundCount(); | |
| 8133 inline void IncrementMementoCreateCount(); | |
| 8134 PretenureFlag GetPretenureMode() { | |
| 8135 int mode = pretenure_decision()->value(); | |
| 8136 // Zombie objects "decide" to be untenured. | |
| 8137 return (mode == kTenure) ? TENURED : NOT_TENURED; | |
| 8138 } | |
| 8139 bool IsZombie() { | |
| 8140 return pretenure_decision()->value() == kZombie; | |
| 8141 } | |
| 8142 inline void MarkZombie(); | |
| 8143 bool DecisionMade() { | |
| 8144 return pretenure_decision()->value() != kUndecided; | |
| 8145 } | |
| 8146 void Decide() { | |
| 8147 ASSERT(!DecisionMade()); | |
| 8148 if (ShouldPretenure()) { | |
| 8149 set_pretenure_decision(Smi::FromInt(kTenure)); | |
| 8150 } else { | |
| 8151 set_pretenure_decision(Smi::FromInt(kDontTenure)); | |
| 8152 } | |
| 8153 } | |
| 8154 void Clear() { | |
| 8155 set_memento_found_count(Smi::FromInt(0)); | |
| 8156 set_memento_create_count(Smi::FromInt(0)); | |
| 8157 } | |
| 8158 | |
| 8132 ElementsKind GetElementsKind() { | 8159 ElementsKind GetElementsKind() { |
| 8133 ASSERT(!SitePointsToLiteral()); | 8160 ASSERT(!SitePointsToLiteral()); |
| 8134 int value = Smi::cast(transition_info())->value(); | 8161 int value = Smi::cast(transition_info())->value(); |
| 8135 return ElementsKindBits::decode(value); | 8162 return ElementsKindBits::decode(value); |
| 8136 } | 8163 } |
| 8137 | 8164 |
| 8138 void SetElementsKind(ElementsKind kind) { | 8165 void SetElementsKind(ElementsKind kind) { |
| 8139 int value = Smi::cast(transition_info())->value(); | 8166 int value = Smi::cast(transition_info())->value(); |
| 8140 set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)), | 8167 set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)), |
| 8141 SKIP_WRITE_BARRIER); | 8168 SKIP_WRITE_BARRIER); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8195 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; | 8222 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; |
| 8196 static const int kPointerFieldsEndOffset = kDependentCodeOffset; | 8223 static const int kPointerFieldsEndOffset = kDependentCodeOffset; |
| 8197 | 8224 |
| 8198 // For other visitors, use the fixed body descriptor below. | 8225 // For other visitors, use the fixed body descriptor below. |
| 8199 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, | 8226 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, |
| 8200 kDependentCodeOffset + kPointerSize, | 8227 kDependentCodeOffset + kPointerSize, |
| 8201 kSize> BodyDescriptor; | 8228 kSize> BodyDescriptor; |
| 8202 | 8229 |
| 8203 private: | 8230 private: |
| 8204 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); | 8231 inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason); |
| 8232 inline bool ShouldPretenure(); | |
| 8233 | |
| 8205 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); | 8234 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); |
| 8206 }; | 8235 }; |
| 8207 | 8236 |
| 8208 | 8237 |
| 8209 class AllocationMemento: public Struct { | 8238 class AllocationMemento: public Struct { |
| 8210 public: | 8239 public: |
| 8211 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; | 8240 static const int kAllocationSiteOffset = HeapObject::kHeaderSize; |
| 8212 static const int kSize = kAllocationSiteOffset + kPointerSize; | 8241 static const int kSize = kAllocationSiteOffset + kPointerSize; |
| 8213 | 8242 |
| 8214 DECL_ACCESSORS(allocation_site, Object) | 8243 DECL_ACCESSORS(allocation_site, Object) |
| 8215 | 8244 |
| 8216 bool IsValid() { return allocation_site()->IsAllocationSite(); } | 8245 bool IsValid() { |
| 8246 return allocation_site()->IsAllocationSite() && | |
| 8247 !AllocationSite::cast(allocation_site())->IsZombie(); | |
| 8248 } | |
| 8217 AllocationSite* GetAllocationSite() { | 8249 AllocationSite* GetAllocationSite() { |
| 8218 ASSERT(IsValid()); | 8250 ASSERT(IsValid()); |
| 8219 return AllocationSite::cast(allocation_site()); | 8251 return AllocationSite::cast(allocation_site()); |
| 8220 } | 8252 } |
| 8221 | 8253 |
| 8222 DECLARE_PRINTER(AllocationMemento) | 8254 DECLARE_PRINTER(AllocationMemento) |
| 8223 DECLARE_VERIFIER(AllocationMemento) | 8255 DECLARE_VERIFIER(AllocationMemento) |
| 8224 | 8256 |
| 8225 // Returns NULL if no AllocationMemento is available for object. | 8257 // Returns NULL if no AllocationMemento is available for object. |
| 8226 static AllocationMemento* FindForJSObject(JSObject* object, | 8258 static AllocationMemento* FindForJSObject(JSObject* object, |
| (...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10575 } else { | 10607 } else { |
| 10576 value &= ~(1 << bit_position); | 10608 value &= ~(1 << bit_position); |
| 10577 } | 10609 } |
| 10578 return value; | 10610 return value; |
| 10579 } | 10611 } |
| 10580 }; | 10612 }; |
| 10581 | 10613 |
| 10582 } } // namespace v8::internal | 10614 } } // namespace v8::internal |
| 10583 | 10615 |
| 10584 #endif // V8_OBJECTS_H_ | 10616 #endif // V8_OBJECTS_H_ |
| OLD | NEW |