aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-06-07 11:35:20 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-06-07 14:32:02 +0000
commitd2c09b41ddc82dda5c5228b1f295850bb1c58f4c (patch)
tree1b1d0518119805a0396395b89e8acd9cd1fcf098 /src/qml
parenta6eac7e299016c9ee8742abffd780683adac3066 (diff)
Jit: fix unary minus for integers
Change-Id: Ib2cdfe6f09528d169e9ea6f8b872de875317c9c9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jit/qv4unop.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qml/jit/qv4unop.cpp b/src/qml/jit/qv4unop.cpp
index 896be07ed5..78546e1509 100644
--- a/src/qml/jit/qv4unop.cpp
+++ b/src/qml/jit/qv4unop.cpp
@@ -83,6 +83,15 @@ template <typename JITAssembler>
void Unop<JITAssembler>::generateUMinus(IR::Expr *source, IR::Expr *target)
{
IR::Temp *targetTemp = target->asTemp();
+
+ if (IR::Const *c = source->asConst()) {
+ if (c->value == 0 && source->type == IR::SInt32Type) {
+ // special case: minus integer 0 is 0, which is not what JS expects it to be, so always
+ // do a runtime call
+ generateRuntimeCall(_as, target, uMinus, PointerToValue(source));
+ return;
+ }
+ }
if (source->type == IR::SInt32Type) {
typename JITAssembler::RegisterID tReg = JITAssembler::ScratchRegister;
if (targetTemp && targetTemp->kind == IR::Temp::PhysicalRegister)