Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ config("flutter_config") {

source_set("common") {
sources = [
"runtime.h",
"settings.cc",
"settings.h",
"task_runners.cc",
Expand Down
5 changes: 4 additions & 1 deletion common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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") {
Expand All @@ -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" ]
}
Expand Down
15 changes: 15 additions & 0 deletions common/runtime.h
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions flow/raster_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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
6 changes: 4 additions & 2 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}

Expand Down Expand Up @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions lib/ui/window/viewport_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion runtime/dart_snapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions runtime/dart_vm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")};
Expand All @@ -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";
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 4 additions & 3 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/android/io/flutter/view/FlutterMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/fuchsia/runtime/dart/utils/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
3 changes: 2 additions & 1 deletion testing/testing.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}

Expand Down
12 changes: 7 additions & 5 deletions tools/gen_android_buildconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}}
"""

Expand All @@ -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())
13 changes: 3 additions & 10 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jit_release so both variants can in the out directory and engineers tinker on builds locally without one clobbering another.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dart_runtime_mode is used by the Dart SDK. Otherwise, the output directory I have locally is host_jit_release(_unopt) and android_jit_release(_unopt) so this should be okay?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I misread this line to mean it was the out directory. Thanks for the clarification.

else:
gn_args['dart_runtime_mode'] = runtime_mode

Expand Down Expand Up @@ -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')
Expand Down