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

[maglev] Remove isolate from MaglevCompilationInfo

... to avoid it being accessible from BG threads.

Bug: v8:7700
Change-Id: I8fa7ac66016cb1f70925ed84a6552128d419f330
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3899128Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83356}
parent 11d4b5e5
...@@ -31,9 +31,10 @@ class DeferredCodeInfo { ...@@ -31,9 +31,10 @@ class DeferredCodeInfo {
class MaglevCodeGenState { class MaglevCodeGenState {
public: public:
MaglevCodeGenState(MaglevCompilationInfo* compilation_info, MaglevCodeGenState(Isolate* isolate, MaglevCompilationInfo* compilation_info,
MaglevSafepointTableBuilder* safepoint_table_builder) MaglevSafepointTableBuilder* safepoint_table_builder)
: compilation_info_(compilation_info), : isolate_(isolate),
compilation_info_(compilation_info),
safepoint_table_builder_(safepoint_table_builder) {} safepoint_table_builder_(safepoint_table_builder) {}
void set_tagged_slots(int slots) { tagged_slots_ = slots; } void set_tagged_slots(int slots) { tagged_slots_ = slots; }
...@@ -60,7 +61,7 @@ class MaglevCodeGenState { ...@@ -60,7 +61,7 @@ class MaglevCodeGenState {
compiler::NativeContextRef native_context() const { compiler::NativeContextRef native_context() const {
return broker()->target_native_context(); return broker()->target_native_context();
} }
Isolate* isolate() const { return compilation_info_->isolate(); } Isolate* isolate() const { return isolate_; }
compiler::JSHeapBroker* broker() const { return compilation_info_->broker(); } compiler::JSHeapBroker* broker() const { return compilation_info_->broker(); }
MaglevGraphLabeller* graph_labeller() const { MaglevGraphLabeller* graph_labeller() const {
return compilation_info_->graph_labeller(); return compilation_info_->graph_labeller();
...@@ -73,6 +74,7 @@ class MaglevCodeGenState { ...@@ -73,6 +74,7 @@ class MaglevCodeGenState {
MaglevCompilationInfo* compilation_info() const { return compilation_info_; } MaglevCompilationInfo* compilation_info() const { return compilation_info_; }
private: private:
Isolate* const isolate_;
MaglevCompilationInfo* const compilation_info_; MaglevCompilationInfo* const compilation_info_;
MaglevSafepointTableBuilder* const safepoint_table_builder_; MaglevSafepointTableBuilder* const safepoint_table_builder_;
......
...@@ -945,17 +945,19 @@ class MaglevCodeGeneratingNodeProcessor { ...@@ -945,17 +945,19 @@ class MaglevCodeGeneratingNodeProcessor {
class MaglevCodeGeneratorImpl final { class MaglevCodeGeneratorImpl final {
public: public:
static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info, static MaybeHandle<Code> Generate(Isolate* isolate,
MaglevCompilationInfo* compilation_info,
Graph* graph) { Graph* graph) {
return MaglevCodeGeneratorImpl(compilation_info, graph).Generate(); return MaglevCodeGeneratorImpl(isolate, compilation_info, graph).Generate();
} }
private: private:
MaglevCodeGeneratorImpl(MaglevCompilationInfo* compilation_info, Graph* graph) MaglevCodeGeneratorImpl(Isolate* isolate,
MaglevCompilationInfo* compilation_info, Graph* graph)
: safepoint_table_builder_(compilation_info->zone(), : safepoint_table_builder_(compilation_info->zone(),
graph->tagged_stack_slots(), graph->tagged_stack_slots(),
graph->untagged_stack_slots()), graph->untagged_stack_slots()),
code_gen_state_(compilation_info, safepoint_table_builder()), code_gen_state_(isolate, compilation_info, safepoint_table_builder()),
masm_(&code_gen_state_), masm_(&code_gen_state_),
processor_(&masm_), processor_(&masm_),
graph_(graph) {} graph_(graph) {}
...@@ -1153,9 +1155,7 @@ class MaglevCodeGeneratorImpl final { ...@@ -1153,9 +1155,7 @@ class MaglevCodeGeneratorImpl final {
return stack_slot_count() + StandardFrameConstants::kFixedSlotCount; return stack_slot_count() + StandardFrameConstants::kFixedSlotCount;
} }
Isolate* isolate() const { Isolate* isolate() const { return code_gen_state_.isolate(); }
return code_gen_state_.compilation_info()->isolate();
}
MaglevAssembler* masm() { return &masm_; } MaglevAssembler* masm() { return &masm_; }
MaglevSafepointTableBuilder* safepoint_table_builder() { MaglevSafepointTableBuilder* safepoint_table_builder() {
return &safepoint_table_builder_; return &safepoint_table_builder_;
...@@ -1173,8 +1173,8 @@ class MaglevCodeGeneratorImpl final { ...@@ -1173,8 +1173,8 @@ class MaglevCodeGeneratorImpl final {
// static // static
MaybeHandle<Code> MaglevCodeGenerator::Generate( MaybeHandle<Code> MaglevCodeGenerator::Generate(
MaglevCompilationInfo* compilation_info, Graph* graph) { Isolate* isolate, MaglevCompilationInfo* compilation_info, Graph* graph) {
return MaglevCodeGeneratorImpl::Generate(compilation_info, graph); return MaglevCodeGeneratorImpl::Generate(isolate, compilation_info, graph);
} }
} // namespace maglev } // namespace maglev
......
...@@ -16,7 +16,8 @@ class MaglevCompilationInfo; ...@@ -16,7 +16,8 @@ class MaglevCompilationInfo;
class MaglevCodeGenerator : public AllStatic { class MaglevCodeGenerator : public AllStatic {
public: public:
static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info, static MaybeHandle<Code> Generate(Isolate* isolate,
MaglevCompilationInfo* compilation_info,
Graph* graph); Graph* graph);
}; };
......
...@@ -52,7 +52,6 @@ class V8_NODISCARD MaglevCompilationHandleScope final { ...@@ -52,7 +52,6 @@ class V8_NODISCARD MaglevCompilationHandleScope final {
MaglevCompilationInfo::MaglevCompilationInfo(Isolate* isolate, MaglevCompilationInfo::MaglevCompilationInfo(Isolate* isolate,
Handle<JSFunction> function) Handle<JSFunction> function)
: zone_(isolate->allocator(), kMaglevZoneName), : zone_(isolate->allocator(), kMaglevZoneName),
isolate_(isolate),
broker_(new compiler::JSHeapBroker( broker_(new compiler::JSHeapBroker(
isolate, zone(), v8_flags.trace_heap_broker, CodeKind::MAGLEV)) isolate, zone(), v8_flags.trace_heap_broker, CodeKind::MAGLEV))
#define V(Name) , Name##_(v8_flags.Name) #define V(Name) , Name##_(v8_flags.Name)
......
...@@ -53,7 +53,6 @@ class MaglevCompilationInfo final { ...@@ -53,7 +53,6 @@ class MaglevCompilationInfo final {
} }
~MaglevCompilationInfo(); ~MaglevCompilationInfo();
Isolate* isolate() const { return isolate_; }
Zone* zone() { return &zone_; } Zone* zone() { return &zone_; }
compiler::JSHeapBroker* broker() const { return broker_.get(); } compiler::JSHeapBroker* broker() const { return broker_.get(); }
MaglevCompilationUnit* toplevel_compilation_unit() const { MaglevCompilationUnit* toplevel_compilation_unit() const {
...@@ -111,7 +110,6 @@ class MaglevCompilationInfo final { ...@@ -111,7 +110,6 @@ class MaglevCompilationInfo final {
MaglevCompilationInfo(Isolate* isolate, Handle<JSFunction> function); MaglevCompilationInfo(Isolate* isolate, Handle<JSFunction> function);
Zone zone_; Zone zone_;
Isolate* const isolate_;
const std::unique_ptr<compiler::JSHeapBroker> broker_; const std::unique_ptr<compiler::JSHeapBroker> broker_;
// Must be initialized late since it requires an initialized heap broker. // Must be initialized late since it requires an initialized heap broker.
MaglevCompilationUnit* toplevel_compilation_unit_ = nullptr; MaglevCompilationUnit* toplevel_compilation_unit_ = nullptr;
......
...@@ -40,8 +40,6 @@ compiler::JSHeapBroker* MaglevCompilationUnit::broker() const { ...@@ -40,8 +40,6 @@ compiler::JSHeapBroker* MaglevCompilationUnit::broker() const {
return info_->broker(); return info_->broker();
} }
Isolate* MaglevCompilationUnit::isolate() const { return info_->isolate(); }
Zone* MaglevCompilationUnit::zone() const { return info_->zone(); } Zone* MaglevCompilationUnit::zone() const { return info_->zone(); }
bool MaglevCompilationUnit::has_graph_labeller() const { bool MaglevCompilationUnit::has_graph_labeller() const {
......
...@@ -42,7 +42,6 @@ class MaglevCompilationUnit : public ZoneObject { ...@@ -42,7 +42,6 @@ class MaglevCompilationUnit : public ZoneObject {
MaglevCompilationInfo* info() const { return info_; } MaglevCompilationInfo* info() const { return info_; }
const MaglevCompilationUnit* caller() const { return caller_; } const MaglevCompilationUnit* caller() const { return caller_; }
compiler::JSHeapBroker* broker() const; compiler::JSHeapBroker* broker() const;
Isolate* isolate() const;
LocalIsolate* local_isolate() const; LocalIsolate* local_isolate() const;
Zone* zone() const; Zone* zone() const;
int register_count() const { return register_count_; } int register_count() const { return register_count_; }
......
...@@ -565,7 +565,7 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate, ...@@ -565,7 +565,7 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate,
// static // static
MaybeHandle<CodeT> MaglevCompiler::GenerateCode( MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
MaglevCompilationInfo* compilation_info) { Isolate* isolate, MaglevCompilationInfo* compilation_info) {
Graph* const graph = compilation_info->graph(); Graph* const graph = compilation_info->graph();
if (graph == nullptr) { if (graph == nullptr) {
// Compilation failed. // Compilation failed.
...@@ -577,7 +577,8 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode( ...@@ -577,7 +577,8 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
} }
Handle<Code> code; Handle<Code> code;
if (!MaglevCodeGenerator::Generate(compilation_info, graph).ToHandle(&code)) { if (!MaglevCodeGenerator::Generate(isolate, compilation_info, graph)
.ToHandle(&code)) {
compilation_info->toplevel_compilation_unit() compilation_info->toplevel_compilation_unit()
->shared_function_info() ->shared_function_info()
.object() .object()
...@@ -596,7 +597,6 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode( ...@@ -596,7 +597,6 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
code->Print(); code->Print();
} }
Isolate* const isolate = compilation_info->isolate();
isolate->native_context()->AddOptimizedCode(ToCodeT(*code)); isolate->native_context()->AddOptimizedCode(ToCodeT(*code));
return ToCodeT(code, isolate); return ToCodeT(code, isolate);
} }
......
...@@ -30,7 +30,7 @@ class MaglevCompiler : public AllStatic { ...@@ -30,7 +30,7 @@ class MaglevCompiler : public AllStatic {
// Called on the main thread after Compile has completed. // Called on the main thread after Compile has completed.
// 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(
MaglevCompilationInfo* compilation_info); Isolate* isolate, MaglevCompilationInfo* compilation_info);
}; };
} // namespace maglev } // namespace maglev
......
...@@ -108,7 +108,7 @@ CompilationJob::Status MaglevCompilationJob::ExecuteJobImpl( ...@@ -108,7 +108,7 @@ CompilationJob::Status MaglevCompilationJob::ExecuteJobImpl(
CompilationJob::Status MaglevCompilationJob::FinalizeJobImpl(Isolate* isolate) { CompilationJob::Status MaglevCompilationJob::FinalizeJobImpl(Isolate* isolate) {
Handle<CodeT> codet; Handle<CodeT> codet;
if (!maglev::MaglevCompiler::GenerateCode(info()).ToHandle(&codet)) { if (!maglev::MaglevCompiler::GenerateCode(isolate, info()).ToHandle(&codet)) {
return CompilationJob::FAILED; return CompilationJob::FAILED;
} }
info()->toplevel_compilation_unit()->function().object()->set_code(*codet); info()->toplevel_compilation_unit()->function().object()->set_code(*codet);
......
...@@ -18,7 +18,7 @@ MaybeHandle<CodeT> Maglev::Compile(Isolate* isolate, ...@@ -18,7 +18,7 @@ MaybeHandle<CodeT> Maglev::Compile(Isolate* isolate,
maglev::MaglevCompilationInfo::New(isolate, function); maglev::MaglevCompilationInfo::New(isolate, function);
maglev::MaglevCompiler::Compile(isolate->main_thread_local_isolate(), maglev::MaglevCompiler::Compile(isolate->main_thread_local_isolate(),
info.get()); info.get());
return maglev::MaglevCompiler::GenerateCode(info.get()); return maglev::MaglevCompiler::GenerateCode(isolate, info.get());
} }
} // namespace internal } // namespace internal
......
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