-
Notifications
You must be signed in to change notification settings - Fork 6k
Plumbing refactor to allow the usage of Dart_CreateIsolateInGroup #23549
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| #include "flutter/lib/ui/io_manager.h" | ||
| #include "flutter/lib/ui/snapshot_delegate.h" | ||
| #include "flutter/lib/ui/ui_dart_state.h" | ||
| #include "flutter/lib/ui/volatile_path_tracker.h" | ||
| #include "flutter/lib/ui/window/platform_configuration.h" | ||
| #include "flutter/runtime/dart_snapshot.h" | ||
| #include "third_party/dart/runtime/include/dart_api.h" | ||
|
|
@@ -207,7 +206,9 @@ class DartIsolate : public UIDartState { | |
| /// for all isolate shutdowns | ||
| /// (including the children of the | ||
| /// root isolate). | ||
| /// | ||
| /// @param[in] spawning_isolate The isolate that is spawning the | ||
| /// new isolate. See also | ||
| /// DartIsolate::SpawnIsolate. | ||
| /// @return A weak pointer to the root Dart isolate. The caller must | ||
| /// ensure that the isolate is not referenced for long periods of | ||
| /// time as it prevents isolate collection when the isolate | ||
|
|
@@ -232,7 +233,37 @@ class DartIsolate : public UIDartState { | |
| std::optional<std::string> dart_entrypoint, | ||
| std::optional<std::string> dart_entrypoint_library, | ||
| std::unique_ptr<IsolateConfiguration> isolate_configration, | ||
| std::shared_ptr<VolatilePathTracker> volatile_path_tracker); | ||
| std::shared_ptr<VolatilePathTracker> volatile_path_tracker, | ||
| const DartIsolate* spawning_isolate = nullptr); | ||
|
|
||
| //---------------------------------------------------------------------------- | ||
| /// @brief Creates a running DartIsolate who shares as many resources as | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creates a new running DartIsolate from the current DartIsolate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that is much of an improvement. Hopefully the other edits cover the information you are trying to convey with that. |
||
| /// possible with the caller DartIsolate. This allows them to | ||
| /// occupy less memory together and to be created faster. | ||
| /// @details Shared components will be destroyed when the last live | ||
| /// DartIsolate is destroyed. SpawnIsolate can only be used to | ||
| /// create DartIsolates whose executable code is shared with the | ||
| /// calling DartIsolate. | ||
| /// @attention Only certain setups can take advantage of the most savings | ||
| /// currently, AOT specifically. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the same disclosure for why it's a weak pointer, who owns it, performance considerations etc.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| /// @return A weak pointer to a new running DartIsolate. The caller must | ||
| /// ensure that the isolate is not referenced for long periods of | ||
| /// time as it prevents isolate collection when the isolate | ||
| /// terminates itself. The caller may also only use the isolate on | ||
| /// the thread on which the isolate was created. | ||
| std::weak_ptr<DartIsolate> SpawnIsolate( | ||
| const Settings& settings, | ||
| std::unique_ptr<PlatformConfiguration> platform_configuration, | ||
| fml::WeakPtr<SnapshotDelegate> snapshot_delegate, | ||
| fml::WeakPtr<HintFreedDelegate> hint_freed_delegate, | ||
| std::string advisory_script_uri, | ||
| std::string advisory_script_entrypoint, | ||
| Flags flags, | ||
| const fml::closure& isolate_create_callback, | ||
| const fml::closure& isolate_shutdown_callback, | ||
| std::optional<std::string> dart_entrypoint, | ||
| std::optional<std::string> dart_entrypoint_library, | ||
| std::unique_ptr<IsolateConfiguration> isolate_configration) const; | ||
|
|
||
| // |UIDartState| | ||
| ~DartIsolate() override; | ||
|
|
@@ -433,7 +464,8 @@ class DartIsolate : public UIDartState { | |
| Flags flags, | ||
| const fml::closure& isolate_create_callback, | ||
| const fml::closure& isolate_shutdown_callback, | ||
| std::shared_ptr<VolatilePathTracker> volatile_path_tracker); | ||
| std::shared_ptr<VolatilePathTracker> volatile_path_tracker, | ||
| const DartIsolate* spawning_isolate = nullptr); | ||
|
|
||
| DartIsolate(const Settings& settings, | ||
| TaskRunners task_runners, | ||
|
|
@@ -463,6 +495,8 @@ class DartIsolate : public UIDartState { | |
|
|
||
| DartIsolateGroupData& GetIsolateGroupData(); | ||
|
|
||
| const DartIsolateGroupData& GetIsolateGroupData() const; | ||
|
|
||
| // |Dart_IsolateGroupCreateCallback| | ||
| static Dart_Isolate DartIsolateGroupCreateCallback( | ||
| const char* advisory_script_uri, | ||
|
|
@@ -487,7 +521,11 @@ class DartIsolate : public UIDartState { | |
| std::unique_ptr<std::shared_ptr<DartIsolateGroupData>> isolate_group_data, | ||
| std::unique_ptr<std::shared_ptr<DartIsolate>> isolate_data, | ||
| Dart_IsolateFlags* flags, | ||
| char** error); | ||
| char** error, | ||
| std::function<Dart_Isolate(std::shared_ptr<DartIsolateGroupData>*, | ||
| std::shared_ptr<DartIsolate>*, | ||
| Dart_IsolateFlags*, | ||
| char**)> make_isolate); | ||
|
|
||
| static bool InitializeIsolate(std::shared_ptr<DartIsolate> embedder_isolate, | ||
| Dart_Isolate isolate, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you change the signature, update the method doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done