aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp46
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp133
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h42
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp12
4 files changed, 77 insertions, 156 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index 401730c275..9feafb8bd4 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -69,27 +69,26 @@ int BytecodeGenerator::newRegisterArray(int n)
void BytecodeGenerator::packInstruction(I &i)
{
+ uchar type = *reinterpret_cast<uchar *>(i.packed);
+ Q_ASSERT(type >= MOTH_NUM_INSTRUCTIONS());
+ if (type >= MOTH_NUM_INSTRUCTIONS())
+ type -= MOTH_NUM_INSTRUCTIONS();
int instructionsAsInts[sizeof(Instr)/sizeof(int)];
int nMembers = Moth::Instr::argumentCount[static_cast<int>(i.type)];
- char *data = i.packed;
- Q_ASSERT(*data == static_cast<char>(Instr::Type::XWide));
- data += 2;
- memcpy(instructionsAsInts, data, nMembers*sizeof(int));
+ memcpy(instructionsAsInts, i.packed + 1, nMembers*sizeof(int));
enum {
Normal,
- Wide,
- XWide
+ Wide
} width = Normal;
for (int n = 0; n < nMembers; ++n) {
if (width == Normal && (static_cast<char>(instructionsAsInts[n]) != instructionsAsInts[n]))
width = Wide;
- if (width == Wide && (static_cast<short>(instructionsAsInts[n]) != instructionsAsInts[n]))
- width = XWide;
}
char *code = i.packed;
switch (width) {
case Normal:
- *code++ = static_cast<char>(i.type);
+ *reinterpret_cast<uchar *>(code) = type;
+ ++code;
for (int n = 0; n < nMembers; ++n) {
char v = static_cast<char>(instructionsAsInts[n]);
memcpy(code, &v, 1);
@@ -100,18 +99,6 @@ void BytecodeGenerator::packInstruction(I &i)
i.offsetForJump = i.size - 1;
break;
case Wide:
- *code++ = static_cast<char>(Instr::Type::Wide);
- *code++ = static_cast<char>(i.type);
- for (int n = 0; n < nMembers; ++n) {
- short v = static_cast<short>(instructionsAsInts[n]);
- memcpy(code, &v, 2);
- code += 2;
- }
- i.size = code - i.packed;
- if (i.offsetForJump != -1)
- i.offsetForJump = i.size - 2;
- break;
- case XWide:
// nothing to do
break;
}
@@ -129,14 +116,10 @@ void BytecodeGenerator::adjustJumpOffsets()
int jumpOffset = linkedInstruction.position - (i.position + i.size);
// qDebug() << "adjusting jump offset for instruction" << index << i.position << i.size << "offsetForJump" << i.offsetForJump << "target"
// << labels.at(i.linkedLabel) << linkedInstruction.position << "jumpOffset" << jumpOffset;
- if (*i.packed == static_cast<char>(Instr::Type::XWide)) {
+ uchar type = *reinterpret_cast<const uchar *>(i.packed);
+ if (type >= MOTH_NUM_INSTRUCTIONS()) {
Q_ASSERT(i.offsetForJump == i.size - 4);
memcpy(c, &jumpOffset, sizeof(int));
- } else if (*i.packed == static_cast<char>(Instr::Type::Wide)) {
- Q_ASSERT(i.offsetForJump == i.size - 2);
- short o = jumpOffset;
- Q_ASSERT(o == jumpOffset);
- memcpy(c, &o, sizeof(short));
} else {
Q_ASSERT(i.offsetForJump == i.size - 1);
char o = jumpOffset;
@@ -199,11 +182,12 @@ int BytecodeGenerator::addInstructionHelper(Instr::Type type, const Instr &i, in
int pos = instructions.size();
int s = Moth::Instr::argumentCount[static_cast<int>(type)]*sizeof(int);
if (offsetOfOffset != -1)
- offsetOfOffset += 2;
- I instr{type, static_cast<short>(s + 2), 0, currentLine, offsetOfOffset, -1, "\0\0" };
+ offsetOfOffset += 1;
+ I instr{type, static_cast<short>(s + 1), 0, currentLine, offsetOfOffset, -1, "\0\0" };
char *code = instr.packed;
- *code++ = static_cast<char>(Instr::Type::XWide);
- *code++ = static_cast<char>(type);
+ *reinterpret_cast<uchar *>(code) = static_cast<uchar>(MOTH_NUM_INSTRUCTIONS() + static_cast<int>(type));
+ ++code;
+ Q_ASSERT(MOTH_NUM_INSTRUCTIONS() + static_cast<int>(type) < 256);
memcpy(code, &i, s);
instructions.append(instr);
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index 8f639453bd..4a440e8d0a 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -92,12 +92,7 @@ static QString toString(QV4::ReturnedValue v)
QDebug d = qDebug(); \
d.noquote(); \
d.nospace(); \
- d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " << #instr; \
- switch(mode) { \
- case Normal: d << " "; break; \
- case Wide: d << ".Wide "; break; \
- case XWide: d << ".XWide "; break; \
- }
+ d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " << #instr << " "; \
#define MOTH_END_INSTR(instr) \
continue; \
@@ -135,41 +130,21 @@ 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)
-
- {
- 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);
+ d << StackSlot::dump(reg, nFormals);
MOTH_END_INSTR(LoadReg)
MOTH_BEGIN_INSTR(StoreReg)
- d << StackSlot::createRegister(reg).dump(nFormals);
+ d << StackSlot::dump(reg, nFormals);
MOTH_END_INSTR(StoreReg)
MOTH_BEGIN_INSTR(MoveReg)
- d << StackSlot::createRegister(destReg).dump(nFormals) << ", " << StackSlot::createRegister(srcReg).dump(nFormals);
+ d << StackSlot::dump(destReg, nFormals) << ", " << StackSlot::dump(srcReg, nFormals);
MOTH_END_INSTR(MoveReg)
MOTH_BEGIN_INSTR(LoadConst)
@@ -196,7 +171,7 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(LoadInt)
MOTH_BEGIN_INSTR(MoveConst)
- d << StackSlot::createRegister(destTemp).dump(nFormals) << ", C" << constIndex;
+ d << StackSlot::dump(destTemp, nFormals) << ", C" << constIndex;
MOTH_END_INSTR(MoveConst)
MOTH_BEGIN_INSTR(LoadScopedLocal)
@@ -242,19 +217,19 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(StoreNameStrict)
MOTH_BEGIN_INSTR(LoadElement)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << StackSlot::createRegister(index).dump(nFormals) << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << StackSlot::dump(index, nFormals) << "]";
MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(LoadElementA)
- d << StackSlot::createRegister(base).dump(nFormals) << "[acc]";
+ d << StackSlot::dump(base, nFormals) << "[acc]";
MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(StoreElement)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << StackSlot::createRegister(index).dump(nFormals) << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << StackSlot::dump(index, nFormals) << "]";
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << name << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << name << "]";
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(LoadPropertyA)
@@ -262,7 +237,7 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(LoadElementA)
MOTH_BEGIN_INSTR(GetLookup)
- d << StackSlot::createRegister(base).dump(nFormals) << "(" << index << ")";
+ d << StackSlot::dump(base, nFormals) << "(" << index << ")";
MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(GetLookupA)
@@ -270,59 +245,59 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(GetLookupA)
MOTH_BEGIN_INSTR(StoreProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << name<< "]";
+ d << StackSlot::dump(base, nFormals) << "[" << name<< "]";
MOTH_END_INSTR(StoreProperty)
MOTH_BEGIN_INSTR(SetLookup)
- d << StackSlot::createRegister(base).dump(nFormals);
+ d << StackSlot::dump(base, nFormals);
MOTH_END_INSTR(SetLookup)
MOTH_BEGIN_INSTR(StoreScopeObjectProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << propertyIndex << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << propertyIndex << "]";
MOTH_END_INSTR(StoreScopeObjectProperty)
MOTH_BEGIN_INSTR(LoadScopeObjectProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << propertyIndex << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << propertyIndex << "]";
MOTH_END_INSTR(LoadScopeObjectProperty)
MOTH_BEGIN_INSTR(StoreContextObjectProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << propertyIndex << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << propertyIndex << "]";
MOTH_END_INSTR(StoreContextObjectProperty)
MOTH_BEGIN_INSTR(LoadContextObjectProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << propertyIndex << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << propertyIndex << "]";
MOTH_END_INSTR(LoadContextObjectProperty)
MOTH_BEGIN_INSTR(LoadIdObject)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << index << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << index << "]";
MOTH_END_INSTR(LoadIdObject)
MOTH_BEGIN_INSTR(CallValue)
- d << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallValue)
MOTH_BEGIN_INSTR(CallProperty)
- d << StackSlot::createRegister(base).dump(nFormals) << "." << name << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << StackSlot::dump(base, nFormals) << "." << name << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallPropertyLookup)
- d << lookupIndex << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << lookupIndex << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallPropertyLookup)
MOTH_BEGIN_INSTR(CallElement)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << StackSlot::createRegister(index).dump(nFormals) << "]" << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << StackSlot::dump(base, nFormals) << "[" << StackSlot::dump(index, nFormals) << "]" << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallElement)
MOTH_BEGIN_INSTR(CallName)
- d << name << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << name << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallName)
MOTH_BEGIN_INSTR(CallPossiblyDirectEval)
- d << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallPossiblyDirectEval)
MOTH_BEGIN_INSTR(CallGlobalLookup)
- d << index << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << index << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(CallGlobalLookup)
MOTH_BEGIN_INSTR(SetExceptionHandler)
@@ -345,15 +320,15 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(UnwindException)
MOTH_BEGIN_INSTR(PushCatchContext)
- d << StackSlot::createRegister(reg).dump(nFormals) << ", " << name;
+ d << StackSlot::dump(reg, nFormals) << ", " << name;
MOTH_END_INSTR(PushCatchContext)
MOTH_BEGIN_INSTR(PushWithContext)
- d << StackSlot::createRegister(reg).dump(nFormals);
+ d << StackSlot::dump(reg, nFormals);
MOTH_END_INSTR(PushWithContext)
MOTH_BEGIN_INSTR(PopContext)
- d << StackSlot::createRegister(reg).dump(nFormals);
+ d << StackSlot::dump(reg, nFormals);
MOTH_END_INSTR(PopContext)
MOTH_BEGIN_INSTR(ForeachIteratorObject)
@@ -363,11 +338,11 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(ForeachNextPropertyName)
MOTH_BEGIN_INSTR(DeleteMember)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << member << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << member << "]";
MOTH_END_INSTR(DeleteMember)
MOTH_BEGIN_INSTR(DeleteSubscript)
- d << StackSlot::createRegister(base).dump(nFormals) << "[" << StackSlot::createRegister(index).dump(nFormals) << "]";
+ d << StackSlot::dump(base, nFormals) << "[" << StackSlot::dump(index, nFormals) << "]";
MOTH_END_INSTR(DeleteSubscript)
MOTH_BEGIN_INSTR(DeleteName)
@@ -386,11 +361,11 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(DeclareVar)
MOTH_BEGIN_INSTR(DefineArray)
- d << StackSlot::createRegister(args).dump(nFormals) << ", " << argc;
+ d << StackSlot::dump(args, nFormals) << ", " << argc;
MOTH_END_INSTR(DefineArray)
MOTH_BEGIN_INSTR(DefineObjectLiteral)
- d << StackSlot::createRegister(args).dump(nFormals)
+ d << StackSlot::dump(args, nFormals)
<< ", " << internalClassId
<< ", " << arrayValueCount
<< ", " << arrayGetterSetterCountAndFlags;
@@ -406,7 +381,7 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(ConvertThisToObject)
MOTH_BEGIN_INSTR(Construct)
- d << "new" << StackSlot::createRegister(func).dump(nFormals) << "(" << StackSlot::createRegister(callData).dump(nFormals) << ")";
+ d << "new" << StackSlot::dump(func, nFormals) << "(" << StackSlot::dump(callData, nFormals) << ")";
MOTH_END_INSTR(Construct)
MOTH_BEGIN_INSTR(Jump)
@@ -439,43 +414,43 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_BEGIN_INSTR(CmpJmpEq)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpEq)
MOTH_BEGIN_INSTR(CmpJmpNe)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpNe)
MOTH_BEGIN_INSTR(CmpJmpGt)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpGt)
MOTH_BEGIN_INSTR(CmpJmpGe)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpGe)
MOTH_BEGIN_INSTR(CmpJmpLt)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpLt)
MOTH_BEGIN_INSTR(CmpJmpLe)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(CmpJmpLe)
MOTH_BEGIN_INSTR(JumpStrictEqual)
- d << StackSlot::createRegister(lhs).dump(nFormals) << " " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << " " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(JumpStrictEqual)
MOTH_BEGIN_INSTR(JumpStrictNotEqual)
- d << StackSlot::createRegister(lhs).dump(nFormals) << " " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << " " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(JumpStrictNotEqual)
MOTH_BEGIN_INSTR(JumpStrictEqualStackSlotInt)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(JumpStrictEqualStackSlotInt)
MOTH_BEGIN_INSTR(JumpStrictNotEqualStackSlotInt)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
+ d << StackSlot::dump(lhs, nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
MOTH_END_INSTR(JumpStrictNotEqualStackSlotInt)
MOTH_BEGIN_INSTR(UNot)
@@ -497,31 +472,31 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(PreDecrement)
MOTH_BEGIN_INSTR(Binop)
- d << alu << ", " << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << alu << ", " << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Binop)
MOTH_BEGIN_INSTR(Add)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Add)
MOTH_BEGIN_INSTR(BitAnd)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(BitAnd)
MOTH_BEGIN_INSTR(BitOr)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(BitOr)
MOTH_BEGIN_INSTR(BitXor)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(BitXor)
MOTH_BEGIN_INSTR(Shr)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Shr)
MOTH_BEGIN_INSTR(Shl)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Shl)
MOTH_BEGIN_INSTR(BitAndConst)
@@ -545,15 +520,15 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
MOTH_END_INSTR(ShlConst)
MOTH_BEGIN_INSTR(Mul)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Mul)
MOTH_BEGIN_INSTR(Sub)
- d << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Sub)
MOTH_BEGIN_INSTR(BinopContext)
- d << alu << " " << StackSlot::createRegister(lhs).dump(nFormals) << ", acc";
+ d << alu << " " << StackSlot::dump(lhs, nFormals) << ", acc";
MOTH_END_INSTR(BinopContext)
MOTH_BEGIN_INSTR(Ret)
@@ -565,11 +540,11 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star
#endif // QT_NO_QML_DEBUGGER
MOTH_BEGIN_INSTR(LoadQmlContext)
- d << StackSlot::createRegister(result).dump(nFormals);
+ d << StackSlot::dump(result, nFormals);
MOTH_END_INSTR(LoadQmlContext)
MOTH_BEGIN_INSTR(LoadQmlImportedScripts)
- d << StackSlot::createRegister(result).dump(nFormals);
+ d << StackSlot::dump(result, nFormals);
MOTH_END_INSTR(LoadQmlImportedScripts)
MOTH_BEGIN_INSTR(LoadQmlSingleton)
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 {
};
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index c43db37ed2..37b95c41c6 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -539,18 +539,6 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
for (;;) {
MOTH_DISPATCH()
- MOTH_BEGIN_INSTR(Nop)
- MOTH_DISPATCH()
- }
-
- MOTH_BEGIN_INSTR(Wide)
- MOTH_DISPATCH_WIDE()
- }
-
- MOTH_BEGIN_INSTR(XWide)
- MOTH_DISPATCH_XWIDE()
- }
-
MOTH_BEGIN_INSTR(LoadConst)
accumulator = constant(function, index);
MOTH_END_INSTR(LoadConst)