aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4bytecodegenerator.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-21 10:59:53 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-25 12:05:59 +0000
commit4e0174a88e66b9d9471c98eeb7d8be6209ba5c98 (patch)
tree573aac0c41d77fab6dfe37d4d75e0446165d78f0 /src/qml/compiler/qv4bytecodegenerator.cpp
parent3c201dd0d95020c4cb4c8ceaf779673d411664e7 (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/compiler/qv4bytecodegenerator.cpp')
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index c9b7c4ae7e..cae984a253 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include <private/qv4bytecodegenerator_p.h>
+#include <private/qv4compilercontext_p.h>
#include <private/qqmljsastfwd_p.h>
QT_USE_NAMESPACE
@@ -46,12 +47,7 @@ using namespace Moth;
void BytecodeGenerator::setLocation(const QQmlJS::AST::SourceLocation &loc)
{
- if (static_cast<int>(loc.startLine) == currentLine)
- return;
currentLine = static_cast<int>(loc.startLine);
- Instruction::Line line;
- line.lineNumber = currentLine;
- addInstruction(line); //### put line numbers in a side-table, not in the instruction stream
}
int BytecodeGenerator::newRegister()
@@ -71,14 +67,23 @@ int BytecodeGenerator::newRegisterArray(int n)
return t;
}
-QByteArray BytecodeGenerator::finalize()
+void BytecodeGenerator::finalize(Compiler::Context *context)
{
QByteArray code;
// content
QVector<int> instructionOffsets;
+ QVector<int> lineNumbers;
+ currentLine = startLine;
instructionOffsets.reserve(instructions.size());
for (const auto &i : qAsConst(instructions)) {
+ if (i.line != currentLine) {
+ Q_ASSERT(i.line > currentLine);
+ while (currentLine < i.line) {
+ lineNumbers.append(code.size());
+ ++currentLine;
+ }
+ }
instructionOffsets.append(code.size());
code.append(reinterpret_cast<const char *>(&i.instr), i.size);
}
@@ -97,5 +102,6 @@ QByteArray BytecodeGenerator::finalize()
memcpy(c, &linkedInstructionOffset, sizeof(ptrdiff_t));
}
- return code;
+ context->code = code;
+ context->lineNumberMapping = lineNumbers;
}