diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index ace6f46b18022..729cbf88bf8a0 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -577,6 +577,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, [[nodiscard]] bool DartIsolate::PrepareForRunningFromKernel( std::shared_ptr 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 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 mapping, for (uint64_t i = 0; i < buffers.size(); i++) { bool last_piece = i + 1 == buffers.size(); const std::shared_ptr& 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 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; } } diff --git a/runtime/dart_isolate.h b/runtime/dart_isolate.h index 04ceb4edda77f..47f2ea88c2f3f 100644 --- a/runtime/dart_isolate.h +++ b/runtime/dart_isolate.h @@ -301,7 +301,8 @@ class DartIsolate : public UIDartState { /// [[nodiscard]] bool PrepareForRunningFromKernel( std::shared_ptr kernel, - bool last_piece = true); + bool child_isolate, + bool last_piece); //---------------------------------------------------------------------------- /// @brief Prepare the isolate for running for a a list of kernel files. diff --git a/runtime/isolate_configuration.cc b/runtime/isolate_configuration.cc index a7f4aa19da5c9..dee5c781691bb 100644 --- a/runtime/isolate_configuration.cc +++ b/runtime/isolate_configuration.cc @@ -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; } }