mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibJS/JIT: Compile the NewObject bytecode instruction
This commit is contained in:
parent
580249d650
commit
d866780235
2 changed files with 16 additions and 0 deletions
|
@ -383,6 +383,18 @@ void Compiler::compile_new_string(Bytecode::Op::NewString const& op)
|
||||||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_new_object(VM& vm)
|
||||||
|
{
|
||||||
|
auto& realm = *vm.current_realm();
|
||||||
|
return Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_new_object(Bytecode::Op::NewObject const&)
|
||||||
|
{
|
||||||
|
m_assembler.native_call((void*)cxx_new_object);
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||||
|
}
|
||||||
|
|
||||||
static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index)
|
static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index)
|
||||||
{
|
{
|
||||||
return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index));
|
return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index));
|
||||||
|
@ -547,6 +559,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
case Bytecode::Instruction::Type::NewString:
|
case Bytecode::Instruction::Type::NewString:
|
||||||
compiler.compile_new_string(static_cast<Bytecode::Op::NewString const&>(op));
|
compiler.compile_new_string(static_cast<Bytecode::Op::NewString const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::NewObject:
|
||||||
|
compiler.compile_new_object(static_cast<Bytecode::Op::NewObject const&>(op));
|
||||||
|
break;
|
||||||
case Bytecode::Instruction::Type::GetById:
|
case Bytecode::Instruction::Type::GetById:
|
||||||
compiler.compile_get_by_id(static_cast<Bytecode::Op::GetById const&>(op));
|
compiler.compile_get_by_id(static_cast<Bytecode::Op::GetById const&>(op));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
|
|
||||||
void compile_return(Bytecode::Op::Return const&);
|
void compile_return(Bytecode::Op::Return const&);
|
||||||
void compile_new_string(Bytecode::Op::NewString const&);
|
void compile_new_string(Bytecode::Op::NewString const&);
|
||||||
|
void compile_new_object(Bytecode::Op::NewObject const&);
|
||||||
void compile_get_by_id(Bytecode::Op::GetById const&);
|
void compile_get_by_id(Bytecode::Op::GetById const&);
|
||||||
void compile_get_by_value(Bytecode::Op::GetByValue const&);
|
void compile_get_by_value(Bytecode::Op::GetByValue const&);
|
||||||
void compile_get_global(Bytecode::Op::GetGlobal const&);
|
void compile_get_global(Bytecode::Op::GetGlobal const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue