diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-30 10:29:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 14:32:47 +0200 |
commit | e360eaa02fb1a9baae89b473e2b5e8cc9d1bc609 (patch) | |
tree | 02256b5944400511182d3749d37bb88e5cb4a2a4 /src | |
parent | 729cde55784e17a0e923caa8142cef6918146cd2 (diff) |
Temporarily collect a map of all functions in the engine
At the moment we collect a lot of compilation units (one per binding
expression!), which for long running QML accumulates and creates a horrible
performance when trying to retrieve back traces. There is work in progress
to reduces the number of units down to one per QML file, and then the
fixed sorted QVector might proof to be a more efficient data structure
for the lookups.
But until that code lands, this patch proposes to use a QMap instead for the
time being, that tracks all functions. This brings down the qtquickcontrols
auto-test run from 2.5 minutes to just under a minute on my machine.
Change-Id: I45bf609055877081daa984de90f291a030f2f24f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_masm.cpp | 5 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 9 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 1 |
7 files changed, 33 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index a434f6c0dc..4c1b05b04e 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -133,9 +133,11 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) linkBackendToEngine(engine); +#if 0 runtimeFunctionsSortedByAddress.resize(runtimeFunctions.size()); memcpy(runtimeFunctionsSortedByAddress.data(), runtimeFunctions.data(), runtimeFunctions.size() * sizeof(QV4::Function*)); qSort(runtimeFunctionsSortedByAddress.begin(), runtimeFunctionsSortedByAddress.end(), functionSortHelper); +#endif return runtimeFunctions[data->indexOfRootFunction]; } diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 854df1185b..235202a832 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -330,7 +330,7 @@ struct CompilationUnit QV4::Value *runtimeRegularExpressions; QV4::InternalClass **runtimeClasses; QVector<QV4::Function *> runtimeFunctions; - QVector<QV4::Function *> runtimeFunctionsSortedByAddress; +// QVector<QV4::Function *> runtimeFunctionsSortedByAddress; QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index 22f6c3311a..deb0cd1500 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -67,6 +67,8 @@ using namespace QV4; CompilationUnit::~CompilationUnit() { + foreach (Function *f, runtimeFunctions) + engine->allFunctions.remove(reinterpret_cast<quintptr>(f->code)); UnwindHelper::deregisterFunctions(runtimeFunctions); } @@ -83,6 +85,9 @@ void CompilationUnit::linkBackendToEngine(ExecutionEngine *engine) } UnwindHelper::registerFunctions(runtimeFunctions); + + foreach (Function *f, runtimeFunctions) + engine->allFunctions.insert(reinterpret_cast<quintptr>(f->code), f); } QV4::ExecutableAllocator::ChunkOfPages *CompilationUnit::chunkForFunction(int functionIndex) diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index 37772ca90f..3e7b1911e9 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -1112,6 +1112,12 @@ Param InstructionSelection::getParam(V4IR::Expr *e) { } +CompilationUnit::~CompilationUnit() +{ + foreach (QV4::Function *f, runtimeFunctions) + engine->allFunctions.remove(reinterpret_cast<quintptr>(f->codeData)); +} + void CompilationUnit::linkBackendToEngine(QV4::ExecutionEngine *engine) { runtimeFunctions.resize(data->functionTableSize); @@ -1126,4 +1132,7 @@ void CompilationUnit::linkBackendToEngine(QV4::ExecutionEngine *engine) if (QV4::Debugging::Debugger *debugger = engine->debugger) debugger->setPendingBreakpoints(runtimeFunction); } + + foreach (QV4::Function *f, runtimeFunctions) + engine->allFunctions.insert(reinterpret_cast<quintptr>(f->codeData), f); } diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h index 1b4d8b6d77..43e792ccc7 100644 --- a/src/qml/compiler/qv4isel_moth_p.h +++ b/src/qml/compiler/qv4isel_moth_p.h @@ -58,6 +58,7 @@ class StackSlotAllocator; struct CompilationUnit : public QV4::CompiledData::CompilationUnit { + virtual ~CompilationUnit(); virtual void linkBackendToEngine(QV4::ExecutionEngine *engine); QVector<QByteArray> codeRefs; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b272e69fb0..ca0ea916a3 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -795,6 +795,9 @@ namespace { Function *ExecutionEngine::functionForProgramCounter(quintptr pc) const { + // ### Use this code path instead of the "else" when the number of compilation units went down to + // one per (qml) file. +#if 0 for (QSet<QV4::CompiledData::CompilationUnit*>::ConstIterator unitIt = compilationUnits.constBegin(), unitEnd = compilationUnits.constEnd(); unitIt != unitEnd; ++unitIt) { const QVector<Function*> &functions = (*unitIt)->runtimeFunctionsSortedByAddress; @@ -805,6 +808,17 @@ Function *ExecutionEngine::functionForProgramCounter(quintptr pc) const return *it; } return 0; +#else + QMap<quintptr, Function*>::ConstIterator it = allFunctions.lowerBound(pc); + if (it != allFunctions.begin() && allFunctions.count() > 0) + --it; + if (it == allFunctions.end()) + return 0; + + if (pc < it.key() || pc >= it.key() + (*it)->codeSize) + return 0; + return *it; +#endif } QmlExtensions *ExecutionEngine::qmlExtensions() diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 88cafe5fa0..b793509321 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -206,6 +206,7 @@ struct Q_QML_EXPORT ExecutionEngine String *id_name; QSet<CompiledData::CompilationUnit*> compilationUnits; + QMap<quintptr, QV4::Function*> allFunctions; quint32 m_engineId; |