mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:02:06 +00:00
LibJS/JIT: Compile the ThrowIfNullish instruction
This commit is contained in:
parent
9e2edc3085
commit
e7fdf9c7e5
2 changed files with 16 additions and 1 deletions
|
@ -1255,6 +1255,20 @@ void Compiler::compile_throw_if_not_object(Bytecode::Op::ThrowIfNotObject const&
|
|||
check_exception();
|
||||
}
|
||||
|
||||
static Value cxx_throw_if_nullish(VM& vm, Value value)
|
||||
{
|
||||
if (value.is_nullish())
|
||||
TRY_OR_SET_EXCEPTION(vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, value.to_string_without_side_effects()));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Compiler::compile_throw_if_nullish(Bytecode::Op::ThrowIfNullish const&)
|
||||
{
|
||||
load_vm_register(ARG1, Bytecode::Register::accumulator());
|
||||
native_call((void*)cxx_throw_if_nullish);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
void Compiler::jump_to_exit()
|
||||
{
|
||||
m_assembler.jump(m_exit_label);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue