From 52bc4fbfbae6aa1569dc134dd103e966f04bc2e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Dec 2017 12:44:47 +0100 Subject: Use potentially intercepted URL as ID for compilation units We generally have to pass a URL and a file name everywhere because the logical URL might be something else than the actual file being loaded. For example a QQmlFileSelector might modify the URL to be loaded for a specific file. This resulting URL, however, should not be used to resolve further URLs defined in the file loaded that way. As we need to access QQmlTypeLoader::m_url as string more often now, cache it and avoid frequent translations between QUrl and QString. Furthermore, QQmlDataBlob's URLs are changed to follow the same semantics. The finalUrl is the one that should be used to resolve further URLs, the url is the one used to load the content, and subject to any redirects or interceptions. This changes the semantics of URL redirects. Previously a redirected URL was used as the base URL for furher URL resolution. This doesn't work because redirection occurs after interception and interception should not influence the resolution of further URLs. We now use the original URL as base URL for resolution of further URLs and rely on the server to redirect those, too. Task-number: QTBUG-61209 Change-Id: I93822f820bed2515995de3cb118099218b510ca4 Reviewed-by: Michael Brasser --- tools/qmlcachegen/qmlcachegen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools/qmlcachegen/qmlcachegen.cpp') diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index a62adc82f4..69612eb514 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -180,7 +180,10 @@ static bool compileQmlFile(const QString &inputFileName, const QString &outputFi annotateListElements(&irDocument); { - QmlIR::JSCodeGen v4CodeGen(/*empty input file name*/QString(), irDocument.code, &irDocument.jsModule, &irDocument.jsParserEngine, irDocument.program, /*import cache*/0, &irDocument.jsGenerator.stringTable); + QmlIR::JSCodeGen v4CodeGen(/*empty input file name*/QString(), QString(), irDocument.code, + &irDocument.jsModule, &irDocument.jsParserEngine, + irDocument.program, /*import cache*/0, + &irDocument.jsGenerator.stringTable); for (QmlIR::Object *object: qAsConst(irDocument.objects)) { if (object->functionsAndExpressions->count == 0) continue; @@ -289,8 +292,12 @@ static bool compileJSFile(const QString &inputFileName, const QString &outputFil } { - QmlIR::JSCodeGen v4CodeGen(inputFileName, irDocument.code, &irDocument.jsModule, &irDocument.jsParserEngine, irDocument.program, /*import cache*/0, &irDocument.jsGenerator.stringTable); - v4CodeGen.generateFromProgram(/*empty input file name*/QString(), sourceCode, program, &irDocument.jsModule, QQmlJS::Codegen::GlobalCode); + QmlIR::JSCodeGen v4CodeGen(inputFileName, inputFileName, + irDocument.code, &irDocument.jsModule, + &irDocument.jsParserEngine, irDocument.program, + /*import cache*/0, &irDocument.jsGenerator.stringTable); + v4CodeGen.generateFromProgram(/*empty input file name*/QString(), QString(), sourceCode, + program, &irDocument.jsModule, QQmlJS::Codegen::GlobalCode); QList jsErrors = v4CodeGen.errors(); if (!jsErrors.isEmpty()) { for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) { -- cgit v1.2.3 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/qmlcachegen/qmlcachegen.cpp') 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 From 0c2b18778a5c7f38bcddda0ee5ceb04da540e6d8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 18 Jan 2018 10:31:08 +0100 Subject: Fix illegal name setup in qmlcachegen After commit c2b4c6393fee37e0c6c4a8c5d40d13120cc8a94e we must also initialize the set in order to benefit from the improved lookup on the cache side. Change-Id: I0f66f118b912ed66a281d16caea67500f9c14046 Reviewed-by: Lars Knoll --- tools/qmlcachegen/qmlcachegen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/qmlcachegen/qmlcachegen.cpp') diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index 844cd816bc..8d59a34a28 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -413,6 +413,8 @@ int main(int argc, char **argv) if (parser.isSet(outputFileOption)) outputFileName = parser.value(outputFileOption); + setupIllegalNames(); + const QString targetABI = parser.value(targetABIOption); if (inputFile.endsWith(QLatin1String(".qml"))) { -- cgit v1.2.3