From 080a5c705aa9c04a332c2f95a216853b098d9d6b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 4 Oct 2017 17:21:44 +0200 Subject: QV4Engine: Don't cache compilation units to be unlinked A compilation unit that is unlinked may recursively unlink and delete further compilation units belonging to the same engine via its resolvedTypes property. Those units won't be able to remove themselves from the cached set, and will therefore get their unlink() method called again, this time on a dangling pointer, when the engine gets around to them. Change-Id: Icaa941ca2117c8303c49623b2be0f9014502d849 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/qml/jsruntime/qv4engine.cpp') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 54011e6bd2..34336e3c87 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -478,10 +478,8 @@ ExecutionEngine::~ExecutionEngine() delete identifierTable; delete memoryManager; - QSet remainingUnits; - qSwap(compilationUnits, remainingUnits); - for (QV4::CompiledData::CompilationUnit *unit : qAsConst(remainingUnits)) - unit->unlink(); + while (!compilationUnits.isEmpty()) + (*compilationUnits.begin())->unlink(); internalClasses[Class_Empty]->destroy(); delete classPool; -- cgit v1.2.3 From 55ecfd409ca6aa8018be8cc2697b27928fbd4cc2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 5 Oct 2017 11:02:36 +0200 Subject: Simplify compilation unit tracking in the execution engine Instead of collecting all compilation units in a hash, let's collect linked units in a doubly-linked lists that makes the removal at destruction time dramatically cheaper. Change-Id: I9fd59600d082be3566f605d90f14a86a58ac9296 Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4engine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4engine.cpp') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 34336e3c87..917f6bffc5 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -951,9 +951,8 @@ void ExecutionEngine::markObjects() drainMarkStack(this, markBase); - for (QSet::ConstIterator it = compilationUnits.constBegin(), end = compilationUnits.constEnd(); - it != end; ++it) { - (*it)->markObjects(this); + for (auto compilationUnit: compilationUnits) { + compilationUnit->markObjects(this); drainMarkStack(this, markBase); } } -- cgit v1.2.3