diff options
Diffstat (limited to 'deps/v8/src/property.h')
-rw-r--r-- | deps/v8/src/property.h | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/deps/v8/src/property.h b/deps/v8/src/property.h index 233233c5d4..177f06b769 100644 --- a/deps/v8/src/property.h +++ b/deps/v8/src/property.h @@ -18,22 +18,47 @@ 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, + Handle<Object> wrapped_field_type, + PropertyAttributes attributes, + Representation representation) { + DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakCell()); + return Descriptor(key, wrapped_field_type, kData, attributes, kField, + representation, field_index); + } + + static Descriptor DataConstant(Handle<Name> key, Handle<Object> value, + PropertyAttributes attributes) { + return Descriptor(key, value, kData, attributes, kDescriptor, + value->OptimalRepresentation()); + } + + static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign, + PropertyAttributes attributes) { + return Descriptor(key, foreign, kAccessor, attributes, kDescriptor, + Representation::Tagged()); + } + 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 +73,21 @@ class Descriptor BASE_EMBEDDED { DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable()); } - Descriptor(Handle<Name> key, Handle<Object> value, - PropertyAttributes attributes, PropertyType type, + Descriptor(Handle<Name> key, Handle<Object> value, PropertyKind kind, + PropertyAttributes attributes, PropertyLocation location, Representation representation, int field_index = 0) : key_(key), value_(value), - details_(attributes, type, representation, field_index) { + details_(kind, attributes, location, 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 |