mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
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.
This commit is contained in:
parent
6a6ef6670c
commit
310bcd4717
5 changed files with 21 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/RegexTable.h>
|
||||
#include <LibJS/JIT/Compiler.h>
|
||||
#include <LibJS/SourceCode.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
@ -52,4 +53,13 @@ void Executable::dump() const
|
|||
}
|
||||
}
|
||||
|
||||
JIT::NativeExecutable const* Executable::get_or_create_native_executable()
|
||||
{
|
||||
if (!m_did_try_jitting) {
|
||||
m_did_try_jitting = true;
|
||||
m_native_executable = JIT::Compiler::compile(*this);
|
||||
}
|
||||
return m_native_executable;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibJS/Bytecode/IdentifierTable.h>
|
||||
#include <LibJS/Bytecode/StringTable.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/JIT/NativeExecutable.h>
|
||||
#include <LibJS/Runtime/EnvironmentCoordinate.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
@ -63,6 +65,12 @@ public:
|
|||
DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
|
||||
|
||||
void dump() const;
|
||||
|
||||
JIT::NativeExecutable const* get_or_create_native_executable();
|
||||
|
||||
private:
|
||||
OwnPtr<JIT::NativeExecutable> m_native_executable;
|
||||
bool m_did_try_jitting { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable& executa
|
|||
else
|
||||
push_call_frame(make<CallFrame>(), executable.number_of_registers);
|
||||
|
||||
if (auto native_executable = JIT::Compiler::compile(executable)) {
|
||||
if (auto native_executable = executable.get_or_create_native_executable()) {
|
||||
native_executable->run(vm());
|
||||
|
||||
for (size_t i = 0; i < vm().running_execution_context().local_variables.size(); ++i) {
|
||||
|
|
|
@ -22,7 +22,7 @@ NativeExecutable::~NativeExecutable()
|
|||
munmap(m_code, m_size);
|
||||
}
|
||||
|
||||
void NativeExecutable::run(VM& vm)
|
||||
void NativeExecutable::run(VM& vm) const
|
||||
{
|
||||
typedef void (*JITCode)(VM&, Value* registers, Value* locals);
|
||||
((JITCode)m_code)(vm,
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
NativeExecutable(void* code, size_t size);
|
||||
~NativeExecutable();
|
||||
|
||||
void run(VM&);
|
||||
void run(VM&) const;
|
||||
|
||||
private:
|
||||
void* m_code { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue