aboutsummaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp22
1 files changed, 19 insertions, 3 deletions
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<QString> 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<QString> 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<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();