Commit 4f0f2d1d authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Make MaglevCompiler all static

We don't actually ever need the MaglevCompiler instance.

Bug: v8:7700
Change-Id: I876353310cf34971b72b08d2113d87caaa255e13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3585957
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79987}
parent 01af3a65
......@@ -141,27 +141,26 @@ class UseMarkingProcessor {
// static
void MaglevCompiler::Compile(LocalIsolate* local_isolate,
MaglevCompilationUnit* toplevel_compilation_unit) {
MaglevCompiler compiler(local_isolate, toplevel_compilation_unit);
compiler.Compile();
}
void MaglevCompiler::Compile() {
compiler::UnparkedScopeIfNeeded unparked_scope(broker());
compiler::UnparkedScopeIfNeeded unparked_scope(
toplevel_compilation_unit->broker());
// Build graph.
if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph ||
FLAG_trace_maglev_regalloc) {
toplevel_compilation_unit_->info()->set_graph_labeller(
toplevel_compilation_unit->info()->set_graph_labeller(
new MaglevGraphLabeller());
}
// TODO(v8:7700): Support exceptions in maglev. We currently bail if exception
// handler table is non-empty.
if (toplevel_compilation_unit_->bytecode().handler_table_size() > 0) {
if (toplevel_compilation_unit->bytecode().handler_table_size() > 0) {
return;
}
MaglevGraphBuilder graph_builder(local_isolate(), toplevel_compilation_unit_);
Graph* graph = Graph::New(toplevel_compilation_unit->zone());
MaglevGraphBuilder graph_builder(local_isolate, toplevel_compilation_unit,
graph);
graph_builder.Build();
......@@ -172,12 +171,12 @@ void MaglevCompiler::Compile() {
if (FLAG_print_maglev_graph) {
std::cout << "After graph buiding" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit_, graph_builder.graph());
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph());
}
#ifdef DEBUG
{
GraphProcessor<MaglevGraphVerifier> verifier(toplevel_compilation_unit_);
GraphProcessor<MaglevGraphVerifier> verifier(toplevel_compilation_unit);
verifier.ProcessGraph(graph_builder.graph());
}
#endif
......@@ -185,25 +184,25 @@ void MaglevCompiler::Compile() {
{
GraphMultiProcessor<NumberingProcessor, UseMarkingProcessor,
MaglevVregAllocator>
processor(toplevel_compilation_unit_);
processor(toplevel_compilation_unit);
processor.ProcessGraph(graph_builder.graph());
}
if (FLAG_print_maglev_graph) {
std::cout << "After node processor" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit_, graph_builder.graph());
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph());
}
StraightForwardRegisterAllocator allocator(toplevel_compilation_unit_,
StraightForwardRegisterAllocator allocator(toplevel_compilation_unit,
graph_builder.graph());
if (FLAG_print_maglev_graph) {
std::cout << "After register allocation" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit_, graph_builder.graph());
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph());
}
// Stash the compiled graph on the compilation info.
toplevel_compilation_unit_->info()->set_graph(graph_builder.graph());
toplevel_compilation_unit->info()->set_graph(graph_builder.graph());
}
// static
......
......@@ -21,7 +21,7 @@ namespace maglev {
class Graph;
class MaglevCompiler {
class MaglevCompiler : public AllStatic {
public:
// May be called from any thread.
static void Compile(LocalIsolate* local_isolate,
......@@ -31,23 +31,6 @@ class MaglevCompiler {
// TODO(v8:7700): Move this to a different class?
static MaybeHandle<CodeT> GenerateCode(
MaglevCompilationUnit* toplevel_compilation_unit);
private:
explicit MaglevCompiler(LocalIsolate* local_isolate,
MaglevCompilationUnit* toplevel_compilation_unit)
: local_isolate_(local_isolate),
toplevel_compilation_unit_(toplevel_compilation_unit) {}
void Compile();
compiler::JSHeapBroker* broker() const {
return toplevel_compilation_unit_->broker();
}
Zone* zone() { return toplevel_compilation_unit_->zone(); }
LocalIsolate* local_isolate() { return local_isolate_; }
LocalIsolate* const local_isolate_;
MaglevCompilationUnit* const toplevel_compilation_unit_;
};
} // namespace maglev
......
......@@ -34,16 +34,17 @@ int LoadSimpleFieldHandler(FieldIndex field_index) {
} // namespace
MaglevGraphBuilder::MaglevGraphBuilder(LocalIsolate* local_isolate,
MaglevCompilationUnit* compilation_unit)
MaglevCompilationUnit* compilation_unit,
Graph* graph)
: local_isolate_(local_isolate),
compilation_unit_(compilation_unit),
graph_(graph),
iterator_(bytecode().object()),
jump_targets_(zone()->NewArray<BasicBlockRef>(bytecode().length())),
// Overallocate merge_states_ by one to allow always looking up the
// next offset.
merge_states_(zone()->NewArray<MergePointInterpreterFrameState*>(
bytecode().length() + 1)),
graph_(Graph::New(zone())),
current_interpreter_frame_(*compilation_unit_) {
memset(merge_states_, 0,
bytecode().length() * sizeof(InterpreterFrameState*));
......
......@@ -26,7 +26,8 @@ namespace maglev {
class MaglevGraphBuilder {
public:
explicit MaglevGraphBuilder(LocalIsolate* local_isolate,
MaglevCompilationUnit* compilation_unit);
MaglevCompilationUnit* compilation_unit,
Graph* graph);
void Build() {
for (iterator_.Reset(); !iterator_.done(); iterator_.Advance()) {
......@@ -529,6 +530,7 @@ class MaglevGraphBuilder {
LocalIsolate* const local_isolate_;
MaglevCompilationUnit* const compilation_unit_;
Graph* const graph_;
interpreter::BytecodeArrayIterator iterator_;
uint32_t* predecessors_;
......@@ -540,7 +542,6 @@ class MaglevGraphBuilder {
BasicBlockRef* jump_targets_;
MergePointInterpreterFrameState** merge_states_;
Graph* const graph_;
InterpreterFrameState current_interpreter_frame_;
// Allow marking some bytecodes as unsupported during graph building, so that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment