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

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

Issue 786193004: PropertyType is divided into PropertyKind and PropertyStoreMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 6 years 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/mirror-debugger.js ('k') | src/serialize.h » ('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 23 matching lines...) Expand all
34 namespace v8 { 34 namespace v8 {
35 namespace internal { 35 namespace internal {
36 36
37 class Smi; 37 class Smi;
38 template<class> class TypeImpl; 38 template<class> class TypeImpl;
39 struct ZoneTypeConfig; 39 struct ZoneTypeConfig;
40 typedef TypeImpl<ZoneTypeConfig> Type; 40 typedef TypeImpl<ZoneTypeConfig> Type;
41 class TypeInfo; 41 class TypeInfo;
42 42
43 // Type of properties. 43 // Type of properties.
44 // Order of kinds is significant.
45 // Must fit in the BitField PropertyDetails::KindField.
46 enum PropertyKind { DATA = 0, ACCESSOR = 1 };
47
48
49 // Order of modes is significant.
50 // Must fit in the BitField PropertyDetails::StoreModeField.
51 enum PropertyLocation { IN_OBJECT = 0, IN_DESCRIPTOR = 1 };
52
53
44 // Order of properties is significant. 54 // Order of properties is significant.
45 // Must fit in the BitField PropertyDetails::TypeField. 55 // Must fit in the BitField PropertyDetails::TypeField.
46 // A copy of this is in mirror-debugger.js. 56 // A copy of this is in mirror-debugger.js.
47 enum PropertyType { FIELD = 0, CONSTANT = 1, CALLBACKS = 2 }; 57 enum PropertyType {
58 FIELD = (IN_OBJECT << 1) | DATA,
59 CONSTANT = (IN_DESCRIPTOR << 1) | DATA,
60 CALLBACKS = (IN_DESCRIPTOR << 1) | ACCESSOR
61 };
48 62
49 63
50 class Representation { 64 class Representation {
51 public: 65 public:
52 enum Kind { 66 enum Kind {
53 kNone, 67 kNone,
54 kInteger8, 68 kInteger8,
55 kUInteger8, 69 kUInteger8,
56 kInteger16, 70 kInteger16,
57 kUInteger16, 71 kUInteger16,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 inline Smi* AsSmi() const; 229 inline Smi* AsSmi() const;
216 230
217 static uint8_t EncodeRepresentation(Representation representation) { 231 static uint8_t EncodeRepresentation(Representation representation) {
218 return representation.kind(); 232 return representation.kind();
219 } 233 }
220 234
221 static Representation DecodeRepresentation(uint32_t bits) { 235 static Representation DecodeRepresentation(uint32_t bits) {
222 return Representation::FromKind(static_cast<Representation::Kind>(bits)); 236 return Representation::FromKind(static_cast<Representation::Kind>(bits));
223 } 237 }
224 238
239 PropertyKind kind() const { return KindField::decode(value_); }
240 PropertyLocation location() const { return LocationField::decode(value_); }
241
225 PropertyType type() const { return TypeField::decode(value_); } 242 PropertyType type() const { return TypeField::decode(value_); }
226 243
227 PropertyAttributes attributes() const { 244 PropertyAttributes attributes() const {
228 return AttributesField::decode(value_); 245 return AttributesField::decode(value_);
229 } 246 }
230 247
231 int dictionary_index() const { 248 int dictionary_index() const {
232 return DictionaryStorageField::decode(value_); 249 return DictionaryStorageField::decode(value_);
233 } 250 }
234 251
(...skipping 11 matching lines...) Expand all
246 return DictionaryStorageField::is_valid(index); 263 return DictionaryStorageField::is_valid(index);
247 } 264 }
248 265
249 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 266 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
250 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } 267 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
251 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 268 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
252 bool IsDeleted() const { return DeletedField::decode(value_) != 0; } 269 bool IsDeleted() const { return DeletedField::decode(value_) != 0; }
253 270
254 // Bit fields in value_ (type, shift, size). Must be public so the 271 // Bit fields in value_ (type, shift, size). Must be public so the
255 // constants can be embedded in generated code. 272 // constants can be embedded in generated code.
256 class TypeField : public BitField<PropertyType, 0, 2> {}; 273 class KindField : public BitField<PropertyKind, 0, 1> {};
274 class LocationField : public BitField<PropertyLocation, 1, 1> {};
257 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; 275 class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
258 276
259 // Bit fields for normalized objects. 277 // Bit fields for normalized objects.
260 class DeletedField : public BitField<uint32_t, 5, 1> {}; 278 class DeletedField : public BitField<uint32_t, 5, 1> {};
261 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {}; 279 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {};
262 280
263 // Bit fields for fast objects. 281 // Bit fields for fast objects.
264 class RepresentationField : public BitField<uint32_t, 5, 4> {}; 282 class RepresentationField : public BitField<uint32_t, 5, 4> {};
265 class DescriptorPointer 283 class DescriptorPointer
266 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT 284 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT
267 class FieldIndexField 285 class FieldIndexField
268 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, 286 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount,
269 kDescriptorIndexBitCount> {}; // NOLINT 287 kDescriptorIndexBitCount> {}; // NOLINT
270 288
289 // NOTE: TypeField overlaps with KindField and LocationField.
290 class TypeField : public BitField<PropertyType, 0, 2> {};
291 STATIC_ASSERT(KindField::kNext == LocationField::kShift);
292 STATIC_ASSERT(TypeField::kShift == KindField::kShift);
293 STATIC_ASSERT(TypeField::kNext == LocationField::kNext);
294
271 // All bits for both fast and slow objects must fit in a smi. 295 // All bits for both fast and slow objects must fit in a smi.
272 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); 296 STATIC_ASSERT(DictionaryStorageField::kNext <= 31);
273 STATIC_ASSERT(FieldIndexField::kNext <= 31); 297 STATIC_ASSERT(FieldIndexField::kNext <= 31);
274 298
275 static const int kInitialIndex = 1; 299 static const int kInitialIndex = 1;
276 300
277 #ifdef OBJECT_PRINT 301 #ifdef OBJECT_PRINT
278 // For our gdb macros, we should perhaps change these in the future. 302 // For our gdb macros, we should perhaps change these in the future.
279 void Print(bool dictionary_mode); 303 void Print(bool dictionary_mode);
280 #endif 304 #endif
(...skipping 13 matching lines...) Expand all
294 uint32_t value_; 318 uint32_t value_;
295 }; 319 };
296 320
297 321
298 std::ostream& operator<<(std::ostream& os, 322 std::ostream& operator<<(std::ostream& os,
299 const PropertyAttributes& attributes); 323 const PropertyAttributes& attributes);
300 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); 324 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
301 } } // namespace v8::internal 325 } } // namespace v8::internal
302 326
303 #endif // V8_PROPERTY_DETAILS_H_ 327 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/serialize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698