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

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: cleanup 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
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
233 static PropertyDetails Empty() {
234 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kInvalid);
235 }
236
224 int pointer() const { return DescriptorPointer::decode(value_); } 237 int pointer() const { return DescriptorPointer::decode(value_); }
225 238
226 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } 239 PropertyDetails set_pointer(int i) const {
240 return PropertyDetails(value_, i);
241 }
242
243 PropertyDetails set_cell_type(PropertyCellType type) const {
244 PropertyDetails details = *this;
245 details.value_ = PropertyCellTypeField::update(details.value_, type);
246 return details;
247 }
248
249 PropertyDetails set_index(int index) const {
250 PropertyDetails details = *this;
251 details.value_ = DictionaryStorageField::update(details.value_, index);
252 return details;
253 }
227 254
228 PropertyDetails CopyWithRepresentation(Representation representation) const { 255 PropertyDetails CopyWithRepresentation(Representation representation) const {
229 return PropertyDetails(value_, representation); 256 return PropertyDetails(value_, representation);
230 } 257 }
231 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { 258 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) const {
232 new_attributes = 259 new_attributes =
233 static_cast<PropertyAttributes>(attributes() | new_attributes); 260 static_cast<PropertyAttributes>(attributes() | new_attributes);
234 return PropertyDetails(value_, new_attributes); 261 return PropertyDetails(value_, new_attributes);
235 } 262 }
236 263
237 // Conversion for storing details as Object*. 264 // Conversion for storing details as Object*.
238 explicit inline PropertyDetails(Smi* smi); 265 explicit inline PropertyDetails(Smi* smi);
239 inline Smi* AsSmi() const; 266 inline Smi* AsSmi() const;
240 267
241 static uint8_t EncodeRepresentation(Representation representation) { 268 static uint8_t EncodeRepresentation(Representation representation) {
(...skipping 25 matching lines...) Expand all
267 294
268 inline int field_width_in_words() const; 295 inline int field_width_in_words() const;
269 296
270 static bool IsValidIndex(int index) { 297 static bool IsValidIndex(int index) {
271 return DictionaryStorageField::is_valid(index); 298 return DictionaryStorageField::is_valid(index);
272 } 299 }
273 300
274 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 301 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
275 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } 302 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
276 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 303 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
304 PropertyCellType cell_type() const {
305 return PropertyCellTypeField::decode(value_);
306 }
277 307
278 // Bit fields in value_ (type, shift, size). Must be public so the 308 // Bit fields in value_ (type, shift, size). Must be public so the
279 // constants can be embedded in generated code. 309 // constants can be embedded in generated code.
280 class KindField : public BitField<PropertyKind, 0, 1> {}; 310 class KindField : public BitField<PropertyKind, 0, 1> {};
281 class LocationField : public BitField<PropertyLocation, 1, 1> {}; 311 class LocationField : public BitField<PropertyLocation, 1, 1> {};
282 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; 312 class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
283 313
284 // Bit fields for normalized objects. 314 // Bit fields for normalized objects.
285 class DictionaryStorageField : public BitField<uint32_t, 5, 24> {}; 315 class PropertyCellTypeField : public BitField<PropertyCellType, 5, 2> {};
316 class DictionaryStorageField : public BitField<uint32_t, 7, 24> {};
286 317
287 // Bit fields for fast objects. 318 // Bit fields for fast objects.
288 class RepresentationField : public BitField<uint32_t, 5, 4> {}; 319 class RepresentationField : public BitField<uint32_t, 5, 4> {};
289 class DescriptorPointer 320 class DescriptorPointer
290 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT 321 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT
291 class FieldIndexField 322 class FieldIndexField
292 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, 323 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount,
293 kDescriptorIndexBitCount> {}; // NOLINT 324 kDescriptorIndexBitCount> {}; // NOLINT
294 325
295 // NOTE: TypeField overlaps with KindField and LocationField. 326 // NOTE: TypeField overlaps with KindField and LocationField.
(...skipping 28 matching lines...) Expand all
324 uint32_t value_; 355 uint32_t value_;
325 }; 356 };
326 357
327 358
328 std::ostream& operator<<(std::ostream& os, 359 std::ostream& operator<<(std::ostream& os,
329 const PropertyAttributes& attributes); 360 const PropertyAttributes& attributes);
330 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); 361 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
331 } } // namespace v8::internal 362 } } // namespace v8::internal
332 363
333 #endif // V8_PROPERTY_DETAILS_H_ 364 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698