aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2022-02-16 16:34:56 +0100
committerUlf Hermann <[email protected]>2022-03-09 12:40:06 +0100
commit9ee2df1e3b648d706805ef1e32c853c19d27e1a2 (patch)
tree67795bace9e2ad26d9c4c1f176423e8b313ba794 /src/qmlcompiler/qqmljsstoragegeneralizer.cpp
parente86019ecbddd76d6551a18595ef9dcff8560f1d4 (diff)
QmlCompiler: Add basic block analysis pass
This basic block analysis pass uses the tracked types to determine dead stores. This is better than the one we already have in the code generator because it also tracks dead stores through renames and it allows removal of lookup results. Furthermore, it adjusts each store to write the type most favorable to its readers. This avoids unnecessary conversions at run time. It cannot replace the other dead store elimination, yet, because it doesn't see whether the results of rename operations are read after the rename. This capability will be added in a separate change that also tracks the register numbers. Once this is in place, we can delete the other basic blocks pass. Task-number: QTBUG-100157 Change-Id: I766c919412b6cf43befa7bdb1a6e5e11b41fe55b Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qmlcompiler/qqmljsstoragegeneralizer.cpp')
-rw-r--r--src/qmlcompiler/qqmljsstoragegeneralizer.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
index 889150f2dd..ce07a333d5 100644
--- a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
+++ b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
@@ -61,38 +61,25 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSStorageGeneralizer::run(
}
}
- const auto transformRegister = [&](QQmlJSRegisterContent &content, int offset) {
- if (QQmlJSScope::ConstPtr specific = content.storedType()) {
- if (QQmlJSScope::ConstPtr generic = m_typeResolver->genericType(specific)) {
- content = content.storedIn(generic);
- } else {
- setError(QStringLiteral("Cannot store the register type %1.")
- .arg(specific->internalName()), offset);
- return false;
- }
- }
- return true;
+ const auto transformRegister = [&](QQmlJSRegisterContent &content) {
+ if (const QQmlJSScope::ConstPtr &specific = content.storedType())
+ m_typeResolver->generalizeType(specific);
};
const auto transformRegisters
- = [&](QFlatMap<int, QQmlJSRegisterContent> &registers, int offset) {
- for (auto j = registers.begin(), jEnd = registers.end(); j != jEnd; ++j) {
- if (!transformRegister(j.value(), offset))
- return false;
- }
- return true;
+ = [&](QFlatMap<int, QQmlJSRegisterContent> &registers) {
+ for (auto j = registers.begin(), jEnd = registers.end(); j != jEnd; ++j)
+ transformRegister(j.value());
};
for (QQmlJSRegisterContent &argument : function->argumentTypes) {
Q_ASSERT(argument.isValid());
- transformRegister(argument, 0);
+ transformRegister(argument);
}
for (auto i = annotations.begin(), iEnd = annotations.end(); i != iEnd; ++i) {
- if (!transformRegister(i->second.changedRegister, i.key()))
- return InstructionAnnotations();
- if (!transformRegisters(i->second.typeConversions, i.key()))
- return InstructionAnnotations();
+ transformRegister(i->second.changedRegister);
+ transformRegisters(i->second.typeConversions);
}
return annotations;