1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

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.
This commit is contained in:
Idan Horowitz 2023-10-28 15:19:12 +03:00 committed by Andreas Kling
parent 863314ff10
commit 78cac671b6

View file

@ -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<Bytecode::StringTableIndex> 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<Value> 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<u64>(&op.expression_string())));
m_assembler.native_call((void*)cxx_call, { Assembler::Operand::Register(GPR0) });
store_vm_register(Bytecode::Register::accumulator(), RET);
check_exception();
}