aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-09-29 13:30:42 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-10-13 22:13:12 +0200
commitae49af00b59628623bc15e19974ee5af5f0121ba (patch)
tree91488d095e7a5b52bb1b8df05e56fb668039ea7b /src/qml/jsruntime
parent9cfc19faf5d1ce2b9626914ab4528998b072385d (diff)
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/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4stackframe.cpp36
-rw-r--r--src/qml/jsruntime/qv4stackframe_p.h1
2 files changed, 27 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4stackframe.cpp b/src/qml/jsruntime/qv4stackframe.cpp
index a02ce0edc5..e8ff9a89bc 100644
--- a/src/qml/jsruntime/qv4stackframe.cpp
+++ b/src/qml/jsruntime/qv4stackframe.cpp
@@ -17,21 +17,37 @@ QString CppStackFrame::function() const
return v4Function ? v4Function->name()->toQString() : QString();
}
-int CppStackFrame::lineNumber() const
+static const CompiledData::CodeOffsetToLineAndStatement *lineAndStatement(const CppStackFrame *frame)
{
- if (!v4Function || instructionPointer <= 0)
- return -1;
+ if (!frame->v4Function || frame->instructionPointer <= 0)
+ return nullptr;
- auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) {
+ auto findLine = [](const CompiledData::CodeOffsetToLineAndStatement &entry, uint offset) {
return entry.codeOffset < offset;
};
- const QV4::CompiledData::Function *cf = v4Function->compiledFunction;
- const uint offset = instructionPointer;
- const CompiledData::CodeOffsetToLine *lineNumbers = cf->lineNumberTable();
- const uint nLineNumbers = cf->nLineNumbers;
- const CompiledData::CodeOffsetToLine *line = std::lower_bound(lineNumbers, lineNumbers + nLineNumbers, offset, findLine) - 1;
- return line->line;
+ const QV4::CompiledData::Function *cf = frame->v4Function->compiledFunction;
+ const uint offset = frame->instructionPointer;
+ const CompiledData::CodeOffsetToLineAndStatement *lineAndStatementNumbers
+ = cf->lineAndStatementNumberTable();
+ const uint nLineAndStatementNumbers = cf->nLineAndStatementNumbers;
+ return std::lower_bound(
+ lineAndStatementNumbers, lineAndStatementNumbers + nLineAndStatementNumbers,
+ offset, findLine) - 1;
+}
+
+int CppStackFrame::lineNumber() const
+{
+ if (auto *line = lineAndStatement(this))
+ return line->line;
+ return -1;
+}
+
+int CppStackFrame::statementNumber() const
+{
+ if (auto *statement = lineAndStatement(this))
+ return statement->statement;
+ return -1;
}
ReturnedValue QV4::CppStackFrame::thisObject() const
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h
index b9d57d5f54..2777d79c31 100644
--- a/src/qml/jsruntime/qv4stackframe_p.h
+++ b/src/qml/jsruntime/qv4stackframe_p.h
@@ -81,6 +81,7 @@ struct Q_QML_PRIVATE_EXPORT CppStackFrame : protected CppStackFrameBase
QString source() const;
QString function() const;
int lineNumber() const;
+ int statementNumber() const;
CppStackFrame *parentFrame() const { return parent; }
void setParentFrame(CppStackFrame *parentFrame) { parent = parentFrame; }