diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-01-10 14:16:22 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-12 13:59:17 +0000 |
commit | 6c8c604f11e7a6d5880e4f951255d496fe905797 (patch) | |
tree | 117050abfb2164d45575ee1bfd35de46ddf224b2 /src/qml/jsruntime/qv4lookup_p.h | |
parent | 6b110a30df178b2aaace579841e5bd74f2e9ee99 (diff) |
Reorganize Lookup data structure to make marking faster
Do this by always using odd numbers for protoId's, and
putting those into the same place as the InternalClass
pointers. That makes it possible to quickly check whether
the lookup contains a pointer to a valid heap object.
Change-Id: I330017b26c090b4dcbbcce1a127dca7ba7e148d1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4lookup_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4lookup_p.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index 75219d1b84..49eb66d1fb 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -65,7 +65,6 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct Lookup { - enum { Size = 4 }; union { ReturnedValue (*getter)(Lookup *l, ExecutionEngine *engine, const Value &object); ReturnedValue (*globalGetter)(Lookup *l, ExecutionEngine *engine); @@ -73,12 +72,20 @@ struct Lookup { }; union { struct { + Heap::Base *h1; + Heap::Base *h2; + quintptr unused; + quintptr unused2; + } markDef; + struct { Heap::InternalClass *ic; + quintptr _unused; int offset; } objectLookup; struct { + quintptr protoId; + quintptr _unused; const Value *data; - int protoId; } protoLookup; struct { Heap::InternalClass *ic; @@ -87,21 +94,21 @@ struct Lookup { int offset2; } objectLookupTwoClasses; struct { + quintptr protoId; + quintptr protoId2; const Value *data; const Value *data2; - int protoId; - int protoId2; } protoLookupTwoClasses; struct { // Make sure the next two values are in sync with protoLookup - const Value *data; - int protoId; - unsigned type; + quintptr protoId; Heap::Object *proto; + const Value *data; + quintptr type; } primitiveLookup; struct { Heap::InternalClass *newClass; - int protoId; + quintptr protoId; int offset; } insertionLookup; }; @@ -145,7 +152,16 @@ struct Lookup { static bool setterInsert(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static bool arrayLengthSetter(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); - void markObjects(MarkStack *stack); + void markObjects(MarkStack *stack) { + if (markDef.h1 && !(reinterpret_cast<quintptr>(markDef.h1) & 1)) + markDef.h1->mark(stack); + if (markDef.h2 && !(reinterpret_cast<quintptr>(markDef.h2) & 1)) + markDef.h2->mark(stack); + } + + void clear() { + memset(&markDef, 0, sizeof(markDef)); + } }; Q_STATIC_ASSERT(std::is_standard_layout<Lookup>::value); |