From 78cac671b6166d0f75f49e95600e933dd6398ba6 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 28 Oct 2023 15:19:12 +0300 Subject: [PATCH] LibJS: Pass the expression string to cxx_call as a stack argument This restores the bytecode interpreter's original call exception throwing behaviour to the JIT. This also fixes 8 of the 10 failing test-js tests when running with the JIT enabled. --- Userland/Libraries/LibJS/JIT/Compiler.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 96dc54847c..a844e98e9f 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -858,10 +858,9 @@ void Compiler::compile_put_by_value(Bytecode::Op::PutByValue const& op) check_exception(); } -static Value cxx_call(VM& vm, Value callee, u32 first_argument_index, u32 argument_count, Value this_value, Bytecode::Op::CallType call_type) +static Value cxx_call(VM& vm, Value callee, u32 first_argument_index, u32 argument_count, Value this_value, Bytecode::Op::CallType call_type, Optional const& expression_string) { - // FIXME: Get the expression_string() here as well. - TRY_OR_SET_EXCEPTION(throw_if_needed_for_call(vm.bytecode_interpreter(), callee, call_type, {})); + TRY_OR_SET_EXCEPTION(throw_if_needed_for_call(vm.bytecode_interpreter(), callee, call_type, expression_string)); MarkedVector argument_values(vm.heap()); argument_values.ensure_capacity(argument_count); @@ -884,7 +883,10 @@ void Compiler::compile_call(Bytecode::Op::Call const& op) m_assembler.mov( Assembler::Operand::Register(ARG5), Assembler::Operand::Imm(to_underlying(op.call_type()))); - m_assembler.native_call((void*)cxx_call); + m_assembler.mov( + Assembler::Operand::Register(GPR0), + Assembler::Operand::Imm(bit_cast(&op.expression_string()))); + m_assembler.native_call((void*)cxx_call, { Assembler::Operand::Register(GPR0) }); store_vm_register(Bytecode::Register::accumulator(), RET); check_exception(); }