Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Revert "[fuchsia] Switch from core-jit to core snapshots. (#30744)" #31065

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,21 @@ template("jit_runner_package") {
rebase_path("$target_gen_dir/kernel/vm_data${product_suffix}.bin")
dest = "vm_snapshot_data.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/vm_instructions${product_suffix}.bin")
dest = "vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/isolate_data${product_suffix}.bin")
dest = "isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/isolate_instructions${product_suffix}.bin")
dest = "isolate_core_snapshot_instructions.bin"
},
]

if (!invoker.product) {
Expand Down
18 changes: 11 additions & 7 deletions shell/platform/fuchsia/dart_runner/dart_component_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ bool DartComponentController::SetupFromKernel() {
isolate_snapshot_data_)) {
return false;
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}

// The core snapshot does not separate instructions from data.
if (!CreateIsolate(isolate_snapshot_data_.address(),
nullptr /* isolate_snapshot_instructions */)) {
isolate_snapshot_instructions_.address())) {
return false;
}

Expand Down Expand Up @@ -273,16 +277,16 @@ bool DartComponentController::SetupFromAppSnapshot() {
return false;
}
} else {
// TODO(fxb/91200): This code path was broken for over a year and is
// probably not used.
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
isolate_data = isolate_snapshot_data_.address();
// We don't separate instructions from data in 'core' snapshots.
isolate_instructions = nullptr;
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}
}
return CreateIsolate(isolate_data, isolate_instructions);
#endif // defined(AOT_RUNTIME)
Expand Down
19 changes: 11 additions & 8 deletions shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ bool DartComponentControllerV2::CreateAndBindNamespace() {

bool DartComponentControllerV2::SetUpFromKernel() {
dart_utils::MappedResource manifest;

if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/app.dilplist", manifest)) {
return false;
Expand All @@ -225,10 +224,14 @@ bool DartComponentControllerV2::SetUpFromKernel() {
isolate_snapshot_data_)) {
return false;
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}

// The core snapshot does not separate instructions from data.
if (!CreateIsolate(isolate_snapshot_data_.address(),
nullptr /* isolate_snapshot_instructions */)) {
isolate_snapshot_instructions_.address())) {
return false;
}

Expand Down Expand Up @@ -293,16 +296,16 @@ bool DartComponentControllerV2::SetUpFromAppSnapshot() {
return false;
}
} else {
// TODO(fxb/91200): This code path was broken for over a year and is
// probably not used.
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
isolate_data = isolate_snapshot_data_.address();
// We don't separate instructions from data in 'core' snapshots.
isolate_instructions = nullptr;
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}
}
return CreateIsolate(isolate_data, isolate_instructions);
#endif // defined(AOT_RUNTIME)
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/fuchsia/dart_runner/dart_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ DartRunner::DartRunner(sys::ComponentContext* context) : context_(context) {
nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/vm_snapshot_instructions.bin",
vm_snapshot_instructions_, true /* executable */)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
}
params.vm_snapshot_data = vm_snapshot_data_.address();
params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
#endif
params.create_group = IsolateGroupCreateCallback;
params.shutdown_isolate = IsolateShutdownCallback;
Expand Down
12 changes: 11 additions & 1 deletion shell/platform/fuchsia/dart_runner/kernel/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ template("create_kernel_core_snapshot") {
inputs = [ platform_dill ]

vm_snapshot_data = "$target_gen_dir/vm_data${product_suffix}.bin"
vm_snapshot_instructions =
"$target_gen_dir/vm_instructions${product_suffix}.bin"
isolate_snapshot_data = "$target_gen_dir/isolate_data${product_suffix}.bin"
isolate_snapshot_instructions =
"$target_gen_dir/isolate_instructions${product_suffix}.bin"
snapshot_profile = "$target_gen_dir/snapshot_profile${product_suffix}.json"
outputs = [
vm_snapshot_data,
vm_snapshot_instructions,
isolate_snapshot_data,
isolate_snapshot_instructions,
snapshot_profile,
]

Expand All @@ -59,10 +65,14 @@ template("create_kernel_core_snapshot") {
"--lazy_async_stacks",
"--enable_mirrors=false",
"--deterministic",
"--snapshot_kind=core",
"--snapshot_kind=core-jit",
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
"--vm_snapshot_instructions=" +
rebase_path(vm_snapshot_instructions, root_build_dir),
"--isolate_snapshot_data=" +
rebase_path(isolate_snapshot_data, root_build_dir),
"--isolate_snapshot_instructions=" +
rebase_path(isolate_snapshot_instructions, root_build_dir),
"--write_v8_snapshot_profile_to=" +
rebase_path(snapshot_profile, root_build_dir),
]
Expand Down
21 changes: 7 additions & 14 deletions shell/platform/fuchsia/dart_runner/service_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ Dart_Isolate CreateServiceIsolate(
"/pkg/data/vmservice_isolate_snapshot_data.bin";
const char* snapshot_instructions_path =
"/pkg/data/vmservice_isolate_snapshot_instructions.bin";
#else
// The VM service is embedded in the core snapshot.
const char* snapshot_data_path = "/pkg/data/isolate_core_snapshot_data.bin";
const char* snapshot_instructions_path =
"/pkg/data/isolate_core_snapshot_instructions.bin";
#endif

if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, snapshot_data_path, mapped_isolate_snapshot_data)) {
Expand All @@ -113,21 +119,8 @@ Dart_Isolate CreateServiceIsolate(

vmservice_data = mapped_isolate_snapshot_data.address();
vmservice_instructions = mapped_isolate_snapshot_instructions.address();
#if defined(AOT_RUNTIME)
}
#else
// The VM service is embedded in the core snapshot.
// 'core' snapshot_kinds do not separate instructions from data, so we don't
// load an instructions file.
const char* snapshot_data_path = "/pkg/data/isolate_core_snapshot_data.bin";
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, snapshot_data_path, mapped_isolate_snapshot_data)) {
*error = strdup("Failed to load snapshot for service isolate");
FX_LOG(ERROR, LOG_TAG, *error);
return nullptr;
}

vmservice_data = mapped_isolate_snapshot_data.address();
vmservice_instructions = nullptr;
#endif

bool is_null_safe =
Expand Down
10 changes: 10 additions & 0 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,21 @@ template("jit_runner") {
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
dest = "vm_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
dest = "vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
dest = "isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
dest = "isolate_core_snapshot_instructions.bin"
},
]

_vulkan_icds = []
Expand Down
12 changes: 9 additions & 3 deletions shell/platform/fuchsia/flutter/component_v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,19 @@ ComponentV1::ComponentV1(
return MakeFileMapping("/pkg/data/vm_snapshot_data.bin",
false /* executable */);
};
settings_.vm_snapshot_instr = []() {
return MakeFileMapping("/pkg/data/vm_snapshot_instructions.bin",
true /* executable */);
};

settings_.isolate_snapshot_data = []() {
return MakeFileMapping("/pkg/data/isolate_core_snapshot_data.bin",
false /* executable */);
};

// 'core' snapshots do not separate instructions from data, so we
// don't set isolate_snapshot_instr here.
settings_.isolate_snapshot_instr = [] {
return MakeFileMapping("/pkg/data/isolate_core_snapshot_instructions.bin",
true /* executable */);
};
}

#if defined(DART_PRODUCT)
Expand Down
12 changes: 9 additions & 3 deletions shell/platform/fuchsia/flutter/component_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,19 @@ ComponentV2::ComponentV2(
return MakeFileMapping("/pkg/data/vm_snapshot_data.bin",
false /* executable */);
};
settings_.vm_snapshot_instr = []() {
return MakeFileMapping("/pkg/data/vm_snapshot_instructions.bin",
true /* executable */);
};

settings_.isolate_snapshot_data = []() {
return MakeFileMapping("/pkg/data/isolate_core_snapshot_data.bin",
false /* executable */);
};

// 'core' snapshots do not separate instructions from data, so we
// don't set isolate_snapshot_instr here.
settings_.isolate_snapshot_instr = [] {
return MakeFileMapping("/pkg/data/isolate_core_snapshot_instructions.bin",
true /* executable */);
};
}

#if defined(DART_PRODUCT)
Expand Down
12 changes: 11 additions & 1 deletion shell/platform/fuchsia/flutter/kernel/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ template("core_snapshot") {
inputs = [ platform_dill ]

vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot${suffix}.bin"
vm_snapshot_instructions =
"$target_gen_dir/vm_snapshot_instructions${suffix}.bin"
isolate_snapshot_data = "$target_gen_dir/isolate_snapshot${suffix}.bin"
isolate_snapshot_instructions =
"$target_gen_dir/isolate_snapshot_instructions${suffix}.bin"
snapshot_profile = "$target_gen_dir/snapshot_profile${suffix}.json"
outputs = [
vm_snapshot_data,
vm_snapshot_instructions,
isolate_snapshot_data,
isolate_snapshot_instructions,
snapshot_profile,
]

Expand All @@ -63,10 +69,14 @@ template("core_snapshot") {
"--lazy_async_stacks",
"--enable_mirrors=false",
"--deterministic",
"--snapshot_kind=core",
"--snapshot_kind=core-jit",
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
"--vm_snapshot_instructions=" +
rebase_path(vm_snapshot_instructions, root_build_dir),
"--isolate_snapshot_data=" +
rebase_path(isolate_snapshot_data, root_build_dir),
"--isolate_snapshot_instructions=" +
rebase_path(isolate_snapshot_instructions, root_build_dir),
"--write_v8_snapshot_profile_to=" +
rebase_path(snapshot_profile, root_build_dir),
]
Expand Down