aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscompiler.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-03-19 10:24:02 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-03-19 23:44:07 +0100
commite1632d851bdece1e74653ddd0a03d5ca12c214ab (patch)
tree74f2f6fa2dab7d63955ef85813eeff28fb366769 /src/qmlcompiler/qqmljscompiler.cpp
parentbcbd57d2a16219747c0f6165728c5af7789fc303 (diff)
QmlCompiler: Pass further information about the IR to AOT compilers
Without access to the JSCodeGen and the contexts for functions and bindings, the AOT compiler is forced to re-generate the byte code for each function. Also filter out object bindings. The AOT compiler cannot generate anything sensible for those. Change-Id: I415ed23791dc220918cdf6d49e9ef5d005796239 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljscompiler.cpp')
-rw-r--r--src/qmlcompiler/qqmljscompiler.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp
index bf5330a6b8..697044fdcf 100644
--- a/src/qmlcompiler/qqmljscompiler.cpp
+++ b/src/qmlcompiler/qqmljscompiler.cpp
@@ -232,7 +232,7 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName,
QmlIR::JSCodeGen v4CodeGen(&irDocument, *illegalNames());
if (aotCompiler)
- aotCompiler->setDocument(&irDocument);
+ aotCompiler->setDocument(&v4CodeGen, &irDocument);
QHash<QmlIR::Object *, QmlIR::Object *> effectiveScopes;
for (QmlIR::Object *object: qAsConst(irDocument.objects)) {
@@ -276,6 +276,7 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName,
std::for_each(bindingsAndFunctions.begin(), bindingsAndFunctions.end(),
[&](const BindingOrFunction &bindingOrFunction) {
std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> result;
+ auto *module = v4CodeGen.module();
if (const auto *binding = bindingOrFunction.binding()) {
switch (binding->type) {
case QmlIR::Binding::Type_AttachedProperty:
@@ -287,18 +288,33 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName,
case QmlIR::Binding::Type_Number:
case QmlIR::Binding::Type_String:
case QmlIR::Binding::Type_Null:
+ case QmlIR::Binding::Type_Object:
return;
default:
break;
}
+ Q_ASSERT(functionsToCompile.length() > binding->value.compiledScriptIndex);
+ auto *node = functionsToCompile[binding->value.compiledScriptIndex].parentNode;
+ Q_ASSERT(node);
+ Q_ASSERT(module->contextMap.contains(node));
+ QV4::Compiler::Context *context = module->contextMap[node];
+ Q_ASSERT(context);
+
qCDebug(lcAotCompiler) << "Compiling binding for property"
<< irDocument.stringAt(binding->propertyNameIndex);
- result = aotCompiler->compileBinding(*binding);
+ result = aotCompiler->compileBinding(context, *binding);
} else if (const auto *function = bindingOrFunction.function()) {
+ Q_ASSERT(functionsToCompile.length() > function->index);
+ auto *node = functionsToCompile[function->index].node;
+ Q_ASSERT(node);
+ Q_ASSERT(module->contextMap.contains(node));
+ QV4::Compiler::Context *context = module->contextMap[node];
+ Q_ASSERT(context);
+
qCDebug(lcAotCompiler) << "Compiling function"
<< irDocument.stringAt(function->nameIndex);
- result = aotCompiler->compileFunction(*function);
+ result = aotCompiler->compileFunction(context, *function);
} else {
Q_UNREACHABLE();
}