Skip to content

Commit 3478232

Browse files
Jonah Williamsfluttergithubbot
authored andcommitted
[flutter_tools] Apply --no-causal-async-stacks and --lazy-async-stacks to profile/release builds (#49377)
1 parent 4964fb6 commit 3478232

File tree

7 files changed

+36
-15
lines changed

7 files changed

+36
-15
lines changed

packages/flutter_tools/lib/src/base/build.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class GenSnapshot {
4949
Iterable<String> additionalArgs = const <String>[],
5050
}) {
5151
final List<String> args = <String>[
52-
'--causal_async_stacks',
5352
...additionalArgs,
5453
];
5554

@@ -156,6 +155,13 @@ class AOTSnapshotter {
156155
genSnapshotArgs.add('--no-use-integer-division');
157156
}
158157

158+
// Optimization arguments.
159+
genSnapshotArgs.addAll(<String>[
160+
// Faster async/await
161+
'--no-causal-async-stacks',
162+
'--lazy-async-stacks',
163+
]);
164+
159165
genSnapshotArgs.add(mainPath);
160166

161167
// TODO(jonahwilliams): fully remove input checks once all callers are

packages/flutter_tools/lib/src/codegen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
9595
bool linkPlatformKernelIn = false,
9696
bool aot = false,
9797
@required BuildMode buildMode,
98-
bool causalAsyncStacks = true,
9998
bool trackWidgetCreation,
10099
List<String> extraFrontEndOptions,
101100
// These arguments are currently unused.
@@ -133,7 +132,6 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
133132
linkPlatformKernelIn: linkPlatformKernelIn,
134133
aot: aot,
135134
buildMode: buildMode,
136-
causalAsyncStacks: causalAsyncStacks,
137135
trackWidgetCreation: trackWidgetCreation,
138136
extraFrontEndOptions: extraFrontEndOptions,
139137
sdkRoot: sdkRoot,

packages/flutter_tools/lib/src/compile.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ class KernelCompiler {
277277
@required BuildMode buildMode,
278278
bool linkPlatformKernelIn = false,
279279
bool aot = false,
280-
bool causalAsyncStacks = true,
281280
@required bool trackWidgetCreation,
282281
List<String> extraFrontEndOptions,
283282
String packagesPath,
@@ -313,7 +312,7 @@ class KernelCompiler {
313312
'--sdk-root',
314313
sdkRoot,
315314
'--target=$targetModel',
316-
'-Ddart.developer.causal_async_stacks=$causalAsyncStacks',
315+
'-Ddart.developer.causal_async_stacks=${buildMode == BuildMode.debug}',
317316
for (final Object dartDefine in dartDefines)
318317
'-D$dartDefine',
319318
..._buildModeOptions(buildMode),
@@ -451,7 +450,6 @@ class _RejectRequest extends _CompilationRequest {
451450
abstract class ResidentCompiler {
452451
factory ResidentCompiler(String sdkRoot, {
453452
@required BuildMode buildMode,
454-
bool causalAsyncStacks,
455453
bool trackWidgetCreation,
456454
String packagesPath,
457455
List<String> fileSystemRoots,
@@ -512,7 +510,6 @@ class DefaultResidentCompiler implements ResidentCompiler {
512510
DefaultResidentCompiler(
513511
String sdkRoot, {
514512
@required this.buildMode,
515-
this.causalAsyncStacks = true,
516513
this.trackWidgetCreation = true,
517514
this.packagesPath,
518515
this.fileSystemRoots,
@@ -531,7 +528,6 @@ class DefaultResidentCompiler implements ResidentCompiler {
531528
sdkRoot = sdkRoot.endsWith('/') ? sdkRoot : '$sdkRoot/';
532529

533530
final BuildMode buildMode;
534-
final bool causalAsyncStacks;
535531
final bool trackWidgetCreation;
536532
final String packagesPath;
537533
final TargetModel targetModel;
@@ -651,7 +647,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
651647
sdkRoot,
652648
'--incremental',
653649
'--target=$targetModel',
654-
'-Ddart.developer.causal_async_stacks=$causalAsyncStacks',
650+
'-Ddart.developer.causal_async_stacks=${buildMode == BuildMode.debug}',
655651
for (final Object dartDefine in dartDefines)
656652
'-D$dartDefine',
657653
if (outputPath != null) ...<String>[

packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ Future<void> _genSnapshot(
9898

9999
final List<String> command = <String>[
100100
genSnapshot,
101-
'--no_causal_async_stacks',
101+
'--no-causal-async-stacks',
102+
'--lazy-async-stacks',
102103
'--deterministic',
103104
'--snapshot_kind=app-aot-blobs',
104105
'--vm_snapshot_data=$vmSnapshotData',

packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class FuchsiaKernelCompiler {
7171

7272
if (buildInfo.isProfile) '-Ddart.vm.profile=true',
7373
if (buildInfo.mode.isRelease) '-Ddart.vm.release=true',
74+
'-Ddart.developer.causal_async_stacks=${buildInfo.isDebug}',
7475

7576
// Use bytecode and drop the ast in JIT release mode.
7677
if (buildInfo.isJitRelease) ...<String>[

packages/flutter_tools/test/general.shard/base/build_test.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ void main() {
121121
verify(mockProcessManager.start(
122122
<String>[
123123
'gen_snapshot',
124-
'--causal_async_stacks',
125124
'--additional_arg',
126125
],
127126
workingDirectory: anyNamed('workingDirectory'),
@@ -146,7 +145,6 @@ void main() {
146145
verify(mockProcessManager.start(
147146
<String>[
148147
'gen_snapshot_armv7',
149-
'--causal_async_stacks',
150148
'--additional_arg',
151149
],
152150
workingDirectory: anyNamed('workingDirectory'),
@@ -171,7 +169,6 @@ void main() {
171169
verify(mockProcessManager.start(
172170
<String>[
173171
'gen_snapshot_arm64',
174-
'--causal_async_stacks',
175172
'--additional_arg',
176173
],
177174
workingDirectory: anyNamed('workingDirectory'),
@@ -184,7 +181,7 @@ void main() {
184181
platform: TargetPlatform.android_x64, mode: BuildMode.release))
185182
.thenReturn('gen_snapshot');
186183
when(mockProcessManager.start(
187-
<String>['gen_snapshot', '--causal_async_stacks', '--strip'],
184+
<String>['gen_snapshot', '--strip'],
188185
workingDirectory: anyNamed('workingDirectory'),
189186
environment: anyNamed('environment')))
190187
.thenAnswer((_) => Future<Process>.value(mockProc));
@@ -202,7 +199,7 @@ void main() {
202199
darwinArch: null,
203200
additionalArgs: <String>['--strip']);
204201
verify(mockProcessManager.start(
205-
<String>['gen_snapshot', '--causal_async_stacks', '--strip'],
202+
<String>['gen_snapshot', '--strip'],
206203
workingDirectory: anyNamed('workingDirectory'),
207204
environment: anyNamed('environment')))
208205
.called(1);
@@ -331,6 +328,8 @@ void main() {
331328
'--assembly=$assembly',
332329
'--no-sim-use-hardfp',
333330
'--no-use-integer-division',
331+
'--no-causal-async-stacks',
332+
'--lazy-async-stacks',
334333
'main.dill',
335334
]);
336335

@@ -388,6 +387,8 @@ void main() {
388387
'--assembly=$assembly',
389388
'--no-sim-use-hardfp',
390389
'--no-use-integer-division',
390+
'--no-causal-async-stacks',
391+
'--lazy-async-stacks',
391392
'main.dill',
392393
]);
393394

@@ -448,6 +449,8 @@ void main() {
448449
'--assembly=$assembly',
449450
'--no-sim-use-hardfp',
450451
'--no-use-integer-division',
452+
'--no-causal-async-stacks',
453+
'--lazy-async-stacks',
451454
'main.dill',
452455
]);
453456
verifyNever(mockXcode.cc(argThat(contains('-fembed-bitcode'))));
@@ -493,6 +496,8 @@ void main() {
493496
'--deterministic',
494497
'--snapshot_kind=app-aot-assembly',
495498
'--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
499+
'--no-causal-async-stacks',
500+
'--lazy-async-stacks',
496501
'main.dill',
497502
]);
498503
}, overrides: contextOverrides);
@@ -531,6 +536,8 @@ void main() {
531536
'--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
532537
'--no-sim-use-hardfp',
533538
'--no-use-integer-division',
539+
'--no-causal-async-stacks',
540+
'--lazy-async-stacks',
534541
'main.dill',
535542
]);
536543
}, overrides: contextOverrides);
@@ -567,6 +574,8 @@ void main() {
567574
'--deterministic',
568575
'--snapshot_kind=app-aot-assembly',
569576
'--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
577+
'--no-causal-async-stacks',
578+
'--lazy-async-stacks',
570579
'main.dill',
571580
]);
572581
}, overrides: contextOverrides);
@@ -597,6 +606,8 @@ void main() {
597606
'--strip',
598607
'--no-sim-use-hardfp',
599608
'--no-use-integer-division',
609+
'--no-causal-async-stacks',
610+
'--lazy-async-stacks',
600611
'main.dill',
601612
]);
602613
}, overrides: contextOverrides);
@@ -625,6 +636,8 @@ void main() {
625636
'--snapshot_kind=app-aot-elf',
626637
'--elf=build/foo/app.so',
627638
'--strip',
639+
'--no-causal-async-stacks',
640+
'--lazy-async-stacks',
628641
'main.dill',
629642
]);
630643
}, overrides: contextOverrides);

packages/flutter_tools/test/general.shard/compile_batch_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ void main() {
6464
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
6565
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
6666
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
67+
final VerificationResult argVerification = verify(mockProcessManager.start(captureAny));
68+
expect(argVerification.captured.single, containsAll(<String>[
69+
'-Ddart.developer.causal_async_stacks=true',
70+
]));
6771
}, overrides: <Type, Generator>{
6872
ProcessManager: () => mockProcessManager,
6973
OutputPreferences: () => OutputPreferences(showColor: false),
@@ -94,6 +98,7 @@ void main() {
9498
'-Ddart.vm.profile=true',
9599
'-Ddart.vm.product=false',
96100
'--bytecode-options=source-positions',
101+
'-Ddart.developer.causal_async_stacks=false',
97102
]));
98103
}, overrides: <Type, Generator>{
99104
ProcessManager: () => mockProcessManager,
@@ -126,6 +131,7 @@ void main() {
126131
'-Ddart.vm.profile=false',
127132
'-Ddart.vm.product=true',
128133
'--bytecode-options=source-positions',
134+
'-Ddart.developer.causal_async_stacks=false',
129135
]));
130136
}, overrides: <Type, Generator>{
131137
ProcessManager: () => mockProcessManager,

0 commit comments

Comments
 (0)