mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 12:49:08 +00:00
LibJS/Bytecode: Add fast path for LeftShift with Int32 operands
This commit is contained in:
@@ -864,6 +864,20 @@ ThrowCompletionOr<void> RightShift::execute_impl(Bytecode::Interpreter& interpre
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> LeftShift::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto const lhs = interpreter.get(m_lhs);
|
||||
auto const rhs = interpreter.get(m_rhs);
|
||||
if (lhs.is_int32() && rhs.is_int32() && rhs.as_i32() >= 0) {
|
||||
auto const shift_count = static_cast<u32>(rhs.as_i32()) % 32;
|
||||
interpreter.set(m_dst, Value(lhs.as_i32() << shift_count));
|
||||
return {};
|
||||
}
|
||||
interpreter.set(m_dst, TRY(left_shift(vm, lhs, rhs)));
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> LessThan::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
Reference in New Issue
Block a user