diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-01-08 15:59:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 21:14:24 +0100 |
commit | e2d9917878968986a9df21c9cfafc32a2360aee7 (patch) | |
tree | 24c4009e65b0a358a1d30f36ab32ec546fe6cbe5 /src/qml/jsruntime/qv4property_p.h | |
parent | 2ba2d245c152cdbb26f918bc4481c77b8004f3cd (diff) |
Changes to the structure of Property
Put the getter into the regular value, and the setter into
the next value following. Like this we can compress property
data to only use 8 bytes per property for regular properties
and simply allocate two slots for accessor properties.
Change-Id: I330b95dbd583ebc2658fed79d37ac3b53492c0cd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4property_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4property_p.h | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index ff9ea59514..4b0896b264 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -52,13 +52,8 @@ namespace QV4 { struct FunctionObject; struct Property { - union { - SafeValue value; - struct { - FunctionObject *get; - FunctionObject *set; - }; - }; + SafeValue value; + SafeValue set; // Section 8.10 inline void fullyPopulated(PropertyAttributes *attrs) { @@ -67,10 +62,10 @@ struct Property { } if (attrs->type() == PropertyAttributes::Accessor) { attrs->clearWritable(); - if (get == (FunctionObject *)0x1) - get = 0; - if (set == (FunctionObject *)0x1) - set = 0; + if (value.managed() == (Managed *)0x1) + value = Primitive::fromManaged(0); + if (set.managed() == (Managed *)0x1) + set = Primitive::fromManaged(0); } attrs->resolve(); } @@ -82,8 +77,8 @@ struct Property { } static inline Property fromAccessor(FunctionObject *getter, FunctionObject *setter) { Property pd; - pd.get = getter; - pd.set = setter; + pd.value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter)); + pd.set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter)); return pd; } @@ -96,10 +91,10 @@ struct Property { inline bool isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const; inline void merge(PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs); - inline FunctionObject *getter() const { return get; } - inline FunctionObject *setter() const { return set; } - inline void setGetter(FunctionObject *g) { get = g; } - inline void setSetter(FunctionObject *s) { set = s; } + inline FunctionObject *getter() const { return reinterpret_cast<FunctionObject *>(value.managed()); } + inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.managed()); } + inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); } + inline void setSetter(FunctionObject *s) { set = Primitive::fromManaged(reinterpret_cast<Managed *>(s)); } }; inline bool Property::isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const @@ -115,9 +110,9 @@ inline bool Property::isSubset(const PropertyAttributes &attrs, const Property & if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other.value)) return false; if (attrs.type() == PropertyAttributes::Accessor) { - if (get != other.get) + if (value.managed() != other.value.managed()) return false; - if (set != other.set) + if (set.managed() != other.set.managed()) return false; } return true; @@ -133,10 +128,10 @@ inline void Property::merge(PropertyAttributes &attrs, const Property &other, Pr attrs.setWritable(otherAttrs.isWritable()); if (otherAttrs.type() == PropertyAttributes::Accessor) { attrs.setType(PropertyAttributes::Accessor); - if (other.get) - get = (other.get == (FunctionObject *)0x1) ? 0 : other.get; - if (other.set) - set = (other.set == (FunctionObject *)0x1) ? 0 : other.set; + if (other.value.managed()) + value = (other.value.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.value.asReturnedValue(); + if (other.set.managed()) + set = (other.set.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.set.asReturnedValue(); } else if (otherAttrs.type() == PropertyAttributes::Data){ attrs.setType(PropertyAttributes::Data); value = other.value; |