diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-24 14:46:45 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-28 13:18:48 +0000 |
commit | 7f0bb07631648ffbe70b92c42fb10e04280d95bd (patch) | |
tree | 02cdb455458fd80cbd80bf8de6f04e68ba20e2af /src/qml/compiler/qv4bytecodegenerator_p.h | |
parent | 062dd5c38379e660c75092260e94d3c5a103ae17 (diff) |
Get rid of the separate vector of Jumps
Instead add it to the unencoded instruction vector
Change-Id: I7e88d808bb94f75aecdf9d3ed9bace2055c1da5d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4bytecodegenerator_p.h')
-rw-r--r-- | src/qml/compiler/qv4bytecodegenerator_p.h | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h index c00c80f0f4..6439009230 100644 --- a/src/qml/compiler/qv4bytecodegenerator_p.h +++ b/src/qml/compiler/qv4bytecodegenerator_p.h @@ -99,13 +99,12 @@ public: }; struct Jump { - Jump(BytecodeGenerator *generator, int instruction, int offset) + Jump(BytecodeGenerator *generator, int instruction) : generator(generator), - index(generator->jumps.size()) { - generator->jumps.append({ instruction, offset, -1 }); - } + index(instruction) + {} ~Jump() { - Q_ASSERT(generator->jumps[index].linkedLabel != -1); + Q_ASSERT(generator->instructions[index].linkedLabel != -1); } @@ -117,8 +116,8 @@ public: } void link(Label l) { Q_ASSERT(l.index >= 0); - Q_ASSERT(generator->jumps[index].linkedLabel == -1); - generator->jumps[index].linkedLabel = l.index; + Q_ASSERT(generator->instructions[index].linkedLabel == -1); + generator->instructions[index].linkedLabel = l.index; } }; @@ -231,7 +230,7 @@ public: Instr genericInstr; genericInstr.Nop.instructionType = InstrT; InstrMeta<InstrT>::setDataNoCommon(genericInstr, data); - return Jump(this, addInstructionHelper(InstrMeta<InstrT>::Size, genericInstr), offsetof(InstrData<InstrT>, offset)); + return Jump(this, addInstructionHelper(InstrMeta<InstrT>::Size, genericInstr, offsetof(InstrData<InstrT>, offset))); } private: @@ -239,27 +238,22 @@ private: friend struct Label; friend struct ExceptionHandler; - int addInstructionHelper(uint size, const Instr &i) { + int addInstructionHelper(uint size, const Instr &i, int offsetOfOffset = -1) { int pos = instructions.size(); - instructions.append({size, currentLine, i}); + instructions.append({size, currentLine, offsetOfOffset, -1, i}); return pos; } - struct JumpData { - int instructionIndex; - int offset; - int linkedLabel; - }; - struct I { uint size; int line; + int offsetForJump; + int linkedLabel; Instr instr; }; QVector<I> instructions; QVector<int> labels; - QVector<JumpData> jumps; ExceptionHandler *currentExceptionHandler; int regCount = 0; public: |