diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-29 13:30:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-10-13 22:13:12 +0200 |
commit | ae49af00b59628623bc15e19974ee5af5f0121ba (patch) | |
tree | 91488d095e7a5b52bb1b8df05e56fb668039ea7b /src/qml/compiler/qv4bytecodegenerator.cpp | |
parent | 9cfc19faf5d1ce2b9626914ab4528998b072385d (diff) | |
download | qtdeclarative-ae49af00b59628623bc15e19974ee5af5f0121ba.tar.gz |
QML: Track the statement indices together with line numbers
We will need the statement indices when tracking value type references.
New value type references shall only be written back in the same
statement they were created in.
Task-number: QTBUG-99766
Change-Id: I83f908df034e7da8ba46ccacaa29bd9d78020d20
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4bytecodegenerator.cpp')
-rw-r--r-- | src/qml/compiler/qv4bytecodegenerator.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp index 8f0518093a..b88c83512f 100644 --- a/src/qml/compiler/qv4bytecodegenerator.cpp +++ b/src/qml/compiler/qv4bytecodegenerator.cpp @@ -15,6 +15,11 @@ void BytecodeGenerator::setLocation(const QQmlJS::SourceLocation &loc) currentSourceLocation = loc; } +void BytecodeGenerator::incrementStatement() +{ + ++currentStatement; +} + int BytecodeGenerator::newRegister() { int t = currentReg++; @@ -129,17 +134,21 @@ void BytecodeGenerator::finalize(Compiler::Context *context) // collect content and line numbers QByteArray code; - QVector<CompiledData::CodeOffsetToLine> lineNumbers; + QVector<CompiledData::CodeOffsetToLineAndStatement> lineAndStatementNumbers; currentLine = -1; + currentStatement = -1; + Q_UNUSED(startLine); for (qsizetype i = 0; i < instructions.size(); i++) { - if (instructions[i].line != currentLine) { + if (instructions[i].line != currentLine || instructions[i].statement != currentStatement) { currentLine = instructions[i].line; - CompiledData::CodeOffsetToLine entry; + currentStatement = instructions[i].statement; + CompiledData::CodeOffsetToLineAndStatement entry; entry.codeOffset = code.size(); entry.line = currentLine; - lineNumbers.append(entry); + entry.statement = currentStatement; + lineAndStatementNumbers.append(entry); } if (m_sourceLocationTable) @@ -149,7 +158,7 @@ void BytecodeGenerator::finalize(Compiler::Context *context) } context->code = code; - context->lineNumberMapping = lineNumbers; + context->lineAndStatementNumberMapping = lineAndStatementNumbers; context->sourceLocationTable = std::move(m_sourceLocationTable); context->labelInfo.reserve(context->labelInfo.size() + _labelInfos.size()); @@ -197,7 +206,16 @@ QT_WARNING_POP int s = argCount*sizeof(int); if (offsetOfOffset != -1) offsetOfOffset += Instr::encodedLength(type); - I instr{type, static_cast<short>(s + Instr::encodedLength(type)), 0, currentLine, offsetOfOffset, -1, "\0\0" }; + I instr { + type, + static_cast<short>(s + Instr::encodedLength(type)), + 0, + currentLine, + currentStatement, + offsetOfOffset, + -1, + "\0\0" + }; uchar *code = instr.packed; code = Instr::pack(code, Instr::wideInstructionType(type)); |