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 { ...@@ -141,27 +141,26 @@ class UseMarkingProcessor {
// static // static
void MaglevCompiler::Compile(LocalIsolate* local_isolate, void MaglevCompiler::Compile(LocalIsolate* local_isolate,
MaglevCompilationUnit* toplevel_compilation_unit) { MaglevCompilationUnit* toplevel_compilation_unit) {
MaglevCompiler compiler(local_isolate, toplevel_compilation_unit); compiler::UnparkedScopeIfNeeded unparked_scope(
compiler.Compile(); toplevel_compilation_unit->broker());
}
void MaglevCompiler::Compile() {
compiler::UnparkedScopeIfNeeded unparked_scope(broker());
// Build graph. // Build graph.
if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph || if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph ||
FLAG_trace_maglev_regalloc) { FLAG_trace_maglev_regalloc) {
toplevel_compilation_unit_->info()->set_graph_labeller( toplevel_compilation_unit->info()->set_graph_labeller(
new MaglevGraphLabeller()); new MaglevGraphLabeller());
} }
// TODO(v8:7700): Support exceptions in maglev. We currently bail if exception // TODO(v8:7700): Support exceptions in maglev. We currently bail if exception
// handler table is non-empty. // handler table is non-empty.
if (toplevel_compilation_unit_->bytecode().handler_table_size() > 0) { if (toplevel_compilation_unit->bytecode().handler_table_size() > 0) {
return; 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(); graph_builder.Build();
...@@ -172,12 +171,12 @@ void MaglevCompiler::Compile() { ...@@ -172,12 +171,12 @@ void MaglevCompiler::Compile() {
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After graph buiding" << std::endl; 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 #ifdef DEBUG
{ {
GraphProcessor<MaglevGraphVerifier> verifier(toplevel_compilation_unit_); GraphProcessor<MaglevGraphVerifier> verifier(toplevel_compilation_unit);
verifier.ProcessGraph(graph_builder.graph()); verifier.ProcessGraph(graph_builder.graph());
} }
#endif #endif
...@@ -185,25 +184,25 @@ void MaglevCompiler::Compile() { ...@@ -185,25 +184,25 @@ void MaglevCompiler::Compile() {
{ {
GraphMultiProcessor<NumberingProcessor, UseMarkingProcessor, GraphMultiProcessor<NumberingProcessor, UseMarkingProcessor,
MaglevVregAllocator> MaglevVregAllocator>
processor(toplevel_compilation_unit_); processor(toplevel_compilation_unit);
processor.ProcessGraph(graph_builder.graph()); processor.ProcessGraph(graph_builder.graph());
} }
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After node processor" << std::endl; 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()); graph_builder.graph());
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After register allocation" << std::endl; 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. // 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 // static
......
...@@ -21,7 +21,7 @@ namespace maglev { ...@@ -21,7 +21,7 @@ namespace maglev {
class Graph; class Graph;
class MaglevCompiler { class MaglevCompiler : public AllStatic {
public: public:
// May be called from any thread. // May be called from any thread.
static void Compile(LocalIsolate* local_isolate, static void Compile(LocalIsolate* local_isolate,
...@@ -31,23 +31,6 @@ class MaglevCompiler { ...@@ -31,23 +31,6 @@ class MaglevCompiler {
// TODO(v8:7700): Move this to a different class? // TODO(v8:7700): Move this to a different class?
static MaybeHandle<CodeT> GenerateCode( static MaybeHandle<CodeT> GenerateCode(
MaglevCompilationUnit* toplevel_compilation_unit); 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 } // namespace maglev
......
...@@ -34,16 +34,17 @@ int LoadSimpleFieldHandler(FieldIndex field_index) { ...@@ -34,16 +34,17 @@ int LoadSimpleFieldHandler(FieldIndex field_index) {
} // namespace } // namespace
MaglevGraphBuilder::MaglevGraphBuilder(LocalIsolate* local_isolate, MaglevGraphBuilder::MaglevGraphBuilder(LocalIsolate* local_isolate,
MaglevCompilationUnit* compilation_unit) MaglevCompilationUnit* compilation_unit,
Graph* graph)
: local_isolate_(local_isolate), : local_isolate_(local_isolate),
compilation_unit_(compilation_unit), compilation_unit_(compilation_unit),
graph_(graph),
iterator_(bytecode().object()), iterator_(bytecode().object()),
jump_targets_(zone()->NewArray<BasicBlockRef>(bytecode().length())), jump_targets_(zone()->NewArray<BasicBlockRef>(bytecode().length())),
// Overallocate merge_states_ by one to allow always looking up the // Overallocate merge_states_ by one to allow always looking up the
// next offset. // next offset.
merge_states_(zone()->NewArray<MergePointInterpreterFrameState*>( merge_states_(zone()->NewArray<MergePointInterpreterFrameState*>(
bytecode().length() + 1)), bytecode().length() + 1)),
graph_(Graph::New(zone())),
current_interpreter_frame_(*compilation_unit_) { current_interpreter_frame_(*compilation_unit_) {
memset(merge_states_, 0, memset(merge_states_, 0,
bytecode().length() * sizeof(InterpreterFrameState*)); bytecode().length() * sizeof(InterpreterFrameState*));
......
...@@ -26,7 +26,8 @@ namespace maglev { ...@@ -26,7 +26,8 @@ namespace maglev {
class MaglevGraphBuilder { class MaglevGraphBuilder {
public: public:
explicit MaglevGraphBuilder(LocalIsolate* local_isolate, explicit MaglevGraphBuilder(LocalIsolate* local_isolate,
MaglevCompilationUnit* compilation_unit); MaglevCompilationUnit* compilation_unit,
Graph* graph);
void Build() { void Build() {
for (iterator_.Reset(); !iterator_.done(); iterator_.Advance()) { for (iterator_.Reset(); !iterator_.done(); iterator_.Advance()) {
...@@ -529,6 +530,7 @@ class MaglevGraphBuilder { ...@@ -529,6 +530,7 @@ class MaglevGraphBuilder {
LocalIsolate* const local_isolate_; LocalIsolate* const local_isolate_;
MaglevCompilationUnit* const compilation_unit_; MaglevCompilationUnit* const compilation_unit_;
Graph* const graph_;
interpreter::BytecodeArrayIterator iterator_; interpreter::BytecodeArrayIterator iterator_;
uint32_t* predecessors_; uint32_t* predecessors_;
...@@ -540,7 +542,6 @@ class MaglevGraphBuilder { ...@@ -540,7 +542,6 @@ class MaglevGraphBuilder {
BasicBlockRef* jump_targets_; BasicBlockRef* jump_targets_;
MergePointInterpreterFrameState** merge_states_; MergePointInterpreterFrameState** merge_states_;
Graph* const graph_;
InterpreterFrameState current_interpreter_frame_; InterpreterFrameState current_interpreter_frame_;
// Allow marking some bytecodes as unsupported during graph building, so that // 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