diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-02-16 15:12:26 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-02-25 14:08:19 +0100 |
commit | 15ff88f0f16cf5a4a5452e3f8ef93e72cbd66e00 (patch) | |
tree | 17dab714583ed976de7dfb24e1c48101879e0cc5 | |
parent | b56a8c98805f24a896fd563e4af76d1a0f03d9c9 (diff) |
QmlCompiler: Make InstructionAnnotations a QFlatMap
We will need to iterate the annotations in program order. Therefore, we
need an order map. QFlatMap fits here.
Change-Id: I9a7fe68b0e5aa817257ceabb4853b1554d3ad709
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/qmlcompiler/qqmljscodegenerator.cpp | 12 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljscompilepass_p.h | 20 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsstoragegeneralizer.cpp | 4 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 10 |
4 files changed, 24 insertions, 22 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index 979f1bdd60..b08af00f1c 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -115,9 +115,11 @@ QQmlJSAotFunction QQmlJSCodeGenerator::run( } }; - for (const InstructionAnnotation &annotation : *m_annotations) { - addVariable(annotation.changedRegisterIndex, annotation.changedRegister.storedType()); - for (auto it = annotation.typeConversions.begin(), end = annotation.typeConversions.end(); + for (const auto &annotation : *m_annotations) { + addVariable(annotation.second.changedRegisterIndex, + annotation.second.changedRegister.storedType()); + for (auto it = annotation.second.typeConversions.begin(), + end = annotation.second.typeConversions.end(); it != end; ++it) { addVariable(it.key(), it.value().storedType()); } @@ -2435,9 +2437,9 @@ void QQmlJSCodeGenerator::generateJumpCodeWithTypeConversions( m_body += u"{\n"_qs; int absoluteOffset =nextInstructionOffset() + relativeOffset; - const auto annotation = m_annotations->constFind(absoluteOffset); + const auto annotation = m_annotations->find(absoluteOffset); if (annotation != m_annotations->constEnd()) { - const auto &conversions = annotation->typeConversions; + const auto &conversions = annotation->second.typeConversions; for (auto regIt = conversions.constBegin(), regEnd = conversions.constEnd(); regIt != regEnd; ++regIt) { diff --git a/src/qmlcompiler/qqmljscompilepass_p.h b/src/qmlcompiler/qqmljscompilepass_p.h index f5a412df77..44cf5bc543 100644 --- a/src/qmlcompiler/qqmljscompilepass_p.h +++ b/src/qmlcompiler/qqmljscompilepass_p.h @@ -79,7 +79,7 @@ public: bool isRename = false; }; - using InstructionAnnotations = QHash<int, InstructionAnnotation>; + using InstructionAnnotations = QFlatMap<int, InstructionAnnotation>; struct Function { @@ -198,7 +198,7 @@ protected: { State newState; - const auto instruction = annotations.constFind(currentInstructionOffset()); + const auto instruction = annotations.find(currentInstructionOffset()); newState.registers = oldState.registers; // Usually the initial accumulator type is the output of the previous instruction, but ... @@ -208,19 +208,19 @@ protected: if (instruction == annotations.constEnd()) return newState; - newState.setHasSideEffects(instruction->hasSideEffects); - newState.setReadRegisters(instruction->readRegisters); - newState.setIsRename(instruction->isRename); + newState.setHasSideEffects(instruction->second.hasSideEffects); + newState.setReadRegisters(instruction->second.readRegisters); + newState.setIsRename(instruction->second.isRename); - for (auto it = instruction->typeConversions.begin(), - end = instruction->typeConversions.end(); it != end; ++it) { + for (auto it = instruction->second.typeConversions.begin(), + end = instruction->second.typeConversions.end(); it != end; ++it) { Q_ASSERT(it.key() != InvalidRegister); newState.registers[it.key()] = it.value(); } - if (instruction->changedRegisterIndex != InvalidRegister) { - newState.setRegister(instruction->changedRegisterIndex, - instruction->changedRegister); + if (instruction->second.changedRegisterIndex != InvalidRegister) { + newState.setRegister(instruction->second.changedRegisterIndex, + instruction->second.changedRegister); } return newState; diff --git a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp index 0f91a46f38..9af98eed85 100644 --- a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp +++ b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp @@ -96,9 +96,9 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSStorageGeneralizer::run( }; for (auto i = annotations.begin(), iEnd = annotations.end(); i != iEnd; ++i) { - if (!transformRegister(i->changedRegister, i.key())) + if (!transformRegister(i->second.changedRegister, i.key())) return InstructionAnnotations(); - if (!transformRegisters(i->typeConversions, i.key())) + if (!transformRegisters(i->second.typeConversions, i.key())) return InstructionAnnotations(); } diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index c4c7e22a6a..949bd0dbc6 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -1036,9 +1036,9 @@ void QQmlJSTypePropagator::setAccumulator(const QQmlJSRegisterContent &content) void QQmlJSTypePropagator::setRegister(int index, const QQmlJSRegisterContent &content) { // If we've come to the same conclusion before, let's not track the type again. - auto it = m_prevStateAnnotations.constFind(currentInstructionOffset()); - if (it != m_prevStateAnnotations.constEnd()) { - const QQmlJSRegisterContent &lastTry = it->changedRegister; + auto it = m_prevStateAnnotations.find(currentInstructionOffset()); + if (it != m_prevStateAnnotations.end()) { + const QQmlJSRegisterContent &lastTry = it->second.changedRegister; if (m_typeResolver->registerContains(lastTry, m_typeResolver->containedType(content))) { m_state.setRegister(index, lastTry); return; @@ -1061,8 +1061,8 @@ void QQmlJSTypePropagator::mergeRegister( if (it == m_prevStateAnnotations.end()) return false; - auto conversion = it->typeConversions.find(index); - if (conversion == it->typeConversions.end()) + auto conversion = it->second.typeConversions.find(index); + if (conversion == it->second.typeConversions.end()) return false; const QQmlJSRegisterContent &lastTry = conversion.value(); |