aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-01-15 15:36:25 +0100
committerLars Knoll <lars.knoll@qt.io>2018-01-17 09:20:59 +0000
commitc2b4c6393fee37e0c6c4a8c5d40d13120cc8a94e (patch)
tree1e3454e819e248337ad460b0db6a7a7239882523 /src/qml/compiler/qqmlirbuilder.cpp
parentc2d0693ca99171ebeb8f35423f29562b0d26c6c0 (diff)
Use a more optimized lookup for global properties
Force the use of a global lookup if we know that the property can and will be found in the global object. This is possible, as the global object is frozen in QML mode and can't be overwritten. Shaves of .5% on the delegates_item_states benchmark, and will significantly speed up all accesses to e.g. the Math object. Change-Id: Ia1e248781a13ebaeb8bc43652e53a6fdde336d0d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 3974f9ae4e..9749324060 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1555,7 +1555,7 @@ char *QmlUnitGenerator::writeBindings(char *bindingPtr, const Object *o, Binding
JSCodeGen::JSCodeGen(const QString &fileName, const QString &finalUrl, const QString &sourceCode,
QV4::IR::Module *jsModule, QQmlJS::Engine *jsEngine,
QQmlJS::AST::UiProgram *qmlRoot, QQmlTypeNameCache *imports,
- const QV4::Compiler::StringTableGenerator *stringPool)
+ const QV4::Compiler::StringTableGenerator *stringPool, const QSet<QString> &globalNames)
: QQmlJS::Codegen(/*strict mode*/false)
, sourceCode(sourceCode)
, jsEngine(jsEngine)
@@ -1567,6 +1567,7 @@ JSCodeGen::JSCodeGen(const QString &fileName, const QString &finalUrl, const QSt
, _scopeObject(0)
, _qmlContextTemp(-1)
, _importedScriptsTemp(-1)
+ , m_globalNames(globalNames)
{
_module = jsModule;
_module->setFileName(fileName);
@@ -2010,6 +2011,9 @@ QV4::IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int
}
}
+ if (m_globalNames.contains(name))
+ return _block->GLOBALNAME(name, line, col, /*forceLookup =*/ true);
+
#else
Q_UNUSED(name)
#endif // V4_BOOTSTRAP