QmlCompiler: Analyze type conversions before reads in basic blocks
The type conversions happen before the value is read. Therefore, we need to record them in this order. Otherwise, we may lose a type conversion if the instruction writes the same register as it reads. Fixes: QTBUG-102281 Change-Id: Id63a69f86af90c8dc987c0301db3958322c006a1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
a55299615f
commit
8a229c38fb
|
@ -296,6 +296,11 @@ void QQmlJSBasicBlocks::populateReaderLocations()
|
|||
? (writeIt + 1)
|
||||
: m_annotations.find(currentBlock->first);
|
||||
for (; blockInstr != blockEnd; ++blockInstr) {
|
||||
if (registerActive
|
||||
&& blockInstr->second.typeConversions.contains(writtenRegister)) {
|
||||
conversions.append(blockInstr.key());
|
||||
}
|
||||
|
||||
for (auto readIt = blockInstr->second.readRegisters.constBegin(),
|
||||
end = blockInstr->second.readRegisters.constEnd();
|
||||
readIt != end; ++readIt) {
|
||||
|
@ -309,11 +314,6 @@ void QQmlJSBasicBlocks::populateReaderLocations()
|
|||
access.registerReadersAndConversions[blockInstr.key()] = conversions;
|
||||
}
|
||||
|
||||
if (registerActive
|
||||
&& blockInstr->second.typeConversions.contains(writtenRegister)) {
|
||||
conversions.append(blockInstr.key());
|
||||
}
|
||||
|
||||
if (blockInstr->second.changedRegisterIndex == writtenRegister) {
|
||||
conversions.clear();
|
||||
registerActive = false;
|
||||
|
|
|
@ -4,4 +4,7 @@ import QtQuick 6
|
|||
Item {
|
||||
property bool a: !x
|
||||
width: !(parent && state) ? 100 : 0
|
||||
|
||||
property font f
|
||||
property bool b: !(parent || f)
|
||||
}
|
||||
|
|
|
@ -2000,13 +2000,16 @@ void tst_QmlCppCodegen::fromBoolValue()
|
|||
QCOMPARE(o->property("a").toBool(), false);
|
||||
|
||||
QCOMPARE(o->property("width").toInt(), 100);
|
||||
QCOMPARE(o->property("b").toBool(), false);
|
||||
|
||||
QScopedPointer<QObject> parent(c.create());
|
||||
o->setProperty("parent", QVariant::fromValue(parent.data()));
|
||||
QCOMPARE(o->property("width").toInt(), 100);
|
||||
QCOMPARE(o->property("b").toBool(), false);
|
||||
|
||||
o->setProperty("state", QVariant::fromValue(u"foo"_qs));
|
||||
QCOMPARE(o->property("width").toInt(), 0);
|
||||
QCOMPARE(o->property("b").toBool(), false);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::runInterpreted()
|
||||
|
|
Loading…
Reference in New Issue