From 2951f6105ad3851b38fa66348a4edd3fe7cfa47e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Aug 2017 16:04:19 +0200 Subject: Introduce the wide/xwide instruction prefixes And add proper decoding for the prefixed instructions to the VME and bytecode dumper. We still only generate XWide instructions, that will get fixed in the next change. Change-Id: I6d2dc6a0a4f706044038274ca79e019a6c9bb7d9 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4instr_moth_p.h | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/qml/compiler/qv4instr_moth_p.h') diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index bffc7b2bf4..c10d48ff8e 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -341,6 +341,27 @@ QT_BEGIN_NAMESPACE #define MOTH_EMIT_INSTR_MEMBER_INSTRUCTION(name, nargs, ...) \ instr_##name name; +/* collect jump labels */ +#define COLLECT_LABELS(instr) \ + 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) }; \ + static const void *jumpTableWide[] = { FOR_EACH_MOTH_INSTR(COLLECT_LABELS_WIDE) }; \ + static const void *jumpTableXWide[] = { FOR_EACH_MOTH_INSTR(COLLECT_LABELS_XWIDE) } + #define MOTH_DECODE_ARG(arg, type, offset) \ arg = reinterpret_cast(code)[offset] @@ -352,6 +373,16 @@ QT_BEGIN_NAMESPACE op_int_##name: \ MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \ MOTH_ADJUST_CODE(int, nargs); \ + goto op_main_##name; \ + op_short_##name: \ + MOTH_DECODE_ARGS(name, short, nargs, __VA_ARGS__) \ + MOTH_ADJUST_CODE(short, nargs); \ + goto op_main_##name; \ + op_char_##name: \ + MOTH_DECODE_ARGS(name, char, nargs, __VA_ARGS__) \ + MOTH_ADJUST_CODE(char, nargs); \ + op_main_##name: \ + ; \ #define MOTH_DECODE_ARGS(name, type, nargs, ...) \ MOTH_DECODE_ARGS##nargs(name, type, __VA_ARGS__) @@ -374,6 +405,16 @@ QT_BEGIN_NAMESPACE ++code; \ goto *jumpTable[instr]; +#define MOTH_DISPATCH_WIDE() \ + int winstr = *code; \ + ++code; \ + goto *jumpTableWide[winstr]; + +#define MOTH_DISPATCH_XWIDE() \ + int xwinstr = *code; \ + ++code; \ + goto *jumpTableXWide[xwinstr]; + namespace QV4 { namespace Moth { -- cgit v1.2.3