From c2b4c6393fee37e0c6c4a8c5d40d13120cc8a94e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 15 Jan 2018 15:36:25 +0100 Subject: 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 --- tools/qmlcachegen/qmlcachegen.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index 69612eb514..844cd816bc 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -47,6 +47,23 @@ Q_QML_EXPORT QV4::EvalISelFactory *createISelForArchitecture(const QString &arch QT_END_NAMESPACE +QSet illegalNames; + +void setupIllegalNames() +{ + // #### this in incomplete + illegalNames.insert(QStringLiteral("Math")); + illegalNames.insert(QStringLiteral("Array")); + illegalNames.insert(QStringLiteral("String")); + illegalNames.insert(QStringLiteral("Function")); + illegalNames.insert(QStringLiteral("Boolean")); + illegalNames.insert(QStringLiteral("Number")); + illegalNames.insert(QStringLiteral("Date")); + illegalNames.insert(QStringLiteral("RegExp")); + illegalNames.insert(QStringLiteral("Error")); + illegalNames.insert(QStringLiteral("Object")); +} + struct Error { QString message; @@ -165,7 +182,6 @@ static bool compileQmlFile(const QString &inputFileName, const QString &outputFi } { - QSet illegalNames; // #### QmlIR::IRBuilder irBuilder(illegalNames); if (!irBuilder.generateFromQml(sourceCode, inputFileName, &irDocument)) { for (const QQmlJS::DiagnosticMessage &parseError: qAsConst(irBuilder.errors)) { @@ -183,7 +199,7 @@ static bool compileQmlFile(const QString &inputFileName, const QString &outputFi QmlIR::JSCodeGen v4CodeGen(/*empty input file name*/QString(), QString(), irDocument.code, &irDocument.jsModule, &irDocument.jsParserEngine, irDocument.program, /*import cache*/0, - &irDocument.jsGenerator.stringTable); + &irDocument.jsGenerator.stringTable, illegalNames); for (QmlIR::Object *object: qAsConst(irDocument.objects)) { if (object->functionsAndExpressions->count == 0) continue; @@ -295,7 +311,7 @@ static bool compileJSFile(const QString &inputFileName, const QString &outputFil QmlIR::JSCodeGen v4CodeGen(inputFileName, inputFileName, irDocument.code, &irDocument.jsModule, &irDocument.jsParserEngine, irDocument.program, - /*import cache*/0, &irDocument.jsGenerator.stringTable); + /*import cache*/0, &irDocument.jsGenerator.stringTable, illegalNames); v4CodeGen.generateFromProgram(/*empty input file name*/QString(), QString(), sourceCode, program, &irDocument.jsModule, QQmlJS::Codegen::GlobalCode); QList jsErrors = v4CodeGen.errors(); -- cgit v1.2.3