mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibJS: Add fast path for multiplying two Int32 values
We can avoid a lot of work here, as long as the result doesn't overflow the Int32 range. 5% speed-up on Kraken/imaging-gaussian-blur.js :^)
This commit is contained in:
parent
14a9cfef4d
commit
111622a164
1 changed files with 8 additions and 0 deletions
|
@ -1818,6 +1818,14 @@ ThrowCompletionOr<Value> sub(VM& vm, Value lhs, Value rhs)
|
||||||
// MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
|
// MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
|
||||||
ThrowCompletionOr<Value> mul(VM& vm, Value lhs, Value rhs)
|
ThrowCompletionOr<Value> mul(VM& vm, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
|
// OPTIMIZATION: Fast path for multiplication of two Int32 values.
|
||||||
|
if (lhs.is_int32() && rhs.is_int32()) {
|
||||||
|
Checked<i32> result = lhs.as_i32();
|
||||||
|
result *= rhs.as_i32();
|
||||||
|
if (!result.has_overflow())
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
|
||||||
// 13.15.3 ApplyStringOrNumericBinaryOperator ( lval, opText, rval ), https://tc39.es/ecma262/#sec-applystringornumericbinaryoperator
|
// 13.15.3 ApplyStringOrNumericBinaryOperator ( lval, opText, rval ), https://tc39.es/ecma262/#sec-applystringornumericbinaryoperator
|
||||||
// 1-2, 6. N/A.
|
// 1-2, 6. N/A.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue