aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4instr_moth_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-26 19:37:39 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-28 13:19:42 +0000
commitb5ade552b799ded48fbb1700d80de5c499ba0f15 (patch)
tree9f3ec66b3753af68a8a0225ff2063d49330235ab /src/qml/compiler/qv4instr_moth_p.h
parentad77c970281345bc03501cea583125a89637a52c (diff)
Remove the distinction between wide and xwide instructions
Only keep 1 byte and 4 byte wide instructions. As this gives less than 256 distinct instructions, those can now again be encoded in 1 byte, dropping the Wide and XWide prefix instructions. This gives us 95% of the size savings that we had before, by being able to encode the full instruction in one byte, while bringing back pretty much all of the speed lost through the compression. Change-Id: I9ec978d43314ed304ca0ee5546035d2b581b6dc3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4instr_moth_p.h')
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h42
1 files changed, 8 insertions, 34 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 425a9e506b..1e1968a91d 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -71,9 +71,6 @@ QT_BEGIN_NAMESPACE
op##_INSTRUCTION(name, nargs, __VA_ARGS__)
/* for all jump instructions, the offset has to come last, to simplify the job of the bytecode generator */
-#define INSTR_Nop(op) INSTRUCTION(op, Nop, 0)
-#define INSTR_Wide(op) INSTRUCTION(op, Wide, 0)
-#define INSTR_XWide(op) INSTRUCTION(op, XWide, 0)
#define INSTR_Ret(op) INSTRUCTION(op, Ret, 0)
#define INSTR_Debug(op) INSTRUCTION(op, Debug, 0)
#define INSTR_LoadConst(op) INSTRUCTION(op, LoadConst, 1, index)
@@ -186,9 +183,6 @@ QT_BEGIN_NAMESPACE
#define FOR_EACH_MOTH_INSTR(F) \
- F(Nop) \
- F(Wide) \
- F(XWide) \
F(Ret) \
F(Debug) \
F(LoadConst) \
@@ -358,10 +352,6 @@ QT_BEGIN_NAMESPACE
MOTH_ADJUST_CODE(int, nargs); \
MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \
goto op_main_##name; \
- op_short_##name: \
- MOTH_ADJUST_CODE(short, nargs); \
- MOTH_DECODE_ARGS(name, short, nargs, __VA_ARGS__) \
- goto op_main_##name; \
op_char_##name: \
MOTH_ADJUST_CODE(char, nargs); \
MOTH_DECODE_ARGS(name, char, nargs, __VA_ARGS__) \
@@ -390,30 +380,19 @@ QT_BEGIN_NAMESPACE
INSTR_##instr(GET_LABEL)
#define GET_LABEL_INSTRUCTION(name, ...) \
&&op_char_##name,
-
#define COLLECT_LABELS_WIDE(instr) \
INSTR_##instr(GET_LABEL_WIDE)
#define GET_LABEL_WIDE_INSTRUCTION(name, ...) \
- &&op_short_##name,
-
-#define COLLECT_LABELS_XWIDE(instr) \
- INSTR_##instr(GET_LABEL_XWIDE)
-#define GET_LABEL_XWIDE_INSTRUCTION(name, ...) \
&&op_int_##name,
#define MOTH_JUMP_TABLE \
static const void *jumpTable[] = { \
FOR_EACH_MOTH_INSTR(COLLECT_LABELS) \
FOR_EACH_MOTH_INSTR(COLLECT_LABELS_WIDE) \
- FOR_EACH_MOTH_INSTR(COLLECT_LABELS_XWIDE) \
};
#define MOTH_DISPATCH() \
- goto *jumpTable[static_cast<int>(*code)];
-#define MOTH_DISPATCH_WIDE() \
- goto *jumpTable[static_cast<int>(*code) + MOTH_NUM_INSTRUCTIONS()];
-#define MOTH_DISPATCH_XWIDE() \
- goto *jumpTable[static_cast<int>(*code) + 2*MOTH_NUM_INSTRUCTIONS()];
+ goto *jumpTable[*reinterpret_cast<const uchar *>(code)];
#else
#define MOTH_JUMP_TABLE
@@ -424,24 +403,12 @@ QT_BEGIN_NAMESPACE
#define MOTH_INSTR_CASE_AND_JUMP_WIDE(instr) \
INSTR_##instr(GET_CASE_AND_JUMP_WIDE)
#define GET_CASE_AND_JUMP_WIDE_INSTRUCTION(name, ...) \
- case Instr::Type::name: goto op_short_##name;
-#define MOTH_INSTR_CASE_AND_JUMP_XWIDE(instr) \
- INSTR_##instr(GET_CASE_AND_JUMP_XWIDE)
-#define GET_CASE_AND_JUMP_XWIDE_INSTRUCTION(name, ...) \
case Instr::Type::name: goto op_int_##name;
#define MOTH_DISPATCH() \
switch (static_cast<Instr::Type>(*code)) { \
FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP) \
}
-#define MOTH_DISPATCH_WIDE() \
- switch (static_cast<Instr::Type>(*code)) { \
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP_WIDE) \
- }
-#define MOTH_DISPATCH_XWIDE() \
- switch (static_cast<Instr::Type>(*code)) { \
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP_XWIDE) \
- }
#endif
namespace QV4 {
@@ -476,6 +443,11 @@ public:
int stackSlot() const { return index; }
operator int() const { return index; }
+ static QString dump(int reg, int nFormals) {
+ StackSlot t;
+ t.index = reg;
+ return t.dump(nFormals);
+ }
QString dump(int nFormals) const {
if (isRegister())
return QStringLiteral("r%1").arg(index);
@@ -513,6 +485,8 @@ union Instr
static int size(Type type);
};
+Q_STATIC_ASSERT(MOTH_NUM_INSTRUCTIONS() < 128);
+
template<int N>
struct InstrMeta {
};