diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-11-13 13:31:23 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-27 11:09:50 +0000 |
commit | 71f0bc8ce6244d4544dcd35a62ed8f163bb5b092 (patch) | |
tree | 3ccbb10947222c58a3cb74cdc5b10fb432b0fed3 /src/qml/jsruntime/qv4internalclass_p.h | |
parent | 458daae517b4465fafb315323e9c727f1655764d (diff) |
Add a unique id to InternalClass that describes it's total state
So far the InternalClass only did describe the state of the class
itself, but it wouldn't change if some of the underlying
objects in the prototype chain changed. This now fixes that and
introduces a unique ID that completely describes the state of
the object including all it's prototypes.
This opens up for optimizing lookups down to one branch and a
load, independent of the depth of the value inside the prototype
chain.
Change-Id: I0787e0e4710f2f6703b1d5e35996124b3db2d2da
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index df17074e72..546073dcf5 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -232,7 +232,8 @@ struct InternalClassTransition // range 0-0xff is reserved for attribute changes NotExtensible = 0x100, VTableChange = 0x200, - PrototypeChange = 0x201 + PrototypeChange = 0x201, + ProtoClass = 0x202 }; bool operator==(const InternalClassTransition &other) const @@ -243,6 +244,7 @@ struct InternalClassTransition }; struct InternalClass : public QQmlJS::Managed { + int id = 0; // unique across the engine, gets changed also when proto chain changes ExecutionEngine *engine; const VTable *vtable; Heap::Object *prototype; @@ -260,6 +262,7 @@ struct InternalClass : public QQmlJS::Managed { uint size; bool extensible; + bool isUsedAsProto = false; Q_REQUIRED_RESULT InternalClass *nonExtensible(); Q_REQUIRED_RESULT InternalClass *changeVTable(const VTable *vt) { @@ -293,12 +296,17 @@ struct InternalClass : public QQmlJS::Managed { Q_REQUIRED_RESULT InternalClass *frozen(); Q_REQUIRED_RESULT InternalClass *propertiesFrozen() const; + Q_REQUIRED_RESULT InternalClass *asProtoClass(); + void destroy(); + void updateProtoUsage(Heap::Object *o); + private: Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt); Q_QML_EXPORT InternalClass *changePrototypeImpl(Heap::Object *proto); InternalClass *addMemberImpl(Identifier *identifier, PropertyAttributes data, uint *index); + void updateInternalClassIdRecursive(); friend struct ExecutionEngine; InternalClass(ExecutionEngine *engine); InternalClass(const InternalClass &other); |