1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 05:54:59 +00:00
serenity/Userland/Libraries/LibJS/JIT/NativeExecutable.cpp
Andreas Kling 310bcd4717 LibJS/JIT: Don't keep trying to JIT unsupported bytecode executables
We now only try jitting each Bytecode::Executable once, and then cache
the resulting NativeExecutable.
2023-10-27 19:07:22 +02:00

33 lines
699 B
C++

/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Bytecode/Interpreter.h>
#include <LibJS/JIT/NativeExecutable.h>
#include <LibJS/Runtime/VM.h>
#include <sys/mman.h>
namespace JS::JIT {
NativeExecutable::NativeExecutable(void* code, size_t size)
: m_code(code)
, m_size(size)
{
}
NativeExecutable::~NativeExecutable()
{
munmap(m_code, m_size);
}
void NativeExecutable::run(VM& vm) const
{
typedef void (*JITCode)(VM&, Value* registers, Value* locals);
((JITCode)m_code)(vm,
vm.bytecode_interpreter().registers().data(),
vm.running_execution_context().local_variables.data());
}
}