1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

LibJS+CI: Remove bytecode optimization passes for now

These passes have not been shown to actually optimize any JS, and tests
have become very flaky with optimizations enabled. Until some measurable
benefit is shown, remove the optimization passes to reduce overhead of
maintaining bytecode operations and to reduce CI churn. The framework
for optimizations will live on in git history, and can be restored once
proven useful.
This commit is contained in:
Timothy Flynn 2023-07-21 09:59:50 -04:00 committed by Ali Mohammad Pur
parent 164c132928
commit 77d7f715e3
17 changed files with 1 additions and 1311 deletions

View file

@ -12,7 +12,6 @@
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Interpreter.h>
#include <LibJS/Bytecode/Op.h>
#include <LibJS/Bytecode/PassManager.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/GlobalEnvironment.h>
#include <LibJS/Runtime/GlobalObject.h>
@ -32,13 +31,6 @@ void Interpreter::set_enabled(bool enabled)
s_bytecode_interpreter_enabled = enabled;
}
static bool s_optimizations_enabled = false;
void Interpreter::set_optimizations_enabled(bool enabled)
{
s_optimizations_enabled = enabled;
}
bool g_dump_bytecode = false;
Interpreter::Interpreter(VM& vm)
@ -124,11 +116,6 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, JS::GCPtr<Envir
} else {
auto executable = executable_result.release_value();
if (s_optimizations_enabled) {
auto& passes = optimization_pipeline();
passes.perform(*executable);
}
if (g_dump_bytecode)
executable->dump();
@ -403,26 +390,6 @@ VM::InterpreterExecutionScope Interpreter::ast_interpreter_scope(Realm& realm)
return { *m_ast_interpreter };
}
Bytecode::PassManager& Interpreter::optimization_pipeline()
{
static auto s_optimization_pipeline = [] {
auto pm = make<Bytecode::PassManager>();
pm->add<Passes::GenerateCFG>();
pm->add<Passes::UnifySameBlocks>();
pm->add<Passes::GenerateCFG>();
pm->add<Passes::MergeBlocks>();
pm->add<Passes::GenerateCFG>();
pm->add<Passes::UnifySameBlocks>();
pm->add<Passes::GenerateCFG>();
pm->add<Passes::MergeBlocks>();
pm->add<Passes::GenerateCFG>();
pm->add<Passes::PlaceBlocks>();
pm->add<Passes::EliminateLoads>();
return pm;
}();
return *s_optimization_pipeline;
}
size_t Interpreter::pc() const
{
return m_pc ? m_pc->offset() : 0;
@ -442,15 +409,6 @@ ThrowCompletionOr<NonnullOwnPtr<Bytecode::Executable>> compile(VM& vm, ASTNode c
auto bytecode_executable = executable_result.release_value();
bytecode_executable->name = name;
if (s_optimizations_enabled) {
auto& passes = Bytecode::Interpreter::optimization_pipeline();
passes.perform(*bytecode_executable);
if constexpr (JS_BYTECODE_DEBUG) {
dbgln("Optimisation passes took {}us", passes.elapsed());
dbgln("Compiled Bytecode::Block for function '{}':", name);
}
}
if (Bytecode::g_dump_bytecode)
bytecode_executable->dump();