aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-02-06 14:56:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-07 10:44:22 +0100
commit357e034f70a60e4016e0f0cd25f97631080cc60a (patch)
tree45ed60f356980c7b0aa5512d9d101d4ce1fe257f /src/qml
parent9a61f10f268f15dc3dcdabe70ec2c4969cf206d8 (diff)
Add specialized instructions for right and left shift
These give a measurable speedup as the critical code paths are now inline. Change-Id: I3cee8a432fbe96d66ba1e6bd277a38e624a50c14 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h32
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp32
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp16
3 files changed, 80 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index a691f37b52..c49b0798ad 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -121,9 +121,13 @@ QT_BEGIN_NAMESPACE
F(BitAnd, bitAnd) \
F(BitOr, bitOr) \
F(BitXor, bitXor) \
+ F(Shr, shr) \
+ F(Shl, shl) \
F(BitAndConst, bitAndConst) \
F(BitOrConst, bitOrConst) \
F(BitXorConst, bitXorConst) \
+ F(ShrConst, shrConst) \
+ F(ShlConst, shlConst) \
F(Mul, mul) \
F(Sub, sub) \
F(BinopContext, binopContext) \
@@ -629,6 +633,18 @@ union Instr
Param rhs;
Param result;
};
+ struct instr_shr {
+ MOTH_INSTR_HEADER
+ Param lhs;
+ Param rhs;
+ Param result;
+ };
+ struct instr_shl {
+ MOTH_INSTR_HEADER
+ Param lhs;
+ Param rhs;
+ Param result;
+ };
struct instr_bitAndConst {
MOTH_INSTR_HEADER
Param lhs;
@@ -647,6 +663,18 @@ union Instr
int rhs;
Param result;
};
+ struct instr_shrConst {
+ MOTH_INSTR_HEADER
+ Param lhs;
+ int rhs;
+ Param result;
+ };
+ struct instr_shlConst {
+ MOTH_INSTR_HEADER
+ Param lhs;
+ int rhs;
+ Param result;
+ };
struct instr_mul {
MOTH_INSTR_HEADER
Param lhs;
@@ -782,9 +810,13 @@ union Instr
instr_bitAnd bitAnd;
instr_bitOr bitOr;
instr_bitXor bitXor;
+ instr_shr shr;
+ instr_shl shl;
instr_bitAndConst bitAndConst;
instr_bitOrConst bitOrConst;
instr_bitXorConst bitXorConst;
+ instr_shrConst shrConst;
+ instr_shlConst shlConst;
instr_mul mul;
instr_sub sub;
instr_binopContext binopContext;
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index b34f5891b3..e67e351ba7 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -806,6 +806,38 @@ Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource
addInstruction(bitXor);
return bitXor.result;
}
+ if (oper == V4IR::OpRShift) {
+ if (V4IR::Const *c = rightSource->asConst()) {
+ Instruction::ShrConst shr;
+ shr.lhs = getParam(leftSource);
+ shr.rhs = convertToValue(c).Value::toInt32() & 0x1f;
+ shr.result = getResultParam(target);
+ addInstruction(shr);
+ return shr.result;
+ }
+ Instruction::Shr shr;
+ shr.lhs = getParam(leftSource);
+ shr.rhs = getParam(rightSource);
+ shr.result = getResultParam(target);
+ addInstruction(shr);
+ return shr.result;
+ }
+ if (oper == V4IR::OpLShift) {
+ if (V4IR::Const *c = rightSource->asConst()) {
+ Instruction::ShlConst shl;
+ shl.lhs = getParam(leftSource);
+ shl.rhs = convertToValue(c).Value::toInt32() & 0x1f;
+ shl.result = getResultParam(target);
+ addInstruction(shl);
+ return shl.result;
+ }
+ Instruction::Shl shl;
+ shl.lhs = getParam(leftSource);
+ shl.rhs = getParam(rightSource);
+ shl.result = getResultParam(target);
+ addInstruction(shl);
+ return shl.result;
+ }
if (oper == V4IR::OpInstanceof || oper == V4IR::OpIn || oper == V4IR::OpAdd) {
Instruction::BinopContext binop;
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index c64a284b4c..a0a021af9a 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -612,6 +612,14 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code
STOREVALUE(instr.result, __qmljs_bit_xor(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
MOTH_END_INSTR(BitXor)
+ MOTH_BEGIN_INSTR(Shr)
+ STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() >> (VALUEPTR(instr.rhs)->toInt32() & 0x1f))));
+ MOTH_END_INSTR(Shr)
+
+ MOTH_BEGIN_INSTR(Shl)
+ STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() << (VALUEPTR(instr.rhs)->toInt32() & 0x1f))));
+ MOTH_END_INSTR(Shl)
+
MOTH_BEGIN_INSTR(BitAndConst)
int lhs = VALUEPTR(instr.lhs)->toInt32();
STOREVALUE(instr.result, QV4::Encode((int)(lhs & instr.rhs)));
@@ -627,6 +635,14 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code
STOREVALUE(instr.result, QV4::Encode((int)(lhs ^ instr.rhs)));
MOTH_END_INSTR(BitXor)
+ MOTH_BEGIN_INSTR(ShrConst)
+ STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() >> instr.rhs)));
+ MOTH_END_INSTR(ShrConst)
+
+ MOTH_BEGIN_INSTR(ShlConst)
+ STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() << instr.rhs)));
+ MOTH_END_INSTR(ShlConst)
+
MOTH_BEGIN_INSTR(Mul)
STOREVALUE(instr.result, __qmljs_mul(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
MOTH_END_INSTR(Mul)