未验证 提交 e59457b8 编写于 作者: G gaaclarke 提交者: GitHub

Fixed plumbing of the spawning isolate for Shell::Spawn. (#24112)

上级 5792343e
...@@ -406,7 +406,8 @@ bool RuntimeController::LaunchRootIsolate( ...@@ -406,7 +406,8 @@ bool RuntimeController::LaunchRootIsolate(
dart_entrypoint, // dart_entrypoint, //
dart_entrypoint_library, // dart_entrypoint_library, //
std::move(isolate_configuration), // std::move(isolate_configuration), //
volatile_path_tracker_ // volatile_path_tracker_, //
spawning_isolate_.lock().get() //
) )
.lock(); .lock();
...@@ -452,6 +453,17 @@ std::optional<uint32_t> RuntimeController::GetRootIsolateReturnCode() { ...@@ -452,6 +453,17 @@ std::optional<uint32_t> RuntimeController::GetRootIsolateReturnCode() {
return root_isolate_return_code_; return root_isolate_return_code_;
} }
uint64_t RuntimeController::GetRootIsolateGroup() const {
auto isolate = root_isolate_.lock();
if (isolate) {
auto isolate_scope = tonic::DartIsolateScope(isolate->isolate());
Dart_IsolateGroup isolate_group = Dart_CurrentIsolateGroup();
return reinterpret_cast<uint64_t>(isolate_group);
} else {
return 0;
}
}
void RuntimeController::LoadDartDeferredLibrary( void RuntimeController::LoadDartDeferredLibrary(
intptr_t loading_unit_id, intptr_t loading_unit_id,
std::unique_ptr<const fml::Mapping> snapshot_data, std::unique_ptr<const fml::Mapping> snapshot_data,
......
...@@ -508,6 +508,14 @@ class RuntimeController : public PlatformConfigurationClient { ...@@ -508,6 +508,14 @@ class RuntimeController : public PlatformConfigurationClient {
/// ///
std::optional<uint32_t> GetRootIsolateReturnCode(); std::optional<uint32_t> GetRootIsolateReturnCode();
//----------------------------------------------------------------------------
/// @brief Get an identifier that represents the Dart isolate group the
/// root isolate is in.
///
/// @return The root isolate isolate group identifier, zero if one can't
/// be established.
uint64_t GetRootIsolateGroup() const;
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/// @brief Loads the Dart shared library into the Dart VM. When the /// @brief Loads the Dart shared library into the Dart VM. When the
/// Dart library is loaded successfully, the Dart future /// Dart library is loaded successfully, the Dart future
......
...@@ -886,6 +886,13 @@ class Engine final : public RuntimeDelegate, ...@@ -886,6 +886,13 @@ class Engine final : public RuntimeDelegate,
const std::string error_message, const std::string error_message,
bool transient); bool transient);
//--------------------------------------------------------------------------
/// @brief Accessor for the RuntimeController.
///
const RuntimeController* GetRuntimeController() const {
return runtime_controller_.get();
}
private: private:
Engine::Delegate& delegate_; Engine::Delegate& delegate_;
const Settings settings_; const Settings settings_;
......
...@@ -2484,11 +2484,27 @@ TEST_F(ShellTest, Spawn) { ...@@ -2484,11 +2484,27 @@ TEST_F(ShellTest, Spawn) {
ASSERT_NE(nullptr, spawn.get()); ASSERT_NE(nullptr, spawn.get());
ASSERT_TRUE(ValidateShell(spawn.get())); ASSERT_TRUE(ValidateShell(spawn.get()));
PostSync(spawner->GetTaskRunners().GetUITaskRunner(), [&spawn] { PostSync(spawner->GetTaskRunners().GetUITaskRunner(),
// Check second shell ran the second entrypoint. [&spawn, &spawner] {
ASSERT_EQ("testCanLaunchSecondaryIsolate", // Check second shell ran the second entrypoint.
spawn->GetEngine()->GetLastEntrypoint()); ASSERT_EQ("testCanLaunchSecondaryIsolate",
}); spawn->GetEngine()->GetLastEntrypoint());
// TODO(74520): Remove conditional once isolate groups are
// supported by JIT.
if (DartVM::IsRunningPrecompiledCode()) {
ASSERT_NE(spawner->GetEngine()
->GetRuntimeController()
->GetRootIsolateGroup(),
0u);
ASSERT_EQ(spawner->GetEngine()
->GetRuntimeController()
->GetRootIsolateGroup(),
spawn->GetEngine()
->GetRuntimeController()
->GetRootIsolateGroup());
}
});
PostSync( PostSync(
spawner->GetTaskRunners().GetIOTaskRunner(), [&spawner, &spawn] { spawner->GetTaskRunners().GetIOTaskRunner(), [&spawner, &spawn] {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册