From ba6fc15d729304c136447242de2410fbf4f020cd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Oct 2013 16:24:58 +0200 Subject: Speed up id object lookups We can resolve lookups for objects referenced by id at QML compile time and use a run-time helper to extract the id object out of the QML context data by index instead of name. Dependencies to id objects are also tracked at compile time and registered separately before entering the generated function code. The lookup of id objects is encoded in the IR as special member lookups. Members will also then in the future be used to for property lookups in context and scope properties, as well as any other property lookups in QObjects where we can determine the meta-object. Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a Reviewed-by: Lars Knoll --- src/qml/qml/qqmlcompiler.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlcompiler.cpp') diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 57114ebead..0462c0b61a 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -3654,7 +3654,21 @@ bool QQmlCompiler::completeComponentBuild() const QString &sourceCode = jsEngine->code(); AST::UiProgram *qmlRoot = parser.qmlRoot(); - const QVector runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, compileState->functionsToCompile); + JSCodeGen::ObjectIdMapping idMapping; + if (compileState->ids.count() > 0) { + idMapping.reserve(compileState->ids.count()); + for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) { + JSCodeGen::IdMapping m; + m.name = o->id; + m.idIndex = o->idIndex; + idMapping << m; + } + } + + const QVector runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, + qmlRoot, compileState->root->astNode, + compileState->functionsToCompile, + idMapping); compileState->runtimeFunctionIndices = runtimeFunctionIndices; for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { -- cgit v1.2.3