diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-06 11:41:21 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-08 18:59:02 +0000 |
commit | 64a20f9277f5461640e531a6dc1ca28ae91afa39 (patch) | |
tree | 6f4020b49ce8e16231216f05e71264b3225c4312 /src | |
parent | d24da7f9497834f982e5cd6e29ff53b73fbac1a3 (diff) |
Use the accumulator for the rhs of CmpJmp instructions
Change-Id: Ib7923863a88aacab93b06fa3c75d788fcfc0bf4e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 8 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 12 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 60 |
4 files changed, 34 insertions, 52 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 1ad7e59203..d00e29bc09 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -991,7 +991,7 @@ static QSOperator::Op invert(QSOperator::Op oper) Codegen::Reference Codegen::jumpBinop(QSOperator::Op oper, Reference &left, Reference &right) { left = left.storeOnStack(); - right = right.storeOnStack(); + right.loadInAccumulator(); const BytecodeGenerator::Label *jumpTarget = _expr.iftrue(); if (_expr.trueBlockFollowsCondition()) { oper = invert(oper); @@ -1002,42 +1002,36 @@ Codegen::Reference Codegen::jumpBinop(QSOperator::Op oper, Reference &left, Refe case QSOperator::Equal: { Instruction::CmpJmpEq cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } case QSOperator::NotEqual: { Instruction::CmpJmpNe cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } case QSOperator::Gt: { Instruction::CmpJmpGt cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } case QSOperator::Ge: { Instruction::CmpJmpGe cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } case QSOperator::Lt: { Instruction::CmpJmpLt cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } case QSOperator::Le: { Instruction::CmpJmpLe cjump; cjump.lhs = left.stackSlot(); - cjump.rhs = right.stackSlot(); bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); break; } diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index 119b6d9960..e4b64bc287 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -373,27 +373,27 @@ void dumpBytecode(const char *code, int len, int nFormals) MOTH_END_INSTR(JumpNe) MOTH_BEGIN_INSTR(CmpJmpEq) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpEq) MOTH_BEGIN_INSTR(CmpJmpNe) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpNe) MOTH_BEGIN_INSTR(CmpJmpGt) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpGt) MOTH_BEGIN_INSTR(CmpJmpGe) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpGe) MOTH_BEGIN_INSTR(CmpJmpLt) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpLt) MOTH_BEGIN_INSTR(CmpJmpLe) - d << instr.lhs.dump(nFormals) << ", " << instr.rhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); + d << instr.lhs.dump(nFormals) << ", " << absoluteInstructionOffset(start, instr); MOTH_END_INSTR(CmpJmpLe) MOTH_BEGIN_INSTR(JumpStrictEqual) diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 24a840efba..19c358eef7 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -559,37 +559,31 @@ union Instr struct instr_cmpJmpEq { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_cmpJmpNe { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_cmpJmpGt { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_cmpJmpGe { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_cmpJmpLt { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_cmpJmpLe { MOTH_INSTR_HEADER StackSlot lhs; - StackSlot rhs; ptrdiff_t offset; }; struct instr_jumpStrictEqual { diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index e75b8e6911..052eea7b55 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -791,86 +791,80 @@ QV4::ReturnedValue VME::exec(Function *function) MOTH_BEGIN_INSTR(CmpJmpEq) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.asReturnedValue() == rhs.asReturnedValue())) { + if (Q_LIKELY(lhs.asReturnedValue() == accumulator.asReturnedValue())) { code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; - } else if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() == rhs.int_32()) + } else if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() == accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareEqual(lhs, rhs)) + if (Runtime::method_compareEqual(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpEq) MOTH_BEGIN_INSTR(CmpJmpNe) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() != rhs.int_32()) + if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() != accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareNotEqual(lhs, rhs)) + if (Runtime::method_compareNotEqual(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpNe) MOTH_BEGIN_INSTR(CmpJmpGt) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() > rhs.int_32()) + if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() > accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; - } if (lhs.isNumber() && rhs.isNumber()) { - if (lhs.asDouble() > rhs.asDouble()) + } if (lhs.isNumber() && accumulator.isNumber()) { + if (lhs.asDouble() > accumulator.asDouble()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareGreaterThan(lhs, rhs)) + if (Runtime::method_compareGreaterThan(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpGt) MOTH_BEGIN_INSTR(CmpJmpGe) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() >= rhs.int_32()) + if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() >= accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; - } if (lhs.isNumber() && rhs.isNumber()) { - if (lhs.asDouble() >= rhs.asDouble()) + } if (lhs.isNumber() && accumulator.isNumber()) { + if (lhs.asDouble() >= accumulator.asDouble()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareGreaterEqual(lhs, rhs)) + if (Runtime::method_compareGreaterEqual(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpGe) MOTH_BEGIN_INSTR(CmpJmpLt) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() < rhs.int_32()) + if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() < accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; - } if (lhs.isNumber() && rhs.isNumber()) { - if (lhs.asDouble() < rhs.asDouble()) + } if (lhs.isNumber() && accumulator.isNumber()) { + if (lhs.asDouble() < accumulator.asDouble()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareLessThan(lhs, rhs)) + if (Runtime::method_compareLessThan(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpLt) MOTH_BEGIN_INSTR(CmpJmpLe) const Value lhs = STACK_VALUE(instr.lhs); - const Value rhs = STACK_VALUE(instr.rhs); - if (Q_LIKELY(lhs.isInteger() && rhs.isInteger())) { - if (lhs.int_32() <= rhs.int_32()) + if (Q_LIKELY(lhs.isInteger() && accumulator.isInteger())) { + if (lhs.int_32() <= accumulator.int_32()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; - } if (lhs.isNumber() && rhs.isNumber()) { - if (lhs.asDouble() <= rhs.asDouble()) + } if (lhs.isNumber() && accumulator.isNumber()) { + if (lhs.asDouble() <= accumulator.asDouble()) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } else { - if (Runtime::method_compareLessEqual(lhs, rhs)) + if (Runtime::method_compareLessEqual(lhs, accumulator)) code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset; } MOTH_END_INSTR(CmpJmpLe) |