Ensure correct child isolate initialization in enable-isolate-groups dart vm configuration. (flutter/engine#26011)
* Ensure child isolate doesn't load kernel * Guard changes to isolate initialization by enable-isolate-groups flag check
This commit is contained in:
committed by
GitHub
parent
daf0fb7387
commit
227d3fa4b7
@@ -577,6 +577,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
|
||||
|
||||
[[nodiscard]] bool DartIsolate::PrepareForRunningFromKernel(
|
||||
std::shared_ptr<const fml::Mapping> mapping,
|
||||
bool child_isolate,
|
||||
bool last_piece) {
|
||||
TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromKernel");
|
||||
if (phase_ != Phase::LibrariesSetup) {
|
||||
@@ -593,11 +594,13 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
|
||||
|
||||
tonic::DartState::Scope scope(this);
|
||||
|
||||
// Use root library provided by kernel in favor of one provided by snapshot.
|
||||
Dart_SetRootLibrary(Dart_Null());
|
||||
if (!child_isolate || !Dart_IsVMFlagSet("--enable-isolate-groups")) {
|
||||
// Use root library provided by kernel in favor of one provided by snapshot.
|
||||
Dart_SetRootLibrary(Dart_Null());
|
||||
|
||||
if (!LoadKernel(mapping, last_piece)) {
|
||||
return false;
|
||||
if (!LoadKernel(mapping, last_piece)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!last_piece) {
|
||||
@@ -622,7 +625,9 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
|
||||
for (uint64_t i = 0; i < buffers.size(); i++) {
|
||||
bool last_piece = i + 1 == buffers.size();
|
||||
const std::shared_ptr<const fml::Mapping>& buffer = buffers.at(i);
|
||||
if (!isolate->PrepareForRunningFromKernel(buffer, last_piece)) {
|
||||
if (!isolate->PrepareForRunningFromKernel(buffer,
|
||||
/*child_isolate=*/true,
|
||||
last_piece)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +655,8 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
bool last = (i == (count - 1));
|
||||
if (!PrepareForRunningFromKernel(kernels[i], last)) {
|
||||
if (!PrepareForRunningFromKernel(kernels[i], /*child_isolate=*/false,
|
||||
last)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,8 @@ class DartIsolate : public UIDartState {
|
||||
///
|
||||
[[nodiscard]] bool PrepareForRunningFromKernel(
|
||||
std::shared_ptr<const fml::Mapping> kernel,
|
||||
bool last_piece = true);
|
||||
bool child_isolate,
|
||||
bool last_piece);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Prepare the isolate for running for a a list of kernel files.
|
||||
|
||||
@@ -51,7 +51,9 @@ class KernelIsolateConfiguration : public IsolateConfiguration {
|
||||
if (DartVM::IsRunningPrecompiledCode()) {
|
||||
return false;
|
||||
}
|
||||
return isolate.PrepareForRunningFromKernel(std::move(kernel_));
|
||||
return isolate.PrepareForRunningFromKernel(std::move(kernel_),
|
||||
/*child_isolate=*/false,
|
||||
/*last_piece=*/true);
|
||||
}
|
||||
|
||||
// |IsolateConfiguration|
|
||||
@@ -98,7 +100,8 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration {
|
||||
}
|
||||
const bool last_piece = i + 1 == resolved_kernel_pieces_.size();
|
||||
if (!isolate.PrepareForRunningFromKernel(
|
||||
std::move(resolved_kernel_pieces_[i]), last_piece)) {
|
||||
std::move(resolved_kernel_pieces_[i]), /*child_isolate=*/false,
|
||||
last_piece)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user