From 4e0174a88e66b9d9471c98eeb7d8be6209ba5c98 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 21 Aug 2017 10:59:53 +0200 Subject: 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 --- src/qml/compiler/qv4bytecodegenerator.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/qml/compiler/qv4bytecodegenerator.cpp') 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 +#include #include QT_USE_NAMESPACE @@ -46,12 +47,7 @@ using namespace Moth; void BytecodeGenerator::setLocation(const QQmlJS::AST::SourceLocation &loc) { - if (static_cast(loc.startLine) == currentLine) - return; currentLine = static_cast(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 instructionOffsets; + QVector 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(&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; } -- cgit v1.2.3