From 32a1d14a3a1dead69dd1306adf70eefd3415639e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 16 May 2017 15:29:17 +0200 Subject: Optimize marking of prototypes in the InternalClass tree There's no need to iterate over all internal classes, as prototype changes always happen in the first or second level of the tree. Change-Id: I99bf11a6cd238286c1547922d61ab47319b6eb97 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4internalclass.cpp | 32 ++++++++++++++++---------------- src/qml/jsruntime/qv4internalclass_p.h | 1 - 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 9f43871f27..0bcd510541 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -506,25 +506,25 @@ void InternalClass::destroy() } } -void InternalClass::mark(ExecutionEngine *e) -{ - if (m_sealed) - m_sealed->mark(e); - if (m_frozen) - m_frozen->mark(e); - - for (size_t i = 0; i < transitions.size(); ++i) { - Q_ASSERT(transitions.at(i).lookup); - transitions.at(i).lookup->mark(e); - } - if (prototype) - prototype->mark(engine); -} - void InternalClassPool::markObjects(ExecutionEngine *engine) { InternalClass *ic = engine->internalClasses[EngineBase::Class_Empty]; - ic->mark(engine); + Q_ASSERT(!ic->prototype); + + // only need to go two levels into the IC hierarchy, as prototype changes + // can only happen there + for (auto &t : ic->transitions) { + Q_ASSERT(t.lookup); + if (t.flags == InternalClassTransition::VTableChange) { + InternalClass *ic2 = t.lookup; + for (auto &t2 : ic2->transitions) { + if (t2.flags == InternalClassTransition::PrototypeChange) + t2.lookup->prototype->mark(engine); + } + } else if (t.flags == InternalClassTransition::PrototypeChange) { + t.lookup->prototype->mark(engine); + } + } } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 34422098d9..9e8ab9e73e 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -293,7 +293,6 @@ struct InternalClass : public QQmlJS::Managed { Q_REQUIRED_RESULT InternalClass *propertiesFrozen() const; void destroy(); - void mark(ExecutionEngine *e); private: Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt); -- cgit v1.2.3