aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp9
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp39
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h41
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp16
4 files changed, 77 insertions, 28 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index 72c3d4e96f..3ce3acdb86 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -71,11 +71,12 @@ void BytecodeGenerator::compressInstructions()
{
for (auto &i : instructions) {
Instr instr = i.instr;
- i.packed[0] = static_cast<char>(i.type);
- memcpy(i.packed + 1, reinterpret_cast<char *>(&instr), i.size);
- ++i.size;
+ i.packed[0] = static_cast<char>(Instr::Type::XWide);
+ i.packed[1] = static_cast<char>(i.type);
+ memcpy(i.packed + 2, reinterpret_cast<char *>(&instr), i.size);
+ i.size += 2;
if (i.offsetForJump != -1)
- ++i.offsetForJump;
+ i.offsetForJump += 2;
}
}
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index ba66dff577..2716bed5ad 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -92,7 +92,12 @@ static QString toString(QV4::ReturnedValue v)
QDebug d = qDebug(); \
d.noquote(); \
d.nospace(); \
- d << alignedLineNumber(line) << alignedNumber(int(code - start)).constData() << ": " << #instr << " ";
+ d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " << #instr; \
+ switch(mode) { \
+ case Normal: d << " "; break; \
+ case Wide: d << ".Wide "; break; \
+ case XWide: d << ".XWide "; break; \
+ }
#define MOTH_END_INSTR(instr) \
continue; \
@@ -114,13 +119,7 @@ void dumpConstantTable(const Value *constants, uint count)
void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int startLine, const QVector<int> &lineNumberMapping)
{
-#ifdef MOTH_THREADED_INTERPRETER
-#define MOTH_INSTR_ADDR(I) &&op_int_##I,
- static void *jumpTable[] = {
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_ADDR)
- };
-#undef MOTH_INSTR_ADDR
-#endif
+ MOTH_JUMP_TABLE;
int lastLine = -1;
const char *start = code;
@@ -131,16 +130,30 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
lastLine = line;
else
line = -1;
+ enum Mode {
+ Normal,
+ Wide,
+ XWide
+ } mode = Normal;
+
+ int codeOffset = (code - start);
+
MOTH_DISPATCH()
MOTH_BEGIN_INSTR(Nop)
MOTH_END_INSTR(Nop)
- MOTH_BEGIN_INSTR(Wide)
- MOTH_END_INSTR(Wide)
-
- MOTH_BEGIN_INSTR(XWide)
- MOTH_END_INSTR(XWide)
+ {
+ INSTR_Wide(MOTH_DECODE) \
+ mode = Wide;
+ MOTH_DISPATCH_WIDE();
+ }
+
+ {
+ INSTR_XWide(MOTH_DECODE) \
+ mode = XWide;
+ MOTH_DISPATCH_XWIDE();
+ }
MOTH_BEGIN_INSTR(LoadReg)
d << StackSlot::createRegister(reg).dump(nFormals);
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<const type *>(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 {
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 78970ef10d..6a58fcd42d 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -519,13 +519,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
{
qt_v4ResolvePendingBreakpointsHook();
-#ifdef MOTH_THREADED_INTERPRETER
-#define MOTH_INSTR_ADDR(I) &&op_int_##I,
- static void *jumpTable[] = {
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_ADDR)
- };
-#undef MOTH_INSTR_ADDR
-#endif
+ MOTH_JUMP_TABLE;
ExecutionEngine *engine = function->internalClass->engine;
Profiling::FunctionCallProfiler(engine, function);
@@ -565,12 +559,12 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
MOTH_END_INSTR(Nop)
MOTH_BEGIN_INSTR(Wide)
- ; // nop
- MOTH_END_INSTR(Wide)
+ MOTH_DISPATCH_WIDE()
+ }
MOTH_BEGIN_INSTR(XWide)
- ; // nop
- MOTH_END_INSTR(XWide)
+ MOTH_DISPATCH_XWIDE()
+ }
MOTH_BEGIN_INSTR(LoadConst)
accumulator = constant(function, index);