aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4instr_moth_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-24 14:10:41 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-28 13:18:36 +0000
commita4f8b9ae6dfacf9ad5c190cde6098ebf13102f41 (patch)
treea179acaa281c399ae8f122c70ba450ac82dd88e2 /src/qml/compiler/qv4instr_moth_p.h
parent011da0cfb69af8d3198f8150a2b7e2857a5ac22f (diff)
Decode instructions into registers
Don't use the old instruction structures in the VME anymore, instead directly decode into scoped registers. Change-Id: Ie03ebad98050ebfd9eb9cc7e9273e5db92884a89 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.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 529584f1dd..6af80689a6 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -297,7 +297,7 @@ QT_BEGIN_NAMESPACE
#define MOTH_INSTR_ALIGN_MASK (Q_ALIGNOF(QV4::Moth::Instr) - 1)
-#define MOTH_INSTR_HEADER union { Instr::Type instructionType; quint64 _dummy; };
+#define MOTH_INSTR_HEADER int instructionType;
#define MOTH_INSTR_ENUM(I) I,
#define MOTH_INSTR_SIZE(I) ((sizeof(QV4::Moth::Instr::instr_##I) + MOTH_INSTR_ALIGN_MASK) & ~MOTH_INSTR_ALIGN_MASK)
@@ -340,6 +340,38 @@ QT_BEGIN_NAMESPACE
instr_##name name;
+#define MOTH_DECODE_ARG(arg, type, offset) \
+ arg = reinterpret_cast<const type *>(code)[offset]
+#define MOTH_ADJUST_CODE(type, nargs) \
+ code += nargs*sizeof(type)
+
+#define MOTH_DECODE_INSTRUCTION(name, nargs, ...) \
+ MOTH_DEFINE_ARGS(nargs, __VA_ARGS__) \
+ op_int_##name: \
+ MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \
+ MOTH_ADJUST_CODE(int, nargs); \
+
+#define MOTH_DECODE_ARGS(name, type, nargs, ...) \
+ MOTH_DECODE_ARGS##nargs(name, type, __VA_ARGS__)
+
+#define MOTH_DECODE_ARGS0(name, type, dummy)
+#define MOTH_DECODE_ARGS1(name, type, arg) \
+ MOTH_DECODE_ARG(arg, type, 0);
+#define MOTH_DECODE_ARGS2(name, type, arg1, arg2) \
+ MOTH_DECODE_ARGS1(name, type, arg1); \
+ MOTH_DECODE_ARG(arg2, type, 1);
+#define MOTH_DECODE_ARGS3(name, type, arg1, arg2, arg3) \
+ MOTH_DECODE_ARGS2(name, type, arg1, arg2); \
+ MOTH_DECODE_ARG(arg3, type, 2);
+#define MOTH_DECODE_ARGS4(name, type, arg1, arg2, arg3, arg4) \
+ MOTH_DECODE_ARGS3(name, type, arg1, arg2, arg3); \
+ MOTH_DECODE_ARG(arg4, type, 3);
+
+#define MOTH_DISPATCH() \
+ int instr = *reinterpret_cast<const int *>(code); \
+ code += 4; \
+ goto *jumpTable[instr];
+
namespace QV4 {
namespace Moth {