Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit dcd5a8f

Browse files
askeksacommit-bot@chromium.org
authored andcommitted
[vm/aot] Two improvements to signature shaking (reland)
- Global parameter use analysis: when a parameter is only used directly as arguments to other calls, only consider it used if any of the target parameters are used. - A parameter can be eliminated if the TFA infers that it has a constant value in every implementation. This change also extends the test of the protobuf-aware tree shaker to run the AOT global transformations on all its test cases in order to check that the protobuf handling in that code path is not broken by signature shaking. Reduces ARM64 .so size of Flutter Gallery by 0.25% uncompressed, 0.37% with gzip and 0.45% with brotli. Issue: dart-lang/sdk#40488 TEST=Existing test suite, expectation files for TFA test, extended test of protobuf-aware tree shaker. Change-Id: Ib00fe362f798c92592a260f72e7bccad04246bb2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173727 Commit-Queue: Aske Simon Christensen <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
1 parent 5bff8f3 commit dcd5a8f

22 files changed

+522
-331
lines changed

pkg/vm/lib/transformations/protobuf_aware_treeshaker/transformer.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ void _treeshakeProtos(Target target, Component component, CoreTypes coreTypes,
5050
component.metadata.clear();
5151
}
5252

53+
/// Called by the signature shaker to exclude the positional parameters of
54+
/// certain members whose first few parameters are depended upon by the
55+
/// protobuf-aware tree shaker.
56+
bool excludePositionalParametersFromSignatureShaking(Member member) {
57+
return member.enclosingClass?.name == 'BuilderInfo' &&
58+
member.enclosingLibrary.importUri ==
59+
Uri.parse('package:protobuf/protobuf.dart') &&
60+
_UnusedFieldMetadataPruner.fieldAddingMethods.contains(member.name.name);
61+
}
62+
5363
InfoCollector removeUnusedProtoReferences(
5464
Component component, CoreTypes coreTypes, TransformationInfo info) {
5565
final protobufUri = Uri.parse('package:protobuf/protobuf.dart');

0 commit comments

Comments
 (0)