mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +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
|
@ -559,6 +559,9 @@ public:
|
|||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
IdentifierTableIndex property() const { return m_property; }
|
||||
u32 cache_index() const { return m_cache_index; }
|
||||
|
||||
private:
|
||||
IdentifierTableIndex m_property;
|
||||
u32 m_cache_index { 0 };
|
||||
|
|
|
@ -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: \
|
||||
|
|
|
@ -23,6 +23,7 @@ private:
|
|||
static constexpr auto ARG0 = Assembler::Reg::RDI;
|
||||
static constexpr auto ARG1 = Assembler::Reg::RSI;
|
||||
static constexpr auto ARG2 = Assembler::Reg::RDX;
|
||||
static constexpr auto ARG3 = Assembler::Reg::RCX;
|
||||
static constexpr auto RET = Assembler::Reg::RAX;
|
||||
static constexpr auto STACK_POINTER = Assembler::Reg::RSP;
|
||||
static constexpr auto REGISTER_ARRAY_BASE = Assembler::Reg::R8;
|
||||
|
@ -49,6 +50,7 @@ private:
|
|||
|
||||
void compile_return(Bytecode::Op::Return const&);
|
||||
void compile_new_string(Bytecode::Op::NewString const&);
|
||||
void compile_get_by_id(Bytecode::Op::GetById const&);
|
||||
|
||||
void store_vm_register(Bytecode::Register, Assembler::Reg);
|
||||
void load_vm_register(Assembler::Reg, Bytecode::Register);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue