aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4bytecodegenerator_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-24 15:31:44 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-28 13:18:57 +0000
commitcd67176bb24c82b239414c162644ebf9e0d3327e (patch)
treeca5b433fdca7d70f477c579680c541a4c01a1814 /src/qml/compiler/qv4bytecodegenerator_p.h
parentddb4fb4c60987ce6e0b9e50de9a5f3a7ff0e8757 (diff)
Start compressing the byte code
As a first step, use only one byte for the instruction type. Change-Id: I762a05233c277a7144472793bc71e41d9e8e82cb 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.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h
index 6439009230..3483565fb0 100644
--- a/src/qml/compiler/qv4bytecodegenerator_p.h
+++ b/src/qml/compiler/qv4bytecodegenerator_p.h
@@ -148,9 +148,8 @@ public:
void addInstruction(const InstrData<InstrT> &data)
{
Instr genericInstr;
- genericInstr.Nop.instructionType = InstrT;
- InstrMeta<InstrT>::setDataNoCommon(genericInstr, data);
- addInstructionHelper(InstrMeta<InstrT>::Size, genericInstr);
+ InstrMeta<InstrT>::setData(genericInstr, data);
+ addInstructionHelper(Moth::Instr::Type(InstrT), InstrMeta<InstrT>::Size, genericInstr);
}
Q_REQUIRED_RESULT Jump jump()
@@ -228,9 +227,8 @@ public:
Jump addJumpInstruction(const InstrData<InstrT> &data)
{
Instr genericInstr;
- genericInstr.Nop.instructionType = InstrT;
- InstrMeta<InstrT>::setDataNoCommon(genericInstr, data);
- return Jump(this, addInstructionHelper(InstrMeta<InstrT>::Size, genericInstr, offsetof(InstrData<InstrT>, offset)));
+ InstrMeta<InstrT>::setData(genericInstr, data);
+ return Jump(this, addInstructionHelper(Moth::Instr::Type(InstrT), InstrMeta<InstrT>::Size, genericInstr, offsetof(InstrData<InstrT>, offset)));
}
private:
@@ -238,18 +236,24 @@ private:
friend struct Label;
friend struct ExceptionHandler;
- int addInstructionHelper(uint size, const Instr &i, int offsetOfOffset = -1) {
+ int addInstructionHelper(Moth::Instr::Type type, uint size, const Instr &i, int offsetOfOffset = -1) {
int pos = instructions.size();
- instructions.append({size, currentLine, offsetOfOffset, -1, i});
+ instructions.append({type, size, 0, currentLine, offsetOfOffset, -1, { i } });
return pos;
}
+ void compressInstructions();
struct I {
+ Moth::Instr::Type type;
uint size;
+ uint position;
int line;
int offsetForJump;
int linkedLabel;
- Instr instr;
+ union {
+ Instr instr;
+ char packed[sizeof(Instr) + 2]; // 2 for instruction and prefix
+ };
};
QVector<I> instructions;