diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 0b2f3ab1254..1cd1866e934 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -2003,6 +2003,21 @@ ThrowCompletionOr Mul::execute_impl(Bytecode::Interpreter& interpreter) co return {}; } +ThrowCompletionOr Div::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_number() && rhs.is_number()) [[likely]] { + interpreter.set(m_dst, Value(lhs.as_double() / rhs.as_double())); + return {}; + } + + interpreter.set(m_dst, TRY(div(vm, lhs, rhs))); + return {}; +} + ThrowCompletionOr Sub::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); diff --git a/Libraries/LibJS/Bytecode/Op.h b/Libraries/LibJS/Bytecode/Op.h index c7e82ca793e..da0968ae9fc 100644 --- a/Libraries/LibJS/Bytecode/Op.h +++ b/Libraries/LibJS/Bytecode/Op.h @@ -113,6 +113,7 @@ private: O(BitwiseAnd, bitwise_and) \ O(BitwiseOr, bitwise_or) \ O(BitwiseXor, bitwise_xor) \ + O(Div, div) \ O(GreaterThan, greater_than) \ O(GreaterThanEquals, greater_than_equals) \ O(LeftShift, left_shift) \ @@ -124,7 +125,6 @@ private: O(UnsignedRightShift, unsigned_right_shift) #define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \ - O(Div, div) \ O(Exp, exp) \ O(Mod, mod) \ O(In, in) \