An isolate configuration is a collection of snapshots and asset managers that the engine will use to configure the isolate before invoking its root entrypoint. The set of snapshots must be sufficient for the engine to move the isolate from the |DartIsolate::Phase::LibrariesSetup| phase to the |DartIsolate::Phase::Ready| phase. Note that the isolate configuration will not be collected till the isolate tied to the configuration as well as any and all child isolates of that isolate are collected. The engine may ask the configuration to prepare multiple isolates. All subclasses of this class must be thread safe as the configuration may be created, collected and used on multiple threads. Usually these threads are engine or VM managed so care must be taken to ensure that subclasses do not reference any thread local state. More...
#include <isolate_configuration.h>
Public Member Functions | |
| IsolateConfiguration () | |
| Create an isolate configuration. This has no threading restrictions. | |
| 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). | |
| 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. | |
| virtual bool | IsNullSafetyEnabled (const DartSnapshot &snapshot)=0 |
Static Public Member Functions | |
| static std::unique_ptr< IsolateConfiguration > | InferFromSettings (const Settings &settings, const std::shared_ptr< AssetManager > &asset_manager=nullptr, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup) |
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. | |
| static std::unique_ptr< IsolateConfiguration > | CreateForAppSnapshot () |
| 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. | |
| static std::unique_ptr< IsolateConfiguration > | CreateForKernelList (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. | |
| static std::unique_ptr< IsolateConfiguration > | CreateForKernel (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. | |
| static std::unique_ptr< IsolateConfiguration > | CreateForKernelList (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. | |
Protected Member Functions | |
| virtual bool | DoPrepareIsolate (DartIsolate &isolate)=0 |
An isolate configuration is a collection of snapshots and asset managers that the engine will use to configure the isolate before invoking its root entrypoint. The set of snapshots must be sufficient for the engine to move the isolate from the |DartIsolate::Phase::LibrariesSetup| phase to the |DartIsolate::Phase::Ready| phase. Note that the isolate configuration will not be collected till the isolate tied to the configuration as well as any and all child isolates of that isolate are collected. The engine may ask the configuration to prepare multiple isolates. All subclasses of this class must be thread safe as the configuration may be created, collected and used on multiple threads. Usually these threads are engine or VM managed so care must be taken to ensure that subclasses do not reference any thread local state.
Definition at line 47 of file isolate_configuration.h.
|
default |
Create an isolate configuration. This has no threading restrictions.
|
virtualdefault |
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).
|
static |
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.
Definition at line 269 of file isolate_configuration.cc.
Referenced by InferFromSettings().
|
static |
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.
| [in] | kernel | The kernel snapshot. |
Definition at line 273 of file isolate_configuration.cc.
Referenced by InferFromSettings(), and flutter::RunTester().
|
static |
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.
| [in] | kernel_pieces | The list of futures to Dart kernel snapshots. |
Definition at line 293 of file isolate_configuration.cc.
Referenced by CreateForKernelList(), and InferFromSettings().
|
static |
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.
| [in] | kernel_pieces | The kernel pieces |
Definition at line 278 of file isolate_configuration.cc.
References CreateForKernelList(), and FML_DLOG.
|
protectedpure virtual |
Implemented in flutter::AppSnapshotIsolateConfiguration, flutter::KernelIsolateConfiguration, and flutter::KernelListIsolateConfiguration.
Referenced by PrepareIsolate().
|
static |
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.
| [in] | settings | The settings |
| [in] | asset_manager | The optional asset manager. This is used when using the legacy settings fields that specify the asset by name instead of a mappings callback. |
| [in] | io_worker | An optional IO worker. Specify nullptr if a worker should not be used or one is not available. |
| [in] | launch_type | Whether the isolate is launching to form a new group or as part of an existing group. If it is part of an existing group, the isolate will reuse resources if it can. |
nullptr. Definition at line 203 of file isolate_configuration.cc.
References flutter::Settings::application_kernel_asset, flutter::Settings::application_kernel_list_asset, flutter::Settings::application_kernels, CreateForAppSnapshot(), CreateForKernel(), CreateForKernelList(), FML_DLOG, FML_LOG, flutter::DartVM::IsRunningPrecompiledCode(), flutter::kExistingGroup, flutter::ParseKernelListPaths(), and flutter::PrepareKernelMappings().
Referenced by flutter::testing::CreateAndRunRootIsolate(), flutter::RunConfiguration::InferFromSettings(), flutter::testing::RunDartCodeInIsolateOnUITaskRunner(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::PlatformIsolateManagerTest::TestWithRootIsolate().
|
pure virtual |
| bool flutter::IsolateConfiguration::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.
| isolate | The isolate which is already in the DartIsolate::Phase::LibrariesSetup phase. |
DartIsolate::Phase::Ready phase for subsequent run. Definition at line 16 of file isolate_configuration.cc.
References DoPrepareIsolate(), FML_DLOG, flutter::DartIsolate::GetPhase(), and flutter::DartIsolate::LibrariesSetup.