From b5d80964876d1f99127f8df13d814841c3e760d5 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 9 Mar 2020 20:08:45 -0700 Subject: [PATCH] Use the ELF loader to setup AOT symbols in benchmark runner. We no longer package AOT artifacts as discrete blobs. The portable ELF loader from the testing library may be used instead. Fixes https://github.com/flutter/flutter/issues/52263 --- lib/ui/BUILD.gn | 5 +---- runtime/BUILD.gn | 1 + shell/common/BUILD.gn | 2 ++ shell/common/shell_benchmarks.cc | 26 +++++++------------------- shell/platform/embedder/BUILD.gn | 1 + testing/BUILD.gn | 2 +- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index 235c1acdefdf9..4d3210d3bef37 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -175,10 +175,7 @@ if (current_toolchain == host_toolchain) { ":ui", ":ui_unittests_fixtures", "//flutter/common", - "//flutter/fml", - "//flutter/lib/snapshot", - "//flutter/runtime", - "//flutter/shell/common", + "//flutter/testing", "//flutter/testing:dart", "//flutter/testing:opengl", "//flutter/third_party/tonic", diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index a61d36256698b..59ebfbedc9d92 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -150,6 +150,7 @@ source_set("runtime_unittests_common") { "//flutter/fml", "//flutter/lib/snapshot", "//flutter/shell/common", + "//flutter/testing", "//flutter/testing:dart", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:elf_loader", diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 970638ea8dac6..8e4a48e2bb000 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -209,6 +209,7 @@ if (enable_unittests) { "//flutter/fml/dart", "//flutter/lib/ui:ui", "//flutter/shell", + "//flutter/testing", "//flutter/testing:dart", ] @@ -278,6 +279,7 @@ if (enable_unittests) { deps = [ ":shell_unittests_fixtures", "//flutter/benchmarking", + "//flutter/testing:dart", "//flutter/testing:testing_lib", ] } diff --git a/shell/common/shell_benchmarks.cc b/shell/common/shell_benchmarks.cc index f7eb44e4c551a..99d38e70d8143 100644 --- a/shell/common/shell_benchmarks.cc +++ b/shell/common/shell_benchmarks.cc @@ -7,6 +7,7 @@ #include "flutter/runtime/dart_vm.h" #include "flutter/shell/common/shell.h" #include "flutter/shell/common/thread_host.h" +#include "flutter/testing/elf_loader.h" #include "flutter/testing/testing.h" namespace flutter { @@ -18,6 +19,8 @@ static void StartupAndShutdownShell(benchmark::State& state, fml::FilePermission::kRead); std::unique_ptr shell; std::unique_ptr thread_host; + testing::ELFAOTSymbols aot_symbols; + { benchmarking::ScopedPauseTiming pause(state, !measure_startup); Settings settings = {}; @@ -25,25 +28,10 @@ static void StartupAndShutdownShell(benchmark::State& state, settings.task_observer_remove = [](intptr_t) {}; if (DartVM::IsRunningPrecompiledCode()) { - settings.vm_snapshot_data = [&]() { - return fml::FileMapping::CreateReadOnly(assets_dir, "vm_snapshot_data"); - }; - - settings.isolate_snapshot_data = [&]() { - return fml::FileMapping::CreateReadOnly(assets_dir, - "isolate_snapshot_data"); - }; - - settings.vm_snapshot_instr = [&]() { - return fml::FileMapping::CreateReadExecute(assets_dir, - "vm_snapshot_instr"); - }; - - settings.isolate_snapshot_instr = [&]() { - return fml::FileMapping::CreateReadExecute(assets_dir, - "isolate_snapshot_instr"); - }; - + aot_symbols = testing::LoadELFSymbolFromFixturesIfNeccessary(); + FML_CHECK( + testing::PrepareSettingsForAOTWithSymbols(settings, aot_symbols)) + << "Could not setup settings with AOT symbols."; } else { settings.application_kernels = [&]() { std::vector> kernel_mappings; diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 7215622912c76..09547a3de27e0 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -137,6 +137,7 @@ if (current_toolchain == host_toolchain) { "//flutter/flow", "//flutter/lib/ui", "//flutter/runtime", + "//flutter/testing", "//flutter/testing:dart", "//flutter/testing:opengl", "//flutter/testing:skia", diff --git a/testing/BUILD.gn b/testing/BUILD.gn index 67a920f10128b..b8c3bd0a2d53b 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn @@ -52,7 +52,7 @@ source_set("dart") { ] public_deps = [ - ":testing", + ":testing_lib", "//flutter/common", "//flutter/runtime", "//flutter/runtime:libdart",