diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-08 11:38:14 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-09 21:28:06 +0200 |
| commit | 406a9e1301e2597962ef0564348304be67d2c316 (patch) | |
| tree | 40a2cfb1581dc7faf017e5e5598241298f2bd003 /src/qml/jsruntime/qv4stackframe.cpp | |
| parent | 1b89c1edcae68351632c2755e5408410c2ff98e3 (diff) | |
QML: Encode "missing" line number as negated address of stack frame
This way we can identify which entry in a stack frame to amend when
processing an exception in generated code. However, negative line
numbers are also used to signal the position of "Ret" instructions.
Since you cannot throw an exception from a "Ret" instruction, those
cannot collide, but we cannot qAbs() the line number anymore when saving
it in the stack trace. We have to qAbs() it in all the places where it's
read.
Pick-to: 6.5
Fixes: QTBUG-112946
Change-Id: I24dc4008fb7eab38e4d24e70211c22e46f1b72a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stackframe.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4stackframe.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4stackframe.cpp b/src/qml/jsruntime/qv4stackframe.cpp index e8ff9a89bc..5117e745a0 100644 --- a/src/qml/jsruntime/qv4stackframe.cpp +++ b/src/qml/jsruntime/qv4stackframe.cpp @@ -40,7 +40,7 @@ int CppStackFrame::lineNumber() const { if (auto *line = lineAndStatement(this)) return line->line; - return -1; + return missingLineNumber(); } int CppStackFrame::statementNumber() const @@ -50,6 +50,15 @@ int CppStackFrame::statementNumber() const return -1; } +int CppStackFrame::missingLineNumber() const +{ + // Remove the first bit so that we can cast to positive int and negate. + // Remove the last bit so that it can't be -1. + const int result = -int(quintptr(this) & 0x7ffffffe); + Q_ASSERT(result < -1); + return result; +} + ReturnedValue QV4::CppStackFrame::thisObject() const { if (isJSTypesFrame()) |
