mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05: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
|
||||
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
|
||||
// 1-2, 6. N/A.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue