Unverified Commit 7c89ec8b authored by Martin Kustermann's avatar Martin Kustermann Committed by GitHub

Remove `toString()` overrides in `dart:ui`/`package:flutter` in...

Remove `toString()` overrides in `dart:ui`/`package:flutter` in profile/release mode on wasm/vm targets (#144763)

The flutter engine & framework can opt out of this optimization for
individual classes / class hierarchies via:

  * `@pragma(flutter:keep-to-string)`
  * `@pragma(flutter:keep-to-string-in-subtypes)`

Or by using the convenience constant `@keepToString` from `dart:ui`.

=> This aligns the build process more with g3 (which already does this)

Closes https://github.com/flutter/flutter/issues/52759
parent 70186852
......@@ -258,6 +258,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
decodeDartDefines(environment.defines, kDartDefines),
);
assert(buildMode == BuildMode.release || buildMode == BuildMode.profile);
final List<String> compilationArgs = <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript),
'compile',
......@@ -265,6 +266,8 @@ class Dart2WasmTarget extends Dart2WebTarget {
'--packages=.dart_tool/package_config.json',
'--extra-compiler-option=--dart-sdk=$dartSdkPath',
'--extra-compiler-option=--platform=$platformFilePath',
'--extra-compiler-option=--delete-tostring-package-uri=dart:ui',
'--extra-compiler-option=--delete-tostring-package-uri=package:flutter',
if (compilerConfig.renderer == WebRendererMode.skwasm) ...<String>[
'--extra-compiler-option=--import-shared-memory',
'--extra-compiler-option=--shared-memory-max-pages=32768',
......
......@@ -183,11 +183,15 @@ List<String> buildModeOptions(BuildMode mode, List<String> dartDefines) =>
'-Ddart.vm.profile=true',
if (!dartDefines.any((String define) => define.startsWith('dart.vm.product')))
'-Ddart.vm.product=false',
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
...kDartCompilerExperiments,
],
BuildMode.release => <String>[
'-Ddart.vm.profile=false',
'-Ddart.vm.product=true',
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
...kDartCompilerExperiments,
],
_ => throw Exception('Unknown BuildMode: $mode')
......
......@@ -36,6 +36,8 @@ const List<String> _kDart2WasmLinuxArgs = <String> [
'--packages=.dart_tool/package_config.json',
'--extra-compiler-option=--dart-sdk=Artifact.engineDartSdkPath.TargetPlatform.web_javascript',
'--extra-compiler-option=--platform=HostArtifact.webPlatformKernelFolder/dart2wasm_platform.dill',
'--extra-compiler-option=--delete-tostring-package-uri=dart:ui',
'--extra-compiler-option=--delete-tostring-package-uri=package:flutter',
];
void main() {
......
......@@ -200,6 +200,8 @@ void main() {
'--no-print-incremental-dependencies',
'-Ddart.vm.profile=true',
'-Ddart.vm.product=false',
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
'--no-link-platform',
'--aot',
'--tfa',
......@@ -248,6 +250,8 @@ void main() {
'--no-print-incremental-dependencies',
'-Ddart.vm.profile=false',
'-Ddart.vm.product=true',
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
'--no-link-platform',
'--aot',
'--tfa',
......
......@@ -105,11 +105,15 @@ void main() {
testWithoutContext('buildModeOptions removes matching profile define in profile mode', () {
expect(buildModeOptions(BuildMode.profile, <String>['dart.vm.profile=true']), <String>[
'-Ddart.vm.product=false',
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
]);
});
testWithoutContext('buildModeOptions removes both matching profile and release define in profile mode', () {
expect(buildModeOptions(BuildMode.profile, <String>['dart.vm.profile=false', 'dart.vm.product=true']), <String>[
'--delete-tostring-package-uri=dart:ui',
'--delete-tostring-package-uri=package:flutter',
]);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment