mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibJS/JIT: Support the GetById bytecode op
We can now do basic property (get) access in jitted code! :^)
This commit is contained in:
parent
8905682a16
commit
6a6ef6670c
3 changed files with 28 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibJS/Bytecode/CommonImplementations.h>
|
||||
#include <LibJS/Bytecode/Instruction.h>
|
||||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
#include <LibJS/JIT/Compiler.h>
|
||||
|
@ -366,6 +367,25 @@ void Compiler::compile_new_string(Bytecode::Op::NewString const& op)
|
|||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op)
|
||||
{
|
||||
load_vm_register(ARG1, Bytecode::Register::accumulator());
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG2),
|
||||
Assembler::Operand::Imm64(op.property().value()));
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG3),
|
||||
Assembler::Operand::Imm64(op.cache_index()));
|
||||
m_assembler.native_call((void*)cxx_get_by_id);
|
||||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
|
||||
{
|
||||
if (getenv("LIBJS_NO_JIT"))
|
||||
|
@ -430,6 +450,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
|||
case Bytecode::Instruction::Type::NewString:
|
||||
compiler.compile_new_string(static_cast<Bytecode::Op::NewString const&>(op));
|
||||
break;
|
||||
case Bytecode::Instruction::Type::GetById:
|
||||
compiler.compile_get_by_id(static_cast<Bytecode::Op::GetById const&>(op));
|
||||
break;
|
||||
|
||||
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||
case Bytecode::Instruction::Type::TitleCaseName: \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue