Flutter Engine
flutter::KernelListIsolateConfiguration Class Referencefinal
Inheritance diagram for flutter::KernelListIsolateConfiguration:
flutter::IsolateConfiguration

Public Member Functions

 KernelListIsolateConfiguration (std::vector< std::future< std::unique_ptr< const fml::Mapping >>> kernel_pieces)
 
bool DoPrepareIsolate (DartIsolate &isolate) override
 
bool IsNullSafetyEnabled (const DartSnapshot &snapshot) override
 
void ResolveKernelPiecesIfNecessary ()
 
- Public Member Functions inherited from flutter::IsolateConfiguration
 IsolateConfiguration ()
 Create an isolate configuration. This has no threading restrictions. More...
 
virtual ~IsolateConfiguration ()
 Destroys an isolate configuration. This has no threading restrictions and may be collection of configurations may occur on any thread (and usually happens on an internal VM managed thread pool thread). More...
 
bool PrepareIsolate (DartIsolate &isolate)
 When an isolate is created and sufficiently initialized to move it into the DartIsolate::Phase::LibrariesSetup phase, this method is invoked on the isolate to then move the isolate into the DartIsolate::Phase::Ready phase. Then isolate's main entrypoint is then invoked to move it into the DartIsolate::Phase::Running phase. This method will be called each time the root isolate is launched (which may be multiple times in cold-restart scenarios) as well as one each for any child isolates referenced by that isolate. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::IsolateConfiguration
static std::unique_ptr< IsolateConfigurationInferFromSettings (const Settings &settings, std::shared_ptr< AssetManager > asset_manager=nullptr, fml::RefPtr< fml::TaskRunner > io_worker=nullptr)
 Attempts to infer the isolate configuration from the Settings object. If the VM is configured for AOT mode, snapshot resolution is attempted with predefined symbols present in the currently loaded process. In JIT mode, Dart kernel file resolution is attempted in the assets directory. If an IO worker is specified, snapshot resolution may be attempted on the serial worker task runner. The worker task runner thread must remain valid and running till after the shell associated with the engine used to launch the isolate for which this run configuration is used is collected. More...
 
static std::unique_ptr< IsolateConfigurationCreateForAppSnapshot ()
 Creates an AOT isolate configuration using snapshot symbols present in the currently loaded process. These symbols need to be given to the Dart VM on bootstrap and hence have already been resolved. More...
 
static std::unique_ptr< IsolateConfigurationCreateForKernelList (std::vector< std::future< std::unique_ptr< const fml::Mapping >>> kernel_pieces)
 Creates a JIT isolate configuration using a list of futures to snapshots defining the ready isolate state. In environments where snapshot resolution is extremely expensive, embedders attempt to resolve snapshots on worker thread(s) and return the future of the promise of snapshot resolution to this method. That way, snapshot resolution begins well before isolate launch is attempted by the engine. More...
 
static std::unique_ptr< IsolateConfigurationCreateForKernel (std::unique_ptr< const fml::Mapping > kernel)
 Creates a JIT isolate configuration using the specified snapshot. This is a convenience method for the CreateForKernelList method that takes a list of futures to Dart kernel snapshots. More...
 
static std::unique_ptr< IsolateConfigurationCreateForKernelList (std::vector< std::unique_ptr< const fml::Mapping >> kernel_pieces)
 Creates a JIT isolate configuration using the specified snapshots. This is a convenience method for the CreateForKernelList method that takes a list of futures to Dart kernel snapshots. More...
 

Detailed Description

Definition at line 68 of file isolate_configuration.cc.

Constructor & Destructor Documentation

◆ KernelListIsolateConfiguration()

flutter::KernelListIsolateConfiguration::KernelListIsolateConfiguration ( std::vector< std::future< std::unique_ptr< const fml::Mapping >>>  kernel_pieces)
inline

Definition at line 70 of file isolate_configuration.cc.

References FML_LOG.

73  : kernel_piece_futures_(std::move(kernel_pieces)) {
74  if (kernel_piece_futures_.empty()) {
75  FML_LOG(ERROR) << "Attempted to create kernel list configuration without "
76  "any kernel blobs.";
77  }
78  }
#define FML_LOG(severity)
Definition: logging.h:65

Member Function Documentation

◆ DoPrepareIsolate()

bool flutter::KernelListIsolateConfiguration::DoPrepareIsolate ( DartIsolate isolate)
inlineoverridevirtual

Implements flutter::IsolateConfiguration.

Definition at line 81 of file isolate_configuration.cc.

References FML_DLOG, flutter::DartVM::IsRunningPrecompiledCode(), and flutter::DartIsolate::PrepareForRunningFromKernel().

81  {
83  return false;
84  }
85 
87 
88  if (resolved_kernel_pieces_.empty()) {
89  FML_DLOG(ERROR) << "No kernel pieces provided to prepare this isolate.";
90  return false;
91  }
92 
93  for (size_t i = 0; i < resolved_kernel_pieces_.size(); i++) {
94  if (!resolved_kernel_pieces_[i]) {
95  FML_DLOG(ERROR) << "This kernel list isolate configuration was already "
96  "used to prepare an isolate.";
97  return false;
98  }
99  const bool last_piece = i + 1 == resolved_kernel_pieces_.size();
100  if (!isolate.PrepareForRunningFromKernel(
101  std::move(resolved_kernel_pieces_[i]), last_piece)) {
102  return false;
103  }
104  }
105 
106  return true;
107  }
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition: dart_vm.cc:199
#define FML_DLOG(severity)
Definition: logging.h:85

◆ IsNullSafetyEnabled()

bool flutter::KernelListIsolateConfiguration::IsNullSafetyEnabled ( const DartSnapshot snapshot)
inlineoverridevirtual

Implements flutter::IsolateConfiguration.

Definition at line 110 of file isolate_configuration.cc.

References flutter::DartSnapshot::IsNullSafetyEnabled().

110  {
112  const auto kernel = resolved_kernel_pieces_.empty()
113  ? nullptr
114  : resolved_kernel_pieces_.front().get();
115  return snapshot.IsNullSafetyEnabled(kernel);
116  }

◆ ResolveKernelPiecesIfNecessary()

void flutter::KernelListIsolateConfiguration::ResolveKernelPiecesIfNecessary ( )
inline

Definition at line 122 of file isolate_configuration.cc.

References FML_DISALLOW_COPY_AND_ASSIGN.

122  {
123  if (resolved_kernel_pieces_.size() == kernel_piece_futures_.size()) {
124  return;
125  }
126 
127  resolved_kernel_pieces_.clear();
128  for (auto& piece : kernel_piece_futures_) {
129  // The get() call will xfer the unique pointer out and leave an empty
130  // future in the original vector.
131  resolved_kernel_pieces_.emplace_back(piece.get());
132  }
133  }

The documentation for this class was generated from the following file: