OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PROPERTY_DETAILS_H_ | 5 #ifndef V8_PROPERTY_DETAILS_H_ |
6 #define V8_PROPERTY_DETAILS_H_ | 6 #define V8_PROPERTY_DETAILS_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/utils.h" | 10 #include "src/utils.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 static const int kDescriptorIndexBitCount = 10; | 179 static const int kDescriptorIndexBitCount = 10; |
180 // The maximum number of descriptors we want in a descriptor array (should | 180 // The maximum number of descriptors we want in a descriptor array (should |
181 // fit in a page). | 181 // fit in a page). |
182 static const int kMaxNumberOfDescriptors = | 182 static const int kMaxNumberOfDescriptors = |
183 (1 << kDescriptorIndexBitCount) - 2; | 183 (1 << kDescriptorIndexBitCount) - 2; |
184 static const int kInvalidEnumCacheSentinel = | 184 static const int kInvalidEnumCacheSentinel = |
185 (1 << kDescriptorIndexBitCount) - 1; | 185 (1 << kDescriptorIndexBitCount) - 1; |
186 | 186 |
187 | 187 |
188 enum class PropertyCellType { | 188 enum class PropertyCellType { |
189 // Meaningful when a property cell does not contain the hole. | 189 kUninitialized, // Cell is deleted or not yet defined. |
190 kUndefined, // The PREMONOMORPHIC of property cells. | 190 kUndefined, // The PREMONOMORPHIC of property cells. |
191 kConstant, // Cell has been assigned only once. | 191 kConstant, // Cell has been assigned only once. |
192 kConstantType, // Cell has been assigned only one type. | 192 kMutable, // Cell will no longer be tracked as constant. |
193 kMutable, // Cell will no longer be tracked as constant. | 193 kDeleted = kConstant, // like kUninitialized, but for cells already deleted. |
194 | 194 kInvalid = kMutable, // For dictionaries not holding cells. |
195 // Meaningful when a property cell contains the hole. | |
196 kUninitialized = kUndefined, // Cell has never been initialized. | |
197 kInvalidated = kConstant, // Cell has been deleted or invalidated. | |
198 | |
199 // For dictionaries not holding cells. | |
200 kNoCell = kMutable, | |
201 }; | 195 }; |
202 | 196 |
203 | 197 |
204 enum class PropertyCellConstantType { | |
205 kSmi, | |
206 kStableMap, | |
207 }; | |
208 | |
209 | |
210 // PropertyDetails captures type and attributes for a property. | 198 // PropertyDetails captures type and attributes for a property. |
211 // They are used both in property dictionaries and instance descriptors. | 199 // They are used both in property dictionaries and instance descriptors. |
212 class PropertyDetails BASE_EMBEDDED { | 200 class PropertyDetails BASE_EMBEDDED { |
213 public: | 201 public: |
214 PropertyDetails(PropertyAttributes attributes, PropertyType type, int index, | 202 PropertyDetails(PropertyAttributes attributes, PropertyType type, int index, |
215 PropertyCellType cell_type) { | 203 PropertyCellType cell_type) { |
216 value_ = TypeField::encode(type) | AttributesField::encode(attributes) | | 204 value_ = TypeField::encode(type) | AttributesField::encode(attributes) | |
217 DictionaryStorageField::encode(index) | | 205 DictionaryStorageField::encode(index) | |
218 PropertyCellTypeField::encode(cell_type); | 206 PropertyCellTypeField::encode(cell_type); |
219 | 207 |
(...skipping 14 matching lines...) Expand all Loading... |
234 PropertyDetails(PropertyAttributes attributes, PropertyKind kind, | 222 PropertyDetails(PropertyAttributes attributes, PropertyKind kind, |
235 PropertyLocation location, Representation representation, | 223 PropertyLocation location, Representation representation, |
236 int field_index = 0) { | 224 int field_index = 0) { |
237 value_ = KindField::encode(kind) | LocationField::encode(location) | | 225 value_ = KindField::encode(kind) | LocationField::encode(location) | |
238 AttributesField::encode(attributes) | | 226 AttributesField::encode(attributes) | |
239 RepresentationField::encode(EncodeRepresentation(representation)) | | 227 RepresentationField::encode(EncodeRepresentation(representation)) | |
240 FieldIndexField::encode(field_index); | 228 FieldIndexField::encode(field_index); |
241 } | 229 } |
242 | 230 |
243 static PropertyDetails Empty() { | 231 static PropertyDetails Empty() { |
244 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 232 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kInvalid); |
245 } | 233 } |
246 | 234 |
247 int pointer() const { return DescriptorPointer::decode(value_); } | 235 int pointer() const { return DescriptorPointer::decode(value_); } |
248 | 236 |
249 PropertyDetails set_pointer(int i) const { | 237 PropertyDetails set_pointer(int i) const { |
250 return PropertyDetails(value_, i); | 238 return PropertyDetails(value_, i); |
251 } | 239 } |
252 | 240 |
253 PropertyDetails set_cell_type(PropertyCellType type) const { | 241 PropertyDetails set_cell_type(PropertyCellType type) const { |
254 PropertyDetails details = *this; | 242 PropertyDetails details = *this; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 uint32_t value_; | 353 uint32_t value_; |
366 }; | 354 }; |
367 | 355 |
368 | 356 |
369 std::ostream& operator<<(std::ostream& os, | 357 std::ostream& operator<<(std::ostream& os, |
370 const PropertyAttributes& attributes); | 358 const PropertyAttributes& attributes); |
371 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); | 359 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); |
372 } } // namespace v8::internal | 360 } } // namespace v8::internal |
373 | 361 |
374 #endif // V8_PROPERTY_DETAILS_H_ | 362 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |