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 {
class MaglevCodeGenState {
public:
MaglevCodeGenState(MaglevCompilationInfo* compilation_info,
MaglevCodeGenState(Isolate* isolate, MaglevCompilationInfo* compilation_info,
MaglevSafepointTableBuilder* safepoint_table_builder)
: compilation_info_(compilation_info),
: isolate_(isolate),
compilation_info_(compilation_info),
safepoint_table_builder_(safepoint_table_builder) {}
void set_tagged_slots(int slots) { tagged_slots_ = slots; }
......@@ -60,7 +61,7 @@ class MaglevCodeGenState {
compiler::NativeContextRef native_context() const {
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(); }
MaglevGraphLabeller* graph_labeller() const {
return compilation_info_->graph_labeller();
......@@ -73,6 +74,7 @@ class MaglevCodeGenState {
MaglevCompilationInfo* compilation_info() const { return compilation_info_; }
private:
Isolate* const isolate_;
MaglevCompilationInfo* const compilation_info_;
MaglevSafepointTableBuilder* const safepoint_table_builder_;
......
......@@ -945,17 +945,19 @@ class MaglevCodeGeneratingNodeProcessor {
class MaglevCodeGeneratorImpl final {
public:
static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info,
static MaybeHandle<Code> Generate(Isolate* isolate,
MaglevCompilationInfo* compilation_info,
Graph* graph) {
return MaglevCodeGeneratorImpl(compilation_info, graph).Generate();
return MaglevCodeGeneratorImpl(isolate, compilation_info, graph).Generate();
}
private:
MaglevCodeGeneratorImpl(MaglevCompilationInfo* compilation_info, Graph* graph)
MaglevCodeGeneratorImpl(Isolate* isolate,
MaglevCompilationInfo* compilation_info, Graph* graph)
: safepoint_table_builder_(compilation_info->zone(),
graph->tagged_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_),
processor_(&masm_),
graph_(graph) {}
......@@ -1153,9 +1155,7 @@ class MaglevCodeGeneratorImpl final {
return stack_slot_count() + StandardFrameConstants::kFixedSlotCount;
}
Isolate* isolate() const {
return code_gen_state_.compilation_info()->isolate();
}
Isolate* isolate() const { return code_gen_state_.isolate(); }
MaglevAssembler* masm() { return &masm_; }
MaglevSafepointTableBuilder* safepoint_table_builder() {
return &safepoint_table_builder_;
......@@ -1173,8 +1173,8 @@ class MaglevCodeGeneratorImpl final {
// static
MaybeHandle<Code> MaglevCodeGenerator::Generate(
MaglevCompilationInfo* compilation_info, Graph* graph) {
return MaglevCodeGeneratorImpl::Generate(compilation_info, graph);
Isolate* isolate, MaglevCompilationInfo* compilation_info, Graph* graph) {
return MaglevCodeGeneratorImpl::Generate(isolate, compilation_info, graph);
}
} // namespace maglev
......
......@@ -16,7 +16,8 @@ class MaglevCompilationInfo;
class MaglevCodeGenerator : public AllStatic {
public:
static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info,
static MaybeHandle<Code> Generate(Isolate* isolate,
MaglevCompilationInfo* compilation_info,
Graph* graph);
};
......
......@@ -52,7 +52,6 @@ class V8_NODISCARD MaglevCompilationHandleScope final {
MaglevCompilationInfo::MaglevCompilationInfo(Isolate* isolate,
Handle<JSFunction> function)
: zone_(isolate->allocator(), kMaglevZoneName),
isolate_(isolate),
broker_(new compiler::JSHeapBroker(
isolate, zone(), v8_flags.trace_heap_broker, CodeKind::MAGLEV))
#define V(Name) , Name##_(v8_flags.Name)
......
......@@ -53,7 +53,6 @@ class MaglevCompilationInfo final {
}
~MaglevCompilationInfo();
Isolate* isolate() const { return isolate_; }
Zone* zone() { return &zone_; }
compiler::JSHeapBroker* broker() const { return broker_.get(); }
MaglevCompilationUnit* toplevel_compilation_unit() const {
......@@ -111,7 +110,6 @@ class MaglevCompilationInfo final {
MaglevCompilationInfo(Isolate* isolate, Handle<JSFunction> function);
Zone zone_;
Isolate* const isolate_;
const std::unique_ptr<compiler::JSHeapBroker> broker_;
// Must be initialized late since it requires an initialized heap broker.
MaglevCompilationUnit* toplevel_compilation_unit_ = nullptr;
......
......@@ -40,8 +40,6 @@ compiler::JSHeapBroker* MaglevCompilationUnit::broker() const {
return info_->broker();
}
Isolate* MaglevCompilationUnit::isolate() const { return info_->isolate(); }
Zone* MaglevCompilationUnit::zone() const { return info_->zone(); }
bool MaglevCompilationUnit::has_graph_labeller() const {
......
......@@ -42,7 +42,6 @@ class MaglevCompilationUnit : public ZoneObject {
MaglevCompilationInfo* info() const { return info_; }
const MaglevCompilationUnit* caller() const { return caller_; }
compiler::JSHeapBroker* broker() const;
Isolate* isolate() const;
LocalIsolate* local_isolate() const;
Zone* zone() const;
int register_count() const { return register_count_; }
......
......@@ -565,7 +565,7 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate,
// static
MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
MaglevCompilationInfo* compilation_info) {
Isolate* isolate, MaglevCompilationInfo* compilation_info) {
Graph* const graph = compilation_info->graph();
if (graph == nullptr) {
// Compilation failed.
......@@ -577,7 +577,8 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
}
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()
->shared_function_info()
.object()
......@@ -596,7 +597,6 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
code->Print();
}
Isolate* const isolate = compilation_info->isolate();
isolate->native_context()->AddOptimizedCode(ToCodeT(*code));
return ToCodeT(code, isolate);
}
......
......@@ -30,7 +30,7 @@ class MaglevCompiler : public AllStatic {
// Called on the main thread after Compile has completed.
// TODO(v8:7700): Move this to a different class?
static MaybeHandle<CodeT> GenerateCode(
MaglevCompilationInfo* compilation_info);
Isolate* isolate, MaglevCompilationInfo* compilation_info);
};
} // namespace maglev
......
......@@ -108,7 +108,7 @@ CompilationJob::Status MaglevCompilationJob::ExecuteJobImpl(
CompilationJob::Status MaglevCompilationJob::FinalizeJobImpl(Isolate* isolate) {
Handle<CodeT> codet;
if (!maglev::MaglevCompiler::GenerateCode(info()).ToHandle(&codet)) {
if (!maglev::MaglevCompiler::GenerateCode(isolate, info()).ToHandle(&codet)) {
return CompilationJob::FAILED;
}
info()->toplevel_compilation_unit()->function().object()->set_code(*codet);
......
......@@ -18,7 +18,7 @@ MaybeHandle<CodeT> Maglev::Compile(Isolate* isolate,
maglev::MaglevCompilationInfo::New(isolate, function);
maglev::MaglevCompiler::Compile(isolate->main_thread_local_isolate(),
info.get());
return maglev::MaglevCompiler::GenerateCode(info.get());
return maglev::MaglevCompiler::GenerateCode(isolate, info.get());
}
} // 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