Add support for JIT release mode (flutter/engine#12446)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -10,6 +10,7 @@ config("flutter_config") {
|
||||
|
||||
source_set("common") {
|
||||
sources = [
|
||||
"runtime.h",
|
||||
"settings.cc",
|
||||
"settings.h",
|
||||
"task_runners.cc",
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
15
engine/src/flutter/common/runtime.h
Normal file
15
engine/src/flutter/common/runtime.h
Normal file
@@ -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
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#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,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <future>
|
||||
#include <memory>
|
||||
|
||||
#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<fml::CommandLine::Option> 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<std::string>());
|
||||
|
||||
#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<std::string>());
|
||||
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));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#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),
|
||||
|
||||
@@ -186,7 +186,7 @@ public class FlutterMain {
|
||||
}
|
||||
|
||||
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 @@ public class FlutterMain {
|
||||
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();
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public final class BuildConfig {{
|
||||
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())
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user