
The JIT compiler was an interesting experiment, but ultimately the security & complexity cost of doing arbitrary code generation at runtime is far too high. In subsequent commits, the bytecode format will change drastically, and instead of rewriting the JIT to fit the new bytecode, this patch simply removes the JIT instead. Other engines, JavaScriptCore in particular, have already proven that it's possible to handle the vast majority of contemporary web content with an interpreter. They are currently ~5x faster than us on benchmarks when running without a JIT. We need to catch up to them before considering performance techniques with a heavy security cost.
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Bytecode/BasicBlock.h>
|
|
#include <LibJS/Bytecode/Executable.h>
|
|
#include <LibJS/Bytecode/RegexTable.h>
|
|
#include <LibJS/SourceCode.h>
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
JS_DEFINE_ALLOCATOR(Executable);
|
|
|
|
Executable::Executable(
|
|
NonnullOwnPtr<IdentifierTable> identifier_table,
|
|
NonnullOwnPtr<StringTable> string_table,
|
|
NonnullOwnPtr<RegexTable> regex_table,
|
|
NonnullRefPtr<SourceCode const> source_code,
|
|
size_t number_of_property_lookup_caches,
|
|
size_t number_of_global_variable_caches,
|
|
size_t number_of_environment_variable_caches,
|
|
size_t number_of_registers,
|
|
Vector<NonnullOwnPtr<BasicBlock>> basic_blocks,
|
|
bool is_strict_mode)
|
|
: basic_blocks(move(basic_blocks))
|
|
, string_table(move(string_table))
|
|
, identifier_table(move(identifier_table))
|
|
, regex_table(move(regex_table))
|
|
, source_code(move(source_code))
|
|
, number_of_registers(number_of_registers)
|
|
, is_strict_mode(is_strict_mode)
|
|
{
|
|
property_lookup_caches.resize(number_of_property_lookup_caches);
|
|
global_variable_caches.resize(number_of_global_variable_caches);
|
|
environment_variable_caches.resize(number_of_environment_variable_caches);
|
|
}
|
|
|
|
Executable::~Executable() = default;
|
|
|
|
void Executable::dump() const
|
|
{
|
|
dbgln("\033[33;1mJS::Bytecode::Executable\033[0m ({})", name);
|
|
for (auto& block : basic_blocks)
|
|
block->dump(*this);
|
|
if (!string_table->is_empty()) {
|
|
outln();
|
|
string_table->dump();
|
|
}
|
|
if (!identifier_table->is_empty()) {
|
|
outln();
|
|
identifier_table->dump();
|
|
}
|
|
}
|
|
|
|
}
|