From b1a00d97119e73c71858512e3afa79165d31c777 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 25 Sep 2019 13:02:43 -0700 Subject: [PATCH 01/15] add support for JIT release mode --- common/config.gni | 3 +++ flow/raster_cache.cc | 2 +- lib/snapshot/BUILD.gn | 4 ++-- lib/ui/window/viewport_metrics.cc | 6 +++--- runtime/dart_snapshot.cc | 2 +- runtime/dart_vm.cc | 4 ++-- shell/platform/android/flutter_main.cc | 4 ++-- shell/platform/android/io/flutter/view/FlutterMain.java | 4 ++-- shell/platform/embedder/embedder.cc | 4 ++-- testing/testing.gni | 2 +- tools/gn | 4 +++- 11 files changed, 22 insertions(+), 17 deletions(-) diff --git a/common/config.gni b/common/config.gni index 1f0de0a71f89b..9964dc63160eb 100644 --- a/common/config.gni +++ b/common/config.gni @@ -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/flow/raster_cache.cc b/flow/raster_cache.cc index 8e85f23444d08..71288866d9c3e 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -265,7 +265,7 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) { } void RasterCache::TraceStatsToTimeline() const { -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE +#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE size_t layer_cache_count = 0; size_t layer_cache_bytes = 0; diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 9968783208543..4c255ddae65b8 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -59,7 +59,7 @@ 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 +261,7 @@ 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..dd5fd27f11fe3 100644 --- a/lib/ui/window/viewport_metrics.cc +++ b/lib/ui/window/viewport_metrics.cc @@ -40,9 +40,9 @@ ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, 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); + // FML_DCHECK(physical_width > 0); + // FML_DCHECK(physical_height > 0); + // FML_DCHECK(device_pixel_ratio > 0); } ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, diff --git a/runtime/dart_snapshot.cc b/runtime/dart_snapshot.cc index 8fe63c095feb9..f4824aea3e7bc 100644 --- a/runtime/dart_snapshot.cc +++ b/runtime/dart_snapshot.cc @@ -24,7 +24,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_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE))) #if !DART_SNAPSHOT_STATIC_LINK diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 72d78c74e800d..b792ca98187b0 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -39,7 +39,7 @@ namespace dart { namespace observatory { -#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE) +#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE) // These two symbols are defined in |observatory_archive.cc| which is generated // by the |//third_party/dart/runtime/observatory:archive_observatory| rule. @@ -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_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE) return nullptr; #elif OS_FUCHSIA fml::UniqueFD fd = fml::OpenFile("pkg/data/observatory.tar", false, diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index 1ddcbf6ae9509..c14800fd332e0 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -26,7 +26,7 @@ namespace flutter { extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; @@ -102,7 +102,7 @@ void FlutterMain::Init(JNIEnv* env, fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); }; -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // There are no ownership concerns here as all mappings are owned by the // embedder and not the engine. auto make_mapping_callback = [](const uint8_t* mapping, size_t size) { diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index 1d1c08d2bb3af..ca9fe21d42fd9 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 (true) { 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 (true) { final String dataDirPath = PathUtils.getDataDirectory(applicationContext); final String packageName = applicationContext.getPackageName(); final PackageManager packageManager = applicationContext.getPackageManager(); diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 72da210079e73..e92043f6c5916 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -15,11 +15,11 @@ #endif // OS_WIN extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; -#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE } #include "flutter/assets/directory_asset_bundle.h" diff --git a/testing/testing.gni b/testing/testing.gni index 30c6c715518cb..2826b21bf4a27 100644 --- a/testing/testing.gni +++ b/testing/testing.gni @@ -87,7 +87,7 @@ 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/gn b/tools/gn index 6e0992ee623f4..4d6a6501f6c31 100755 --- a/tools/gn +++ b/tools/gn @@ -152,6 +152,8 @@ def to_gn_args(args): 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,7 +273,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('--runtime-mode', type=str, choices=['debug', 'profile', 'release', 'jit_release'], default='debug') parser.add_argument('--dynamic', default=False, action='store_true') 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. ' + From 449cb359af6e4d9831c4d517efd9e4d58fe1e5bd Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 25 Sep 2019 13:53:08 -0700 Subject: [PATCH 02/15] update android build config for JIT release --- .../android/io/flutter/view/FlutterMain.java | 4 ++-- tools/gen_android_buildconfig.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index ca9fe21d42fd9..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 (true) { + 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 (true) { + 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/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()) From 3ba52af9673c065cd6c78a156793e4ed7afa6151 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 25 Sep 2019 13:57:08 -0700 Subject: [PATCH 03/15] format files --- flow/raster_cache.cc | 3 ++- runtime/dart_snapshot.cc | 6 ++++-- runtime/dart_vm.cc | 6 ++++-- shell/platform/android/flutter_main.cc | 6 ++++-- shell/platform/embedder/embedder.cc | 6 ++++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index 71288866d9c3e..e52095d4a91a6 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -265,7 +265,8 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) { } void RasterCache::TraceStatsToTimeline() const { -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && \ + FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE size_t layer_cache_count = 0; size_t layer_cache_bytes = 0; diff --git a/runtime/dart_snapshot.cc b/runtime/dart_snapshot.cc index f4824aea3e7bc..cf74a51c2c5b6 100644 --- a/runtime/dart_snapshot.cc +++ b/runtime/dart_snapshot.cc @@ -23,8 +23,10 @@ const char* DartSnapshot::kIsolateInstructionsSymbol = // On Windows and Android (in debug mode) the engine finds the Dart snapshot // 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 || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE))) +#define DART_SNAPSHOT_STATIC_LINK \ + (OS_WIN || \ + (OS_ANDROID && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE))) #if !DART_SNAPSHOT_STATIC_LINK diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index b792ca98187b0..5839a7230d335 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -39,7 +39,8 @@ namespace dart { namespace observatory { -#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE) +#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && \ + FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE) // These two symbols are defined in |observatory_archive.cc| which is generated // by the |//third_party/dart/runtime/observatory:archive_observatory| rule. @@ -148,7 +149,8 @@ bool DartFileModifiedCallback(const char* source_url, int64_t since_ms) { void ThreadExitCallback() {} Dart_Handle GetVMServiceAssetsArchiveCallback() { -#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE) +#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE) return nullptr; #elif OS_FUCHSIA fml::UniqueFD fd = fml::OpenFile("pkg/data/observatory.tar", false, diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index c14800fd332e0..5b498868f8fa8 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -26,7 +26,8 @@ namespace flutter { extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; @@ -102,7 +103,8 @@ void FlutterMain::Init(JNIEnv* env, fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); }; -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // There are no ownership concerns here as all mappings are owned by the // embedder and not the engine. auto make_mapping_callback = [](const uint8_t* mapping, size_t size) { diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index e92043f6c5916..036258102e638 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -15,11 +15,13 @@ #endif // OS_WIN extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; -#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || + // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE } #include "flutter/assets/directory_asset_bundle.h" From cdda47ecef0d5a9900998fbe0fd408885cf7776c Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 25 Sep 2019 14:08:39 -0700 Subject: [PATCH 04/15] allow zero or greater for metrics dcheck --- lib/ui/window/viewport_metrics.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ui/window/viewport_metrics.cc b/lib/ui/window/viewport_metrics.cc index dd5fd27f11fe3..b524f392cdf07 100644 --- a/lib/ui/window/viewport_metrics.cc +++ b/lib/ui/window/viewport_metrics.cc @@ -40,9 +40,9 @@ ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, 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); + FML_DCHECK(physical_width >= 0); + FML_DCHECK(physical_height >= 0); + FML_DCHECK(device_pixel_ratio > 0); } ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio, From 60634bf0a140e6a3951f8004617b541367938497 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 07:50:28 -0700 Subject: [PATCH 05/15] switch to new macros --- common/BUILD.gn | 1 + common/config.gni | 2 +- common/runtime.h | 13 +++++++++++++ flow/raster_cache.cc | 6 +++--- lib/ui/window/viewport_metrics.cc | 11 +---------- runtime/dart_vm.cc | 10 ++++------ shell/common/switches.cc | 7 ++++--- shell/platform/android/flutter_main.cc | 9 ++++----- shell/platform/embedder/embedder.cc | 6 ++---- 9 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 common/runtime.h 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 9964dc63160eb..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 diff --git a/common/runtime.h b/common/runtime.h new file mode 100644 index 0000000000000..b02c94eafa47f --- /dev/null +++ b/common/runtime.h @@ -0,0 +1,13 @@ +// 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 == RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE + +#define FLUTTER_RELEASE FLUTTER_RUNTIME_MODE == RUNTIME_MODE_RELEASE || FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE + + +} + diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index e52095d4a91a6..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,8 +266,7 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) { } void RasterCache::TraceStatsToTimeline() const { -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && \ - FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if !FLUTTER_RELEASE size_t layer_cache_count = 0; size_t layer_cache_bytes = 0; @@ -293,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/ui/window/viewport_metrics.cc b/lib/ui/window/viewport_metrics.cc index b524f392cdf07..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_vm.cc b/runtime/dart_vm.cc index 5839a7230d335..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,8 +40,7 @@ namespace dart { namespace observatory { -#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE && \ - FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_JIT_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. @@ -49,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 @@ -149,8 +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 || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE) +#if FLUTTER_RELEASE return nullptr; #elif OS_FUCHSIA fml::UniqueFD fd = fml::OpenFile("pkg/data/observatory.tar", false, 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/flutter_main.cc b/shell/platform/android/flutter_main.cc index 5b498868f8fa8..b8f5e0e751e7b 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -8,6 +8,7 @@ #include +#include "flutter/common/runtime.h" #include "flutter/fml/command_line.h" #include "flutter/fml/file.h" #include "flutter/fml/macros.h" @@ -26,8 +27,7 @@ namespace flutter { extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_JIT_RUNTIME // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; @@ -103,8 +103,7 @@ void FlutterMain::Init(JNIEnv* env, fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); }; -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_JIT_RUNTIME // There are no ownership concerns here as all mappings are owned by the // embedder and not the engine. auto make_mapping_callback = [](const uint8_t* mapping, size_t size) { @@ -115,7 +114,7 @@ void FlutterMain::Init(JNIEnv* env, settings.dart_library_sources_kernel = make_mapping_callback(kPlatformStrongDill, kPlatformStrongDillSize); -#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +#endif // FLUTTER_JIT_RUNTIME // Not thread safe. Will be removed when FlutterMain is refactored to no // longer be a singleton. diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 036258102e638..1219d7a9dd808 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -15,13 +15,11 @@ #endif // OS_WIN extern "C" { -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#if FLUTTER_JIT_RUNTIME // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; -#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || - // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#endif // FLUTTER_JIT_RUNTIME } #include "flutter/assets/directory_asset_bundle.h" From 0f41e8a8466cb4c3023edb1697176a7498552544 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 07:53:53 -0700 Subject: [PATCH 06/15] fix dart_snapshot --- common/runtime.h | 12 +++++++----- runtime/dart_snapshot.cc | 7 +++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/runtime.h b/common/runtime.h index b02c94eafa47f..5d6f533c70a13 100644 --- a/common/runtime.h +++ b/common/runtime.h @@ -4,10 +4,12 @@ namespace flutter { -#define FLUTTER_JIT_RUNTIME FLUTTER_RUNTIME_MODE == RUNTIME_MODE_DEBUG || FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE +#define FLUTTER_JIT_RUNTIME \ + FLUTTER_RUNTIME_MODE == RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE -#define FLUTTER_RELEASE FLUTTER_RUNTIME_MODE == RUNTIME_MODE_RELEASE || FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE - - -} +#define FLUTTER_RELEASE \ + FLUTTER_RUNTIME_MODE == RUNTIME_MODE_RELEASE || \ + FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE +} // namespace flutter diff --git a/runtime/dart_snapshot.cc b/runtime/dart_snapshot.cc index cf74a51c2c5b6..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" @@ -23,10 +24,8 @@ const char* DartSnapshot::kIsolateInstructionsSymbol = // On Windows and Android (in debug mode) the engine finds the Dart snapshot // 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 || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE))) +#define DART_SNAPSHOT_STATIC_LINK \ + (OS_WIN || (OS_ANDROID && FLUTTER_JIT_RUNTIME)) #if !DART_SNAPSHOT_STATIC_LINK From 079445b257a0a12b4cb606481209a42a284091c1 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 08:40:58 -0700 Subject: [PATCH 07/15] dont load sdk sources --- lib/snapshot/BUILD.gn | 6 ++++-- shell/common/shell.cc | 3 ++- shell/common/shell_unittests.cc | 7 ++++--- shell/platform/android/flutter_main.cc | 5 ++--- shell/platform/embedder/embedder.cc | 2 +- shell/platform/fuchsia/runtime/dart/utils/BUILD.gn | 4 ++-- testing/testing.gni | 3 ++- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 4c255ddae65b8..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 != "jit_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" || flutter_runtime_mode == "jit_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/shell/common/shell.cc b/shell/common/shell.cc index 38ee3f50dcfe1..9a1bb78821be4 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -9,6 +9,7 @@ #include #include +#include "flutter/common/runtime.h" #include "flutter/assets/directory_asset_bundle.h" #include "flutter/fml/file.h" #include "flutter/fml/icu_util.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..4062513c8a136 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" @@ -433,7 +434,7 @@ TEST(SettingsTest, FrameTimingSetsAndGetsProperly) { } } -#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE +#if FLUTTER_RELEASE TEST_F(ShellTest, ReportTimingsIsCalledLaterInReleaseMode) { #else TEST_F(ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) { @@ -472,8 +473,8 @@ 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/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index b8f5e0e751e7b..fe94eee470157 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -8,7 +8,6 @@ #include -#include "flutter/common/runtime.h" #include "flutter/fml/command_line.h" #include "flutter/fml/file.h" #include "flutter/fml/macros.h" @@ -27,7 +26,7 @@ namespace flutter { extern "C" { -#if FLUTTER_JIT_RUNTIME +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; @@ -103,7 +102,7 @@ void FlutterMain::Init(JNIEnv* env, fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); }; -#if FLUTTER_JIT_RUNTIME +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // There are no ownership concerns here as all mappings are owned by the // embedder and not the engine. auto make_mapping_callback = [](const uint8_t* mapping, size_t size) { diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 1219d7a9dd808..929da9d7021bf 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -15,7 +15,7 @@ #endif // OS_WIN extern "C" { -#if FLUTTER_JIT_RUNTIME +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; 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 2826b21bf4a27..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" || flutter_runtime_mode == "jit_release") { + if (flutter_runtime_mode == "release" || + flutter_runtime_mode == "jit_release") { args += [ "-Ddart.vm.product=true" ] } From 0c24eee8bce0282d805907a799010ee37de6527a Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 08:41:28 -0700 Subject: [PATCH 08/15] update test file --- shell/common/shell.cc | 2 +- shell/common/shell_unittests.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 9a1bb78821be4..c22478680b945 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -9,8 +9,8 @@ #include #include -#include "flutter/common/runtime.h" #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" diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 4062513c8a136..5869cb48110d3 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -473,7 +473,7 @@ TEST_F(ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) { fml::TimePoint finish = fml::TimePoint::Now(); fml::TimeDelta ellapsed = finish - start; - + #if FLUTTER_RELEASE // Our batch time is 1000ms. Hopefully the 800ms limit is relaxed enough to // make it not too flaky. From ba8dfe7ed8fd4ecd301024be0679e669aa3a0e60 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 08:44:40 -0700 Subject: [PATCH 09/15] fix comments and remove dynamic from gn --- shell/platform/android/flutter_main.cc | 2 +- shell/platform/embedder/embedder.cc | 2 +- tools/gn | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index fe94eee470157..1ddcbf6ae9509 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -113,7 +113,7 @@ void FlutterMain::Init(JNIEnv* env, settings.dart_library_sources_kernel = make_mapping_callback(kPlatformStrongDill, kPlatformStrongDillSize); -#endif // FLUTTER_JIT_RUNTIME +#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // Not thread safe. Will be removed when FlutterMain is refactored to no // longer be a singleton. diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 929da9d7021bf..72da210079e73 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -19,7 +19,7 @@ extern "C" { // Used for debugging dart:* sources. extern const uint8_t kPlatformStrongDill[]; extern const intptr_t kPlatformStrongDillSize; -#endif // FLUTTER_JIT_RUNTIME +#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG } #include "flutter/assets/directory_asset_bundle.h" diff --git a/tools/gn b/tools/gn index 4d6a6501f6c31..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,6 @@ 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: @@ -274,7 +266,6 @@ def parse_args(args): parser.add_argument('--unoptimized', default=False, action='store_true') parser.add_argument('--runtime-mode', type=str, choices=['debug', 'profile', 'release', 'jit_release'], default='debug') - parser.add_argument('--dynamic', default=False, action='store_true') 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') From fd4300a22f6d5eab4aa4f5a479c6367d8aa7c8b3 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 26 Sep 2019 09:02:31 -0700 Subject: [PATCH 10/15] update license and more shell unittests --- ci/licenses_golden/licenses_flutter | 1 + shell/common/shell_unittests.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 5869cb48110d3..77b2b5a520141 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -224,7 +224,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"; @@ -242,7 +242,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"); From 2cc0f1dac4475a975af5544171e18c3d26a96b81 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 27 Sep 2019 08:17:04 -0700 Subject: [PATCH 11/15] Fix macro definitions --- common/runtime.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/runtime.h b/common/runtime.h index 5d6f533c70a13..f7c4ed820539f 100644 --- a/common/runtime.h +++ b/common/runtime.h @@ -5,11 +5,11 @@ namespace flutter { #define FLUTTER_JIT_RUNTIME \ - FLUTTER_RUNTIME_MODE == RUNTIME_MODE_DEBUG || \ - FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE #define FLUTTER_RELEASE \ - FLUTTER_RUNTIME_MODE == RUNTIME_MODE_RELEASE || \ - FLUTTER_RUNTIME_MODE == RUNTIME_MODE_JIT_RELEASE + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE || \ + FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE } // namespace flutter From 97017e5c2ed9d00dc1ed7ff198a4ddc46d1e5fc5 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 27 Sep 2019 08:32:52 -0700 Subject: [PATCH 12/15] format file --- common/runtime.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/runtime.h b/common/runtime.h index f7c4ed820539f..d86aecf1d49c0 100644 --- a/common/runtime.h +++ b/common/runtime.h @@ -4,11 +4,11 @@ namespace flutter { -#define FLUTTER_JIT_RUNTIME \ +#define FLUTTER_JIT_RUNTIME \ FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE -#define FLUTTER_RELEASE \ +#define FLUTTER_RELEASE \ FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE || \ FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE From 58e4001224139e0da1ed3c36e81103336a7fdc04 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 27 Sep 2019 08:51:45 -0700 Subject: [PATCH 13/15] preprocessors love parens --- common/runtime.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/runtime.h b/common/runtime.h index d86aecf1d49c0..5e444d2647443 100644 --- a/common/runtime.h +++ b/common/runtime.h @@ -4,12 +4,8 @@ namespace flutter { -#define FLUTTER_JIT_RUNTIME \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \ - FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE +#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 +#define FLUTTER_RELEASE ((FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE) || (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE)) } // namespace flutter From fbae38bf26e6882e7068bde8068d918d67346be4 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 27 Sep 2019 09:04:50 -0700 Subject: [PATCH 14/15] skip flag test in release mode --- shell/common/shell_unittests.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 77b2b5a520141..6968cf72994a4 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -208,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")}; From 81a1a98d1966c974ca64a55ce34fcb55841275a1 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 27 Sep 2019 09:06:17 -0700 Subject: [PATCH 15/15] format --- common/runtime.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/runtime.h b/common/runtime.h index 5e444d2647443..096ffbd86f83a 100644 --- a/common/runtime.h +++ b/common/runtime.h @@ -4,8 +4,12 @@ namespace flutter { -#define FLUTTER_JIT_RUNTIME ((FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE)) +#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)) +#define FLUTTER_RELEASE \ + ((FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE) || \ + (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_JIT_RELEASE)) } // namespace flutter