diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-21 10:59:53 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-25 12:05:59 +0000 |
commit | 4e0174a88e66b9d9471c98eeb7d8be6209ba5c98 (patch) | |
tree | 573aac0c41d77fab6dfe37d4d75e0446165d78f0 /src/qml/jsruntime/qv4engine.cpp | |
parent | 3c201dd0d95020c4cb4c8ceaf779673d411664e7 (diff) |
Move line number information into a side table
Don't emit any Line instructions anymore, and instead store
the info in a side table in the compiled data, where it can
be looked up on demand.
Change-Id: Idcaf3bf4ee4129fd62f9e717bf1277dc6a34fe19
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index f5effc8c3b..ce21e0f7e5 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -794,6 +794,19 @@ QString CppStackFrame::function() const return v4Function->name()->toQString(); } +int CppStackFrame::lineNumber() const +{ + const QV4::CompiledData::Function *cf = v4Function->compiledFunction; + uint offset = static_cast<uint>(instructionPointer - v4Function->codeData - 1); // -1 because the instructionPointer points to the next instruction + const quint32_le *lineNumbers = cf->lineNumberTable(); + int nLineNumbers = cf->nLineNumbers; + for (int i = 0; i < nLineNumbers; ++i) { + if (offset <= lineNumbers[i]) + return cf->location.line + i; + } + return cf->location.line + nLineNumbers; +} + ReturnedValue CppStackFrame::thisObject() const { return jsFrame->stack[-(int)v4Function->nFormals - 1].asReturnedValue(); } @@ -809,8 +822,8 @@ StackTrace ExecutionEngine::stackTrace(int frameLimit) const QV4::StackFrame frame; frame.source = f->source(); frame.function = f->function(); - frame.line = f->line; - frame.column = f->column; + frame.line = f->lineNumber(); + frame.column = -1; stack.append(frame); --frameLimit; f = f->parent; |