diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-06-28 11:25:18 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-04 13:29:10 +0000 |
commit | a253824a258c437bf1c8c67aefd6f5f928c9dfd7 (patch) | |
tree | ff393165de35bdddb65134ee199bdd936e9f6c5c /src/qml/jsruntime/qv4function.cpp | |
parent | 0577c9f35628ac2f63e6ce4e6fa73bb4614e29ae (diff) |
Improve releasing of memory allocated from compilation unit strings
Allocate the strings in the compilation unit as regular strings, not as
identifiers. We mark the runtimeStrings in the compilation unit, so when
the unit is released as part of component cache trimming, those strings
can also be collected. The JS object literal class keys have to remain
identifiers though.
However this is just a stop-gap as the real problem is that the
identifier table can be triggered to grow without bounds.
Task-number: QTBUG-61536
Change-Id: I7a2854b7fa9c9953348b5e34a31833f7be67cfbf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 31b57b97e9..f78555dbda 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -44,6 +44,7 @@ #include "qv4engine_p.h" #include "qv4lookup_p.h" #include <private/qv4mm_p.h> +#include <private/qv4identifiertable_p.h> QT_BEGIN_NAMESPACE @@ -57,8 +58,6 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, , codeData(0) , hasQmlDependencies(function->hasQmlDependencies()) { - Q_UNUSED(engine); - internalClass = engine->internalClasses[EngineBase::Class_Empty]; const CompiledData::LEUInt32 *formalsIndices = compiledFunction->formalsTable(); // iterate backwards, so we get the right ordering for duplicate names @@ -81,7 +80,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::LEUInt32 *localsIndices = compiledFunction->localsTable(); for (quint32 i = 0; i < compiledFunction->nLocals; ++i) - internalClass = internalClass->addMember(compilationUnit->runtimeStrings[localsIndices[i]]->identifier, Attr_NotConfigurable); + internalClass = internalClass->addMember(engine->identifierTable->identifier(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); activationRequired = compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject)); @@ -116,7 +115,7 @@ void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArr const CompiledData::LEUInt32 *localsIndices = compiledFunction->localsTable(); for (quint32 i = 0; i < compiledFunction->nLocals; ++i) - internalClass = internalClass->addMember(compilationUnit->runtimeStrings[localsIndices[i]]->identifier, Attr_NotConfigurable); + internalClass = internalClass->addMember(engine->identifierTable->identifier(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); activationRequired = true; } |