mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:12:07 +00:00
LibJS/JIT: Support the NewString bytecode op
This necessitated making the JIT::Compiler aware of the current Bytecode::Executable, since that's where all the string literals are held, but that seems like a good thing.
This commit is contained in:
parent
efe58ebf2f
commit
c2fe7af095
3 changed files with 30 additions and 3 deletions
|
@ -383,12 +383,27 @@ void Compiler::compile_return(Bytecode::Op::Return const&)
|
|||
m_assembler.exit();
|
||||
}
|
||||
|
||||
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_executable)
|
||||
static Value cxx_new_string(VM& vm, DeprecatedString const& string)
|
||||
{
|
||||
return PrimitiveString::create(vm, string);
|
||||
}
|
||||
|
||||
void Compiler::compile_new_string(Bytecode::Op::NewString const& op)
|
||||
{
|
||||
auto const& string = m_bytecode_executable.string_table->get(op.index());
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG1),
|
||||
Assembler::Operand::Imm64(bit_cast<u64>(&string)));
|
||||
m_assembler.native_call((void*)cxx_new_string);
|
||||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||
}
|
||||
|
||||
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
|
||||
{
|
||||
if (getenv("LIBJS_NO_JIT"))
|
||||
return nullptr;
|
||||
|
||||
Compiler compiler;
|
||||
Compiler compiler { bytecode_executable };
|
||||
|
||||
compiler.m_assembler.enter();
|
||||
|
||||
|
@ -459,6 +474,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_
|
|||
case Bytecode::Instruction::Type::Return:
|
||||
compiler.compile_return(static_cast<Bytecode::Op::Return const&>(op));
|
||||
break;
|
||||
case Bytecode::Instruction::Type::NewString:
|
||||
compiler.compile_new_string(static_cast<Bytecode::Op::NewString const&>(op));
|
||||
break;
|
||||
default:
|
||||
dbgln("JIT compilation failed: {}", bytecode_executable.name);
|
||||
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue