diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-16 14:45:25 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-25 11:56:05 +0000 |
commit | 69a1018c9737751c2cc7daae2c03882dc81bd104 (patch) | |
tree | c0aa531dafbffcf0421454229a6bcd7f0aa828ee /src/qml/compiler/qv4codegen.cpp | |
parent | 29e1531252ef435086a2b84e20a8e83304ca30bc (diff) |
Add optimized branch instructions for comparisons with ints
Change-Id: Ib5d5dc3b0e4a67b950ca9804edd3b6434fcdf9d1
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 379db2cd9c..5a7c12d0a2 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1064,19 +1064,33 @@ Codegen::Reference Codegen::jumpBinop(QSOperator::Op oper, Reference &left, Refe jumpTarget = _expr.iffalse(); } - if (right.isConst()) { - if (right.constant == Encode::null() || right.constant == Encode::undefined()) { + if (right.isConst() && (oper == QSOperator::Equal || oper == QSOperator::NotEqual)) { + Value c = Primitive::fromReturnedValue(right.constant); + if (c.isNull() || c.isUndefined()) { + left.loadInAccumulator(); if (oper == QSOperator::Equal) { - left.loadInAccumulator(); Instruction::CmpJmpEqNull cjump; bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); return Reference(); } else if (oper == QSOperator::NotEqual) { - left.loadInAccumulator(); Instruction::CmpJmpNeNull cjump; bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); return Reference(); } + } else if (c.isInt32()) { + left.loadInAccumulator(); + if (oper == QSOperator::Equal) { + Instruction::CmpJmpEqInt cjump; + cjump.lhs = c.int_32(); + bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); + return Reference(); + } else if (oper == QSOperator::NotEqual) { + Instruction::CmpJmpNeInt cjump; + cjump.lhs = c.int_32(); + bytecodeGenerator->addJumpInstruction(cjump).link(*jumpTarget); + return Reference(); + } + } } |