Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/property-details.h

Issue 996133002: correctly invalidate global cells (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: weak cell check Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
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 {
191 kUninitialized, // Cell is deleted or not yet defined.
192 kUndefined, // The PREMONOMORPHIC of property cells.
193 kConstant, // Cell has been assigned only once.
194 kMutable, // Cell will no longer be tracked as constant.
195 kDeleted = kConstant, // like kUninitialized, but for cells already deleted.
196 kInvalid = kMutable, // For dictionaries not holding cells.
197 };
198
199
190 // PropertyDetails captures type and attributes for a property. 200 // PropertyDetails captures type and attributes for a property.
191 // They are used both in property dictionaries and instance descriptors. 201 // They are used both in property dictionaries and instance descriptors.
192 class PropertyDetails BASE_EMBEDDED { 202 class PropertyDetails BASE_EMBEDDED {
193 public: 203 public:
194 PropertyDetails(PropertyAttributes attributes, 204 PropertyDetails(PropertyAttributes attributes, PropertyType type, int index,
195 PropertyType type, 205 PropertyCellType cell_type) {
196 int index) { 206 value_ = TypeField::encode(type) | AttributesField::encode(attributes) |
197 value_ = TypeField::encode(type) 207 DictionaryStorageField::encode(index) |
198 | AttributesField::encode(attributes) 208 PropertyCellTypeField::encode(cell_type);
199 | DictionaryStorageField::encode(index);
200 209
201 DCHECK(type == this->type()); 210 DCHECK(type == this->type());
202 DCHECK(attributes == this->attributes()); 211 DCHECK(attributes == this->attributes());
203 } 212 }
204 213
205 PropertyDetails(PropertyAttributes attributes, 214 PropertyDetails(PropertyAttributes attributes,
206 PropertyType type, 215 PropertyType type,
207 Representation representation, 216 Representation representation,
208 int field_index = 0) { 217 int field_index = 0) {
209 value_ = TypeField::encode(type) 218 value_ = TypeField::encode(type)
210 | AttributesField::encode(attributes) 219 | AttributesField::encode(attributes)
211 | RepresentationField::encode(EncodeRepresentation(representation)) 220 | RepresentationField::encode(EncodeRepresentation(representation))
212 | FieldIndexField::encode(field_index); 221 | FieldIndexField::encode(field_index);
213 } 222 }
214 223
215 PropertyDetails(PropertyAttributes attributes, PropertyKind kind, 224 PropertyDetails(PropertyAttributes attributes, PropertyKind kind,
216 PropertyLocation location, Representation representation, 225 PropertyLocation location, Representation representation,
217 int field_index = 0) { 226 int field_index = 0) {
218 value_ = KindField::encode(kind) | LocationField::encode(location) | 227 value_ = KindField::encode(kind) | LocationField::encode(location) |
219 AttributesField::encode(attributes) | 228 AttributesField::encode(attributes) |
220 RepresentationField::encode(EncodeRepresentation(representation)) | 229 RepresentationField::encode(EncodeRepresentation(representation)) |
221 FieldIndexField::encode(field_index); 230 FieldIndexField::encode(field_index);
222 } 231 }
223 232
224 int pointer() const { return DescriptorPointer::decode(value_); } 233 int pointer() const { return DescriptorPointer::decode(value_); }
225 234
226 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } 235 PropertyDetails set_pointer(int i) const {
236 return PropertyDetails(value_, i);
237 }
238
239 PropertyDetails set_cell_type(PropertyCellType type) const {
240 PropertyDetails details = *this;
241 details.value_ = PropertyCellTypeField::update(details.value_, type);
242 return details;
243 }
244
245 PropertyDetails set_index(int index) const {
246 PropertyDetails details = *this;
247 details.value_ = DictionaryStorageField::update(details.value_, index);
248 return details;
249 }
227 250
228 PropertyDetails CopyWithRepresentation(Representation representation) const { 251 PropertyDetails CopyWithRepresentation(Representation representation) const {
229 return PropertyDetails(value_, representation); 252 return PropertyDetails(value_, representation);
230 } 253 }
231 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { 254 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) const {
232 new_attributes = 255 new_attributes =
233 static_cast<PropertyAttributes>(attributes() | new_attributes); 256 static_cast<PropertyAttributes>(attributes() | new_attributes);
234 return PropertyDetails(value_, new_attributes); 257 return PropertyDetails(value_, new_attributes);
235 } 258 }
236 259
237 // Conversion for storing details as Object*. 260 // Conversion for storing details as Object*.
238 explicit inline PropertyDetails(Smi* smi); 261 explicit inline PropertyDetails(Smi* smi);
239 inline Smi* AsSmi() const; 262 inline Smi* AsSmi() const;
240 263
241 static uint8_t EncodeRepresentation(Representation representation) { 264 static uint8_t EncodeRepresentation(Representation representation) {
(...skipping 25 matching lines...) Expand all
267 290
268 inline int field_width_in_words() const; 291 inline int field_width_in_words() const;
269 292
270 static bool IsValidIndex(int index) { 293 static bool IsValidIndex(int index) {
271 return DictionaryStorageField::is_valid(index); 294 return DictionaryStorageField::is_valid(index);
272 } 295 }
273 296
274 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 297 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
275 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } 298 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
276 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 299 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
300 PropertyCellType cell_type() const {
301 return PropertyCellTypeField::decode(value_);
302 }
277 303
278 // Bit fields in value_ (type, shift, size). Must be public so the 304 // Bit fields in value_ (type, shift, size). Must be public so the
279 // constants can be embedded in generated code. 305 // constants can be embedded in generated code.
280 class KindField : public BitField<PropertyKind, 0, 1> {}; 306 class KindField : public BitField<PropertyKind, 0, 1> {};
281 class LocationField : public BitField<PropertyLocation, 1, 1> {}; 307 class LocationField : public BitField<PropertyLocation, 1, 1> {};
282 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; 308 class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
283 309
284 // Bit fields for normalized objects. 310 // Bit fields for normalized objects.
285 class DictionaryStorageField : public BitField<uint32_t, 5, 24> {}; 311 class PropertyCellTypeField : public BitField<PropertyCellType, 5, 2> {};
312 class DictionaryStorageField : public BitField<uint32_t, 7, 24> {};
286 313
287 // Bit fields for fast objects. 314 // Bit fields for fast objects.
288 class RepresentationField : public BitField<uint32_t, 5, 4> {}; 315 class RepresentationField : public BitField<uint32_t, 5, 4> {};
289 class DescriptorPointer 316 class DescriptorPointer
290 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT 317 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT
291 class FieldIndexField 318 class FieldIndexField
292 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, 319 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount,
293 kDescriptorIndexBitCount> {}; // NOLINT 320 kDescriptorIndexBitCount> {}; // NOLINT
294 321
295 // NOTE: TypeField overlaps with KindField and LocationField. 322 // NOTE: TypeField overlaps with KindField and LocationField.
(...skipping 28 matching lines...) Expand all
324 uint32_t value_; 351 uint32_t value_;
325 }; 352 };
326 353
327 354
328 std::ostream& operator<<(std::ostream& os, 355 std::ostream& operator<<(std::ostream& os,
329 const PropertyAttributes& attributes); 356 const PropertyAttributes& attributes);
330 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); 357 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
331 } } // namespace v8::internal 358 } } // namespace v8::internal
332 359
333 #endif // V8_PROPERTY_DETAILS_H_ 360 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/objects-inl.h ('k') | src/runtime/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698