diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 14b2dbd8cd4a1..6b5b591b48f73 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -18,6 +18,7 @@ FILE: ../../../flutter/assets/directory_asset_bundle.h FILE: ../../../flutter/benchmarking/benchmarking.cc FILE: ../../../flutter/benchmarking/benchmarking.h FILE: ../../../flutter/common/exported_symbols.sym +FILE: ../../../flutter/common/runtime.h FILE: ../../../flutter/common/settings.cc FILE: ../../../flutter/common/settings.h FILE: ../../../flutter/common/task_runners.cc diff --git a/common/BUILD.gn b/common/BUILD.gn index b9b05073501d2..69095bbcd45ab 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -10,6 +10,7 @@ config("flutter_config") { source_set("common") { sources = [ + "runtime.h", "settings.cc", "settings.h", "task_runners.cc", diff --git a/common/config.gni b/common/config.gni index 1f0de0a71f89b..cfc4b15936d6a 100644 --- a/common/config.gni +++ b/common/config.gni @@ -21,7 +21,7 @@ if (is_ios || is_mac) { } declare_args() { - # The runtime mode ("debug", "profile", or "release") + # The runtime mode ("debug", "profile", "release", or "jit_release") flutter_runtime_mode = "debug" # Whether to use the Skia text shaper module @@ -39,6 +39,7 @@ feature_defines_list = [ "FLUTTER_RUNTIME_MODE_DEBUG=1", "FLUTTER_RUNTIME_MODE_PROFILE=2", "FLUTTER_RUNTIME_MODE_RELEASE=3", + "FLUTTER_RUNTIME_MODE_JIT_RELEASE=4", ] if (flutter_runtime_mode == "debug") { @@ -47,6 +48,8 @@ if (flutter_runtime_mode == "debug") { feature_defines_list += [ "FLUTTER_RUNTIME_MODE=2" ] } else if (flutter_runtime_mode == "release") { feature_defines_list += [ "FLUTTER_RUNTIME_MODE=3" ] +} else if (flutter_runtime_mode == "jit_release") { + feature_defines_list += [ "FLUTTER_RUNTIME_MODE=4" ] } else { feature_defines_list += [ "FLUTTER_RUNTIME_MODE=0" ] } diff --git a/common/runtime.h b/common/runtime.h new file mode 100644 index 0000000000000..096ffbd86f83a --- /dev/null +++ b/common/runtime.h @@ -0,0 +1,15 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +namespace flutter { + +#define FLUTTER_JIT_RUNTIME \ + ((FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \ + (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE)) + +#define FLUTTER_RELEASE \ + ((FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE) || \ + (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE)) + +} // namespace flutter diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index 8e85f23444d08..433c4f3973784 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -6,6 +6,7 @@ #include +#include "flutter/common/runtime.h" #include "flutter/flow/layers/layer.h" #include "flutter/flow/paint_utils.h" #include "flutter/fml/logging.h" @@ -265,7 +266,7 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) { } void RasterCache::TraceStatsToTimeline() const { -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE size_t layer_cache_count = 0; size_t layer_cache_bytes = 0; @@ -292,7 +293,7 @@ void RasterCache::TraceStatsToTimeline() const { "PictureMBytes", picture_cache_bytes * 1e-6 // ); -#endif // FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#endif // !FLUTTER_RELEASE } } // namespace flutter diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 9968783208543..5a94265e05052 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -59,7 +59,8 @@ compiled_action("generate_snapshot_bin") { ] if (is_debug && flutter_runtime_mode != "profile" && - flutter_runtime_mode != "release") { + flutter_runtime_mode != "release" && + flutter_runtime_mode != "jit_release") { args += [ "--enable_asserts" ] } @@ -261,7 +262,8 @@ compile_platform("strong_platform") { "$root_out_dir/flutter_patched_sdk/vm_outline_strong.dill", ] - is_runtime_mode_release = flutter_runtime_mode == "release" + is_runtime_mode_release = + flutter_runtime_mode == "release" || flutter_runtime_mode == "jit_release" allow_causal_async_stacks = !is_runtime_mode_release args = [ "--target=flutter", diff --git a/lib/ui/window/viewport_metrics.cc b/lib/ui/window/viewport_metrics.cc index 44e42957e3a8f..f18972992189a 100644 --- a/lib/ui/window/viewport_metrics.cc +++ b/lib/ui/window/viewport_metrics.cc @@ -39,10 +39,6 @@ ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, physical_system_gesture_inset_bottom( p_physical_system_gesture_inset_bottom), physical_system_gesture_inset_left(p_physical_system_gesture_inset_left) { - // Ensure we don't have nonsensical dimensions. - FML_DCHECK(physical_width > 0); - FML_DCHECK(physical_height > 0); - FML_DCHECK(device_pixel_ratio > 0); } ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, @@ -72,12 +68,7 @@ ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, physical_view_inset_bottom(p_physical_view_inset_bottom), physical_view_inset_left(p_physical_view_inset_left), physical_view_inset_front(p_physical_view_inset_front), - physical_view_inset_back(p_physical_view_inset_back) { - // Ensure we don't have nonsensical dimensions. - FML_DCHECK(physical_width > 0); - FML_DCHECK(physical_height > 0); - FML_DCHECK(device_pixel_ratio > 0); -} + physical_view_inset_back(p_physical_view_inset_back) {} ViewportMetrics::ViewportMetrics(const ViewportMetrics& other) = default; diff --git a/runtime/dart_snapshot.cc b/runtime/dart_snapshot.cc index 8fe63c095feb9..acebcd3493d84 100644 --- a/runtime/dart_snapshot.cc +++ b/runtime/dart_snapshot.cc @@ -6,6 +6,7 @@ #include +#include "flutter/common/runtime.h" #include "flutter/fml/native_library.h" #include "flutter/fml/paths.h" #include "flutter/fml/trace_event.h" @@ -24,7 +25,7 @@ const char* DartSnapshot::kIsolateInstructionsSymbol = // data through symbols that are statically linked into the executable. // On other platforms this data is obtained by a dynamic symbol lookup. #define DART_SNAPSHOT_STATIC_LINK \ - (OS_WIN || (OS_ANDROID && FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)) + (OS_WIN || (OS_ANDROID && FLUTTER_JIT_RUNTIME)) #if !DART_SNAPSHOT_STATIC_LINK diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 72d78c74e800d..55d081a189339 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -9,6 +9,7 @@ #include #include +#include "flutter/common/runtime.h" #include "flutter/common/settings.h" #include "flutter/fml/compiler_specific.h" #include "flutter/fml/file.h" @@ -39,7 +40,7 @@ namespace dart { namespace observatory { -#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE) +#if !OS_FUCHSIA && !FLUTTER_RELEASE // These two symbols are defined in |observatory_archive.cc| which is generated // by the |//third_party/dart/runtime/observatory:archive_observatory| rule. @@ -48,8 +49,7 @@ namespace observatory { extern unsigned int observatory_assets_archive_len; extern const uint8_t* observatory_assets_archive; -#endif // !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != - // FLUTTER_RUNTIME_MODE_RELEASE) +#endif // !OS_FUCHSIA && !FLUTTER_RELEASE } // namespace observatory } // namespace dart @@ -148,7 +148,7 @@ bool DartFileModifiedCallback(const char* source_url, int64_t since_ms) { void ThreadExitCallback() {} Dart_Handle GetVMServiceAssetsArchiveCallback() { -#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE) +#if FLUTTER_RELEASE return nullptr; #elif OS_FUCHSIA fml::UniqueFD fd = fml::OpenFile("pkg/data/observatory.tar", false, diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 38ee3f50dcfe1..c22478680b945 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -10,6 +10,7 @@ #include #include "flutter/assets/directory_asset_bundle.h" +#include "flutter/common/runtime.h" #include "flutter/fml/file.h" #include "flutter/fml/icu_util.h" #include "flutter/fml/log_settings.h" @@ -1049,7 +1050,7 @@ void Shell::OnFrameRasterized(const FrameTiming& timing) { first_frame_rasterized_ = true; ReportTimings(); } else if (!frame_timings_report_scheduled_) { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE +#if FLUTTER_RELEASE constexpr int kBatchTimeInMilliseconds = 1000; #else constexpr int kBatchTimeInMilliseconds = 100; diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index c1160b92643f9..6968cf72994a4 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -8,6 +8,7 @@ #include #include +#include "flutter/common/runtime.h" #include "flutter/flow/layers/layer_tree.h" #include "flutter/flow/layers/transform_layer.h" #include "flutter/fml/command_line.h" @@ -207,6 +208,10 @@ TEST(ShellTestNoFixture, EnableMirrorsIsWhitelisted) { GTEST_SKIP(); return; } +#if FLUTTER_RELEASE + GTEST_SKIP(); + return; +#endif const std::vector options = { fml::CommandLine::Option("dart-flags", "--enable_mirrors")}; @@ -223,7 +228,7 @@ TEST_F(ShellTest, BlacklistedDartVMFlag) { fml::CommandLine::Option("dart-flags", "--verify_after_gc")}; fml::CommandLine command_line("", options, std::vector()); -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE // Upon encountering a non-whitelisted Dart flag the process terminates. const char* expected = "Encountered blacklisted Dart VM flag: --verify_after_gc"; @@ -241,7 +246,7 @@ TEST_F(ShellTest, WhitelistedDartVMFlag) { fml::CommandLine command_line("", options, std::vector()); flutter::Settings settings = flutter::SettingsFromCommandLine(command_line); -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE EXPECT_EQ(settings.dart_flags.size(), 2u); EXPECT_EQ(settings.dart_flags[0], "--max_profile_depth 1"); EXPECT_EQ(settings.dart_flags[1], "--random_seed 42"); @@ -433,7 +438,7 @@ TEST(SettingsTest, FrameTimingSetsAndGetsProperly) { } } -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE +#if FLUTTER_RELEASE TEST_F(ShellTest, ReportTimingsIsCalledLaterInReleaseMode) { #else TEST_F(ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) { @@ -473,7 +478,7 @@ TEST_F(ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) { fml::TimePoint finish = fml::TimePoint::Now(); fml::TimeDelta ellapsed = finish - start; -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE +#if FLUTTER_RELEASE // Our batch time is 1000ms. Hopefully the 800ms limit is relaxed enough to // make it not too flaky. ASSERT_TRUE(ellapsed >= fml::TimeDelta::FromMilliseconds(800)); diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 7396df7fa907b..ec275b36a475c 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -9,6 +9,7 @@ #include #include +#include "flutter/common/runtime.h" #include "flutter/fml/native_library.h" #include "flutter/fml/paths.h" #include "flutter/fml/size.h" @@ -36,7 +37,7 @@ struct SwitchDesc { #define DEF_SWITCHES_END }; // clang-format on -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE // List of common and safe VM flags to allow to be passed directly to the VM. // clang-format off @@ -134,7 +135,7 @@ const std::string_view FlagForSwitch(Switch swtch) { return std::string_view(); } -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE static bool IsWhitelistedDartVMFlag(const std::string& flag) { for (uint32_t i = 0; i < fml::size(gDartFlagsWhitelist); ++i) { @@ -328,7 +329,7 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { settings.use_test_fonts = command_line.HasOption(FlagForSwitch(Switch::UseTestFonts)); -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if !FLUTTER_RELEASE command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag); std::string all_dart_flags; if (command_line.GetOptionValue(FlagForSwitch(Switch::DartFlags), diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index 1d1c08d2bb3af..5e1d00b132ba1 100644 --- a/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/shell/platform/android/io/flutter/view/FlutterMain.java @@ -186,7 +186,7 @@ public static void ensureInitializationComplete(@NonNull Context applicationCont } String kernelPath = null; - if (BuildConfig.DEBUG) { + if (BuildConfig.DEBUG || BuildConfig.JIT_RELEASE) { String snapshotAssetPath = PathUtils.getDataDirectory(applicationContext) + File.separator + sFlutterAssetsDir; kernelPath = snapshotAssetPath + File.separator + DEFAULT_KERNEL_BLOB; shellArgs.add("--" + SNAPSHOT_ASSET_PATH_KEY + "=" + snapshotAssetPath); @@ -297,7 +297,7 @@ private static void initConfig(@NonNull Context applicationContext) { private static void initResources(@NonNull Context applicationContext) { new ResourceCleaner(applicationContext).start(); - if (BuildConfig.DEBUG) { + if (BuildConfig.DEBUG || BuildConfig.JIT_RELEASE) { final String dataDirPath = PathUtils.getDataDirectory(applicationContext); final String packageName = applicationContext.getPackageName(); final PackageManager packageManager = applicationContext.getPackageManager(); diff --git a/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn b/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn index b1c94a762da59..1dca94e3c2acd 100644 --- a/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn +++ b/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn @@ -34,10 +34,10 @@ source_set("utils") { "$fuchsia_sdk_root/pkg:async-loop-default", "$fuchsia_sdk_root/pkg:fdio", "$fuchsia_sdk_root/pkg:memfs", - "$fuchsia_sdk_root/pkg:syslog", - "$fuchsia_sdk_root/pkg:zx", "$fuchsia_sdk_root/pkg:sys_cpp", + "$fuchsia_sdk_root/pkg:syslog", "$fuchsia_sdk_root/pkg:vfs_cpp", + "$fuchsia_sdk_root/pkg:zx", "//third_party/tonic", ] diff --git a/testing/testing.gni b/testing/testing.gni index 30c6c715518cb..7de912ca9032a 100644 --- a/testing/testing.gni +++ b/testing/testing.gni @@ -87,7 +87,8 @@ template("dart_snapshot_kernel") { rebase_path(snapshot_depfile), ] - if (flutter_runtime_mode == "release") { + if (flutter_runtime_mode == "release" || + flutter_runtime_mode == "jit_release") { args += [ "-Ddart.vm.product=true" ] } diff --git a/tools/gen_android_buildconfig.py b/tools/gen_android_buildconfig.py index 648ec8a59293a..f54c8723e914c 100644 --- a/tools/gen_android_buildconfig.py +++ b/tools/gen_android_buildconfig.py @@ -23,6 +23,7 @@ public final static boolean DEBUG = {0}; public final static boolean PROFILE = {1}; public final static boolean RELEASE = {2}; + public final static boolean JIT_RELEASE = {3}; }} """ @@ -33,13 +34,14 @@ def main(): args = parser.parse_args() - release ='release' in args.runtime_mode.lower() - profile = not release and 'profile' in args.runtime_mode.lower() - debug = not release and not profile and 'debug' in args.runtime_mode.lower() - assert debug or profile or release + jit_release = 'jit_release' in args.runtime_mode.lower() + release = not jit_release and 'release' in args.runtime_mode.lower() + profile = 'profile' in args.runtime_mode.lower() + debug = 'debug' in args.runtime_mode.lower() + assert debug or profile or release or jit_release with open(os.path.abspath(args.out), 'w+') as output_file: - output_file.write(BUILD_CONFIG_TEMPLATE.format(str(debug).lower(), str(profile).lower(), str(release).lower())) + output_file.write(BUILD_CONFIG_TEMPLATE.format(str(debug).lower(), str(profile).lower(), str(release).lower(), str(jit_release).lower())) if __name__ == '__main__': sys.exit(main()) diff --git a/tools/gn b/tools/gn index 6e0992ee623f4..b49f203db0f7e 100755 --- a/tools/gn +++ b/tools/gn @@ -17,8 +17,6 @@ def get_out_dir(args): target_dir = ['host'] runtime_mode = args.runtime_mode - if args.dynamic and runtime_mode in ['profile', 'release']: - target_dir.append('dynamic') target_dir.append(args.runtime_mode) @@ -81,8 +79,6 @@ def to_gn_args(args): raise Exception('--enable-metal is only supported on iOS') runtime_mode = args.runtime_mode - if args.dynamic and runtime_mode in ['profile', 'release']: - runtime_mode = 'dynamic_' + runtime_mode gn_args = {} @@ -148,10 +144,8 @@ def to_gn_args(args): if runtime_mode == 'debug': gn_args['dart_runtime_mode'] = 'develop' - elif runtime_mode == 'dynamic_profile': - gn_args['dart_runtime_mode'] = 'profile' - elif runtime_mode == 'dynamic_release': - gn_args['dart_runtime_mode'] = 'release' + elif runtime_mode == 'jit_release': + gn_args['dart_runtime_mode'] = 'release'; else: gn_args['dart_runtime_mode'] = runtime_mode @@ -271,8 +265,7 @@ def parse_args(args): parser.add_argument('--unoptimized', default=False, action='store_true') - parser.add_argument('--runtime-mode', type=str, choices=['debug', 'profile', 'release'], default='debug') - parser.add_argument('--dynamic', default=False, action='store_true') + parser.add_argument('--runtime-mode', type=str, choices=['debug', 'profile', 'release', 'jit_release'], default='debug') parser.add_argument('--interpreter', default=False, action='store_true') parser.add_argument('--dart-debug', default=False, action='store_true', help='Enables assertsion in the Dart VM. ' + 'Does not affect optimization levels. If you need to disable optimizations in Dart, use --full-dart-debug')