Fix starting isolate directly from CoreJIT snapshot. (flutter/engine#5798)
This commit is contained in:
committed by
GitHub
parent
4ab74637ba
commit
19219f9693
@@ -257,10 +257,6 @@ bool DartIsolate::PrepareForRunningFromPrecompiledCode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DartVM::IsRunningPrecompiledCode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tonic::DartState::Scope scope(this);
|
||||
|
||||
if (Dart_IsNull(Dart_RootLibrary())) {
|
||||
@@ -342,9 +338,8 @@ bool DartIsolate::PrepareForRunningFromSnapshot(
|
||||
|
||||
tonic::DartState::Scope scope(this);
|
||||
|
||||
if (!Dart_IsNull(Dart_RootLibrary())) {
|
||||
return false;
|
||||
}
|
||||
// Use root library provided by kernel in favor of one provided by snapshot.
|
||||
Dart_SetRootLibrary(Dart_Null());
|
||||
|
||||
if (!LoadSnapshot(mapping, last_piece)) {
|
||||
return false;
|
||||
|
||||
@@ -31,20 +31,17 @@ bool IsolateConfiguration::PrepareIsolate(
|
||||
return DoPrepareIsolate(*isolate);
|
||||
}
|
||||
|
||||
class PrecompiledIsolateConfiguration final : public IsolateConfiguration {
|
||||
class AppSnapshotIsolateConfiguration final : public IsolateConfiguration {
|
||||
public:
|
||||
PrecompiledIsolateConfiguration() = default;
|
||||
AppSnapshotIsolateConfiguration() = default;
|
||||
|
||||
// |shell::IsolateConfiguration|
|
||||
bool DoPrepareIsolate(blink::DartIsolate& isolate) override {
|
||||
if (!blink::DartVM::IsRunningPrecompiledCode()) {
|
||||
return false;
|
||||
}
|
||||
return isolate.PrepareForRunningFromPrecompiledCode();
|
||||
}
|
||||
|
||||
private:
|
||||
FXL_DISALLOW_COPY_AND_ASSIGN(PrecompiledIsolateConfiguration);
|
||||
FXL_DISALLOW_COPY_AND_ASSIGN(AppSnapshotIsolateConfiguration);
|
||||
};
|
||||
|
||||
class SnapshotIsolateConfiguration : public IsolateConfiguration {
|
||||
@@ -122,7 +119,7 @@ std::unique_ptr<IsolateConfiguration> IsolateConfiguration::InferFromSettings(
|
||||
fml::RefPtr<blink::AssetManager> asset_manager) {
|
||||
// Running in AOT mode.
|
||||
if (blink::DartVM::IsRunningPrecompiledCode()) {
|
||||
return CreateForPrecompiledCode();
|
||||
return CreateForAppSnapshot();
|
||||
}
|
||||
|
||||
// Run from sources.
|
||||
@@ -193,8 +190,8 @@ std::unique_ptr<IsolateConfiguration> IsolateConfiguration::InferFromSettings(
|
||||
}
|
||||
|
||||
std::unique_ptr<IsolateConfiguration>
|
||||
IsolateConfiguration::CreateForPrecompiledCode() {
|
||||
return std::make_unique<PrecompiledIsolateConfiguration>();
|
||||
IsolateConfiguration::CreateForAppSnapshot() {
|
||||
return std::make_unique<AppSnapshotIsolateConfiguration>();
|
||||
}
|
||||
|
||||
std::unique_ptr<IsolateConfiguration> IsolateConfiguration::CreateForSnapshot(
|
||||
|
||||
@@ -24,7 +24,7 @@ class IsolateConfiguration {
|
||||
const blink::Settings& settings,
|
||||
fml::RefPtr<blink::AssetManager> asset_manager);
|
||||
|
||||
static std::unique_ptr<IsolateConfiguration> CreateForPrecompiledCode();
|
||||
static std::unique_ptr<IsolateConfiguration> CreateForAppSnapshot();
|
||||
|
||||
static std::unique_ptr<IsolateConfiguration> CreateForSnapshot(
|
||||
std::unique_ptr<fml::Mapping> snapshot);
|
||||
|
||||
@@ -178,7 +178,7 @@ static void SurfaceDestroyed(JNIEnv* env, jobject jcaller, jlong shell_holder) {
|
||||
std::unique_ptr<IsolateConfiguration> CreateIsolateConfiguration(
|
||||
const blink::AssetManager& asset_manager) {
|
||||
if (blink::DartVM::IsRunningPrecompiledCode()) {
|
||||
return IsolateConfiguration::CreateForPrecompiledCode();
|
||||
return IsolateConfiguration::CreateForAppSnapshot();
|
||||
}
|
||||
|
||||
const auto configuration_from_blob =
|
||||
@@ -200,7 +200,8 @@ std::unique_ptr<IsolateConfiguration> CreateIsolateConfiguration(
|
||||
return script;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
// This happens when starting isolate directly from CoreJIT snapshot.
|
||||
return IsolateConfiguration::CreateForAppSnapshot();
|
||||
}
|
||||
|
||||
static void RunBundleAndSnapshot(
|
||||
|
||||
Reference in New Issue
Block a user