aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-11-08 14:57:35 +0100
committerLars Knoll <lars.knoll@qt.io>2017-11-14 21:46:27 +0000
commitd1e2c75559e2fde61f9ec55d93b5730d8e11e8be (patch)
treea9502b523b4d60002869873cc678aa9ca9fc70e9
parent30ada3da8635f3e496ea6cb9483aa104d32e5a61 (diff)
V4: Tweak JumpTrue/JumpFalse interpreter instructions
For JumpTrue, when the accumulator held false/0, the Value::toBoolean method would be called even though the value was already a boolean. The same for JumpFalse and a true value. Change-Id: I0d0e8b9d090dcd4fb69ec9df4f60ed37cfce32ba Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index a6cfa7cff1..9eb51763ca 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -973,17 +973,23 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject,
MOTH_END_INSTR(Jump)
MOTH_BEGIN_INSTR(JumpTrue)
- //### store a type hint, and if the input is a bool, do:
- // ((acc & 1) == 1)
- // because if(1) will end up here with an integer in the accumulator
- if ((ACC.integerCompatible() && ACC.int_32()) || ACC.toBoolean())
- code += offset;
+ if (Q_LIKELY(ACC.integerCompatible())) {
+ if (ACC.int_32())
+ code += offset;
+ } else {
+ if (ACC.toBoolean())
+ code += offset;
+ }
MOTH_END_INSTR(JumpTrue)
MOTH_BEGIN_INSTR(JumpFalse)
- //### see comment for JumpTrue
- if ((ACC.integerCompatible() && !ACC.int_32()) || !ACC.toBoolean())
- code += offset;
+ if (Q_LIKELY(ACC.integerCompatible())) {
+ if (!ACC.int_32())
+ code += offset;
+ } else {
+ if (!ACC.toBoolean())
+ code += offset;
+ }
MOTH_END_INSTR(JumpFalse)
MOTH_BEGIN_INSTR(CmpEqNull)