From 620684764adfeb46bab47d647c04da62e9ee41f9 Mon Sep 17 00:00:00 2001 From: David Worsham Date: Tue, 25 Jan 2022 13:07:09 -0800 Subject: [PATCH] Revert "[fuchsia] Switch from core-jit to core snapshots. (#30744)" This reverts commit a193f08cd006fb5cbc6f22a93e6d8b1d23c5c2e5. --- shell/platform/fuchsia/dart_runner/BUILD.gn | 10 +++++++++ .../dart_runner/dart_component_controller.cc | 18 +++++++++------- .../dart_component_controller_v2.cc | 19 ++++++++++------- .../fuchsia/dart_runner/dart_runner.cc | 6 ++++++ .../fuchsia/dart_runner/kernel/BUILD.gn | 12 ++++++++++- .../fuchsia/dart_runner/service_isolate.cc | 21 +++++++------------ shell/platform/fuchsia/flutter/BUILD.gn | 10 +++++++++ .../platform/fuchsia/flutter/component_v1.cc | 12 ++++++++--- .../platform/fuchsia/flutter/component_v2.cc | 12 ++++++++--- .../platform/fuchsia/flutter/kernel/BUILD.gn | 12 ++++++++++- 10 files changed, 95 insertions(+), 37 deletions(-) diff --git a/shell/platform/fuchsia/dart_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/BUILD.gn index 63f41f6e56347..3d3fad3828380 100644 --- a/shell/platform/fuchsia/dart_runner/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/BUILD.gn @@ -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) { diff --git a/shell/platform/fuchsia/dart_runner/dart_component_controller.cc b/shell/platform/fuchsia/dart_runner/dart_component_controller.cc index 2f29dc4ea2603..b3d7a4ca1342c 100644 --- a/shell/platform/fuchsia/dart_runner/dart_component_controller.cc +++ b/shell/platform/fuchsia/dart_runner/dart_component_controller.cc @@ -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; } @@ -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) diff --git a/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc b/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc index e7d1065b5c490..31bec7d29e0c0 100644 --- a/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc +++ b/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc @@ -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; @@ -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; } @@ -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) diff --git a/shell/platform/fuchsia/dart_runner/dart_runner.cc b/shell/platform/fuchsia/dart_runner/dart_runner.cc index 17613db7299f5..fba5805216cb2 100644 --- a/shell/platform/fuchsia/dart_runner/dart_runner.cc +++ b/shell/platform/fuchsia/dart_runner/dart_runner.cc @@ -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; diff --git a/shell/platform/fuchsia/dart_runner/kernel/BUILD.gn b/shell/platform/fuchsia/dart_runner/kernel/BUILD.gn index 92287802d22f3..d831ccd47be25 100644 --- a/shell/platform/fuchsia/dart_runner/kernel/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/kernel/BUILD.gn @@ -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, ] @@ -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), ] diff --git a/shell/platform/fuchsia/dart_runner/service_isolate.cc b/shell/platform/fuchsia/dart_runner/service_isolate.cc index a43f3382a25e6..6c7ca066c673b 100644 --- a/shell/platform/fuchsia/dart_runner/service_isolate.cc +++ b/shell/platform/fuchsia/dart_runner/service_isolate.cc @@ -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)) { @@ -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 = diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index 98669f0169ae1..de41ca3927e90 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -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 = [] diff --git a/shell/platform/fuchsia/flutter/component_v1.cc b/shell/platform/fuchsia/flutter/component_v1.cc index 0872a2d5292ff..36e7159cecd5f 100644 --- a/shell/platform/fuchsia/flutter/component_v1.cc +++ b/shell/platform/fuchsia/flutter/component_v1.cc @@ -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) diff --git a/shell/platform/fuchsia/flutter/component_v2.cc b/shell/platform/fuchsia/flutter/component_v2.cc index 8d52908760849..b0683699a0dfc 100644 --- a/shell/platform/fuchsia/flutter/component_v2.cc +++ b/shell/platform/fuchsia/flutter/component_v2.cc @@ -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) diff --git a/shell/platform/fuchsia/flutter/kernel/BUILD.gn b/shell/platform/fuchsia/flutter/kernel/BUILD.gn index 6086617acdf47..470f07964d74b 100644 --- a/shell/platform/fuchsia/flutter/kernel/BUILD.gn +++ b/shell/platform/fuchsia/flutter/kernel/BUILD.gn @@ -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, ] @@ -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), ]