diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-08-22 12:29:20 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-09-10 15:52:24 +0200 |
commit | 36b365040a18653b3c522ea573a506b955b6c4da (patch) | |
tree | 09a2aac4ce9c246aeb7272fe59ee8ed0ed981678 /src/qml/jsruntime/qv4runtime_p.h | |
parent | dac6bad5ba411ccc4e6e5fe18250a912d7e87b9c (diff) |
V4 runtime: tune Runtime::add/sub/mul a bit.
Tell the compiler to schedule the int32 case first, tune the double
conversion a bit (int64->double is quite expensive), and write the
function in such a way that it matches typical overflow idiom which
compilers recognize.
Change-Id: Ieae9a60275716002fbdbc54e1d7291c8aad8c927
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 53aea521dc..6042420291 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -338,8 +338,8 @@ inline ReturnedValue Runtime::add(ExecutionContext *ctx, const ValueRef left, co { TRACE2(left, right); - if (left->isInteger() && right->isInteger()) - return add_int32(left->integerValue(), right->integerValue()).asReturnedValue(); + if (Q_LIKELY(left->isInteger() && right->isInteger())) + return add_int32(left->integerValue(), right->integerValue()); if (left->isNumber() && right->isNumber()) return Primitive::fromDouble(left->asDouble() + right->asDouble()).asReturnedValue(); @@ -351,8 +351,8 @@ inline ReturnedValue Runtime::sub(const ValueRef left, const ValueRef right) { TRACE2(left, right); - if (left->isInteger() && right->isInteger()) - return sub_int32(left->integerValue(), right->integerValue()).asReturnedValue(); + if (Q_LIKELY(left->isInteger() && right->isInteger())) + return sub_int32(left->integerValue(), right->integerValue()); double lval = left->isNumber() ? left->asDouble() : left->toNumberImpl(); double rval = right->isNumber() ? right->asDouble() : right->toNumberImpl(); @@ -364,8 +364,8 @@ inline ReturnedValue Runtime::mul(const ValueRef left, const ValueRef right) { TRACE2(left, right); - if (left->isInteger() && right->isInteger()) - return mul_int32(left->integerValue(), right->integerValue()).asReturnedValue(); + if (Q_LIKELY(left->isInteger() && right->isInteger())) + return mul_int32(left->integerValue(), right->integerValue()); double lval = left->isNumber() ? left->asDouble() : left->toNumberImpl(); double rval = right->isNumber() ? right->asDouble() : right->toNumberImpl(); |