aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-10-11 11:59:40 +0200
committerLars Knoll <lars.knoll@qt.io>2017-10-23 06:27:49 +0000
commit44a47106419ea4daea077320cf5f857fe6ae8b47 (patch)
tree6782e08c532ff43342ae88ff7d0fb7ad54ddfd8b /src/qml/jsruntime
parent2a8d1f27df08aa42fae3d9b80abc4a7935d3ba63 (diff)
Remove Binop/BinopContext instructions and implement missing binops
Change-Id: Ibefac50246045066c90c4c2dbc36d2776c5dab0e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4value_p.h7
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp49
2 files changed, 38 insertions, 18 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 63433b7955..8497d47800 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -788,12 +788,13 @@ ReturnedValue value_convert(ExecutionEngine *e, const Value &v);
inline int Value::toInt32() const
{
- if (integerCompatible())
+ if (Q_LIKELY(integerCompatible()))
return int_32();
- double d = isDouble() ? doubleValue() : toNumberImpl();
+ if (Q_LIKELY(isDouble()))
+ return Double::toInt32(doubleValue());
- return Double::toInt32(d);
+ return Double::toInt32(toNumberImpl());
}
inline unsigned int Value::toUInt32() const
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 4abd3582dd..6823cf0000 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -496,7 +496,6 @@ static bool compareEqualInt(Value &accumulator, Value lhs, int rhs)
} \
} while (false)
-
QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
{
qt_v4ResolvePendingBreakpointsHook();
@@ -1091,6 +1090,18 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
}
MOTH_END_INSTR(CmpStrictNotEqual)
+ MOTH_BEGIN_INSTR(CmpIn)
+ STORE_ACC();
+ acc = Runtime::method_in(engine, STACK_VALUE(lhs), accumulator);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(CmpIn)
+
+ MOTH_BEGIN_INSTR(CmpInstanceOf)
+ STORE_ACC();
+ acc = Runtime::method_instanceof(engine, STACK_VALUE(lhs), accumulator);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(CmpInstanceOf)
+
MOTH_BEGIN_INSTR(JumpStrictNotEqualStackSlotInt)
if (STACK_VALUE(lhs).int_32() != rhs || STACK_VALUE(lhs).isUndefined())
code += offset;
@@ -1159,13 +1170,6 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
}
MOTH_END_INSTR(Decrement)
- MOTH_BEGIN_INSTR(Binop)
- QV4::Runtime::BinaryOperation op = *reinterpret_cast<QV4::Runtime::BinaryOperation *>(reinterpret_cast<char *>(&engine->runtime.runtimeMethods[alu]));
- STORE_ACC();
- acc = op(STACK_VALUE(lhs), accumulator);
- CHECK_EXCEPTION;
- MOTH_END_INSTR(Binop)
-
MOTH_BEGIN_INSTR(Add)
const Value left = STACK_VALUE(lhs);
if (Q_LIKELY(Value::integerCompatible(left, ACC))) {
@@ -1205,6 +1209,18 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
}
MOTH_END_INSTR(Mul)
+ MOTH_BEGIN_INSTR(Div)
+ STORE_ACC();
+ acc = Runtime::method_div(STACK_VALUE(lhs), accumulator);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(Div)
+
+ MOTH_BEGIN_INSTR(Mod)
+ STORE_ACC();
+ acc = Runtime::method_mod(STACK_VALUE(lhs), accumulator);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(Mod)
+
MOTH_BEGIN_INSTR(BitAnd)
VALUE_TO_INT(l, STACK_VALUE(lhs));
VALUE_TO_INT(a, ACC);
@@ -1223,6 +1239,12 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
acc = Encode(l ^ a);
MOTH_END_INSTR(BitXor)
+ MOTH_BEGIN_INSTR(UShr)
+ uint l = STACK_VALUE(lhs).toUInt32();
+ VALUE_TO_INT(a, ACC);
+ acc = Encode(l >> uint(a & 0x1f));
+ MOTH_END_INSTR(UShr)
+
MOTH_BEGIN_INSTR(Shr)
VALUE_TO_INT(l, STACK_VALUE(lhs));
VALUE_TO_INT(a, ACC);
@@ -1251,6 +1273,10 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
acc = Encode(a ^ rhs);
MOTH_END_INSTR(BitXorConst)
+ MOTH_BEGIN_INSTR(UShrConst)
+ acc = Encode(ACC.toUInt32() >> uint(rhs));
+ MOTH_END_INSTR(UShrConst)
+
MOTH_BEGIN_INSTR(ShrConst)
VALUE_TO_INT(a, ACC);
acc = Encode(a >> rhs);
@@ -1261,13 +1287,6 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function)
acc = Encode(a << rhs);
MOTH_END_INSTR(ShlConst)
- MOTH_BEGIN_INSTR(BinopContext)
- STORE_ACC();
- QV4::Runtime::BinaryOperationContext op = *reinterpret_cast<QV4::Runtime::BinaryOperationContext *>(reinterpret_cast<char *>(&engine->runtime.runtimeMethods[alu]));
- acc = op(engine, STACK_VALUE(lhs), accumulator);
- CHECK_EXCEPTION;
- MOTH_END_INSTR(BinopContext)
-
MOTH_BEGIN_INSTR(Ret)
goto functionExit;
MOTH_END_INSTR(Ret)