diff options
Diffstat (limited to 'src/property.h')
-rw-r--r-- | src/property.h | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/src/property.h b/src/property.h index 233233c5..ab183d9e 100644 --- a/src/property.h +++ b/src/property.h @@ -18,22 +18,48 @@ namespace internal { // Each descriptor has a key, property attributes, property type, // property index (in the actual instance-descriptor array) and // optionally a piece of data. -class Descriptor BASE_EMBEDDED { +class Descriptor final BASE_EMBEDDED { public: + Descriptor() : details_(Smi::kZero) {} + Handle<Name> GetKey() const { return key_; } Handle<Object> GetValue() const { return value_; } PropertyDetails GetDetails() const { return details_; } void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } + static Descriptor DataField(Handle<Name> key, int field_index, + PropertyAttributes attributes, + Representation representation); + + static Descriptor DataField(Handle<Name> key, int field_index, + PropertyAttributes attributes, + PropertyConstness constness, + Representation representation, + Handle<Object> wrapped_field_type); + + static Descriptor DataConstant(Handle<Name> key, Handle<Object> value, + PropertyAttributes attributes) { + return Descriptor(key, value, kData, attributes, kDescriptor, kConst, + value->OptimalRepresentation(), 0); + } + + static Descriptor DataConstant(Handle<Name> key, int field_index, + Handle<Object> value, + PropertyAttributes attributes); + + static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign, + PropertyAttributes attributes) { + return Descriptor(key, foreign, kAccessor, attributes, kDescriptor, kConst, + Representation::Tagged(), 0); + } + private: Handle<Name> key_; Handle<Object> value_; PropertyDetails details_; protected: - Descriptor() : details_(Smi::kZero) {} - void Init(Handle<Name> key, Handle<Object> value, PropertyDetails details) { DCHECK(key->IsUniqueName()); DCHECK_IMPLIES(key->IsPrivate(), !details.IsEnumerable()); @@ -48,57 +74,23 @@ class Descriptor BASE_EMBEDDED { DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable()); } - Descriptor(Handle<Name> key, Handle<Object> value, - PropertyAttributes attributes, PropertyType type, - Representation representation, int field_index = 0) + Descriptor(Handle<Name> key, Handle<Object> value, PropertyKind kind, + PropertyAttributes attributes, PropertyLocation location, + PropertyConstness constness, Representation representation, + int field_index) : key_(key), value_(value), - details_(attributes, type, representation, field_index) { + details_(kind, attributes, location, constness, representation, + field_index) { DCHECK(key->IsUniqueName()); DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable()); } friend class DescriptorArray; friend class Map; + friend class MapUpdater; }; - -std::ostream& operator<<(std::ostream& os, const Descriptor& d); - - -class DataDescriptor final : public Descriptor { - public: - DataDescriptor(Handle<Name> key, int field_index, - PropertyAttributes attributes, Representation representation); - // The field type is either a simple type or a map wrapped in a weak cell. - DataDescriptor(Handle<Name> key, int field_index, - Handle<Object> wrapped_field_type, - PropertyAttributes attributes, Representation representation) - : Descriptor(key, wrapped_field_type, attributes, DATA, representation, - field_index) { - DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakCell()); - } -}; - - -class DataConstantDescriptor final : public Descriptor { - public: - DataConstantDescriptor(Handle<Name> key, Handle<Object> value, - PropertyAttributes attributes) - : Descriptor(key, value, attributes, DATA_CONSTANT, - value->OptimalRepresentation()) {} -}; - - -class AccessorConstantDescriptor final : public Descriptor { - public: - AccessorConstantDescriptor(Handle<Name> key, Handle<Object> foreign, - PropertyAttributes attributes) - : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT, - Representation::Tagged()) {} -}; - - } // namespace internal } // namespace v8 |