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