Skip to content

Commit 8ac7f6b

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
Revert "[vm/aot/tfa] Tree shake write-only fields"
This reverts commit ff34fd8. Reason: crash on the internal app Issue: flutter/flutter#50745 Change-Id: Ifcfbb38fa04d27558f9e78ca6b2a8637693c7d76 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135794 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 989180a commit 8ac7f6b

25 files changed

+46
-574
lines changed

pkg/vm/lib/transformations/type_flow/analysis.dart

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,12 @@ class _DirectInvocation extends _Invocation {
191191
case CallKind.PropertyGet:
192192
assertx(args.values.length == firstParamIndex);
193193
assertx(args.names.isEmpty);
194-
fieldValue.isGetterUsed = true;
195194
return fieldValue.getValue(
196195
typeFlowAnalysis, field.isStatic ? null : args.values[0]);
197196

198197
case CallKind.PropertySet:
199-
case CallKind.SetFieldInConstructor:
200198
assertx(args.values.length == firstParamIndex + 1);
201199
assertx(args.names.isEmpty);
202-
if (selector.callKind == CallKind.PropertySet) {
203-
fieldValue.isSetterUsed = true;
204-
}
205200
final Type setterArg = args.values[firstParamIndex];
206201
fieldValue.setValue(
207202
setterArg, typeFlowAnalysis, field.isStatic ? null : args.receiver);
@@ -211,7 +206,6 @@ class _DirectInvocation extends _Invocation {
211206
// Call via field.
212207
// TODO(alexmarkov): support function types and use inferred type
213208
// to get more precise return type.
214-
fieldValue.isGetterUsed = true;
215209
final receiver = fieldValue.getValue(
216210
typeFlowAnalysis, field.isStatic ? null : args.values[0]);
217211
if (receiver != const EmptyType()) {
@@ -778,12 +772,6 @@ class _FieldValue extends _DependencyTracker {
778772
/// Flag indicating if field initializer was executed.
779773
bool isInitialized = false;
780774

781-
/// Flag indicating if field getter was executed.
782-
bool isGetterUsed = false;
783-
784-
/// Flag indicating if field setter was executed.
785-
bool isSetterUsed = false;
786-
787775
_FieldValue(this.field, this.typeGuardSummary, TypesBuilder typesBuilder)
788776
: staticType = typesBuilder.fromStaticType(field.type, true) {
789777
if (field.initializer == null && _isDefaultValueOfFieldObservable()) {
@@ -1403,26 +1391,6 @@ class TypeFlowAnalysis implements EntryPointsListener, CallHandler {
14031391
return false;
14041392
}
14051393

1406-
/// Returns true if analysis found that getter corresponding to the given
1407-
/// [field] could be executed.
1408-
bool isFieldGetterUsed(Field field) {
1409-
final fieldValue = _fieldValues[field];
1410-
if (fieldValue != null) {
1411-
return fieldValue.isGetterUsed;
1412-
}
1413-
return false;
1414-
}
1415-
1416-
/// Returns true if analysis found that setter corresponding to the given
1417-
/// [field] could be executed.
1418-
bool isFieldSetterUsed(Field field) {
1419-
final fieldValue = _fieldValues[field];
1420-
if (fieldValue != null) {
1421-
return fieldValue.isSetterUsed;
1422-
}
1423-
return false;
1424-
}
1425-
14261394
bool isClassAllocated(Class c) => hierarchyCache.allocatedClasses.contains(c);
14271395

14281396
Call callSite(TreeNode node) => summaryCollector.callSites[node];

pkg/vm/lib/transformations/type_flow/calls.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ enum CallKind {
1616
Method, // x.foo(..) or foo()
1717
PropertyGet, // ... x.foo ...
1818
PropertySet, // x.foo = ...
19-
FieldInitializer, // run initializer of a field
20-
SetFieldInConstructor, // foo = ... in initializer list in a constructor
19+
FieldInitializer,
2120
}
2221

2322
/// [Selector] encapsulates the way of calling (at the call site).
@@ -56,7 +55,6 @@ abstract class Selector {
5655
return member.getterType;
5756
case CallKind.PropertySet:
5857
case CallKind.FieldInitializer:
59-
case CallKind.SetFieldInConstructor:
6058
return const BottomType();
6159
}
6260
return null;
@@ -74,8 +72,7 @@ abstract class Selector {
7472
case CallKind.PropertySet:
7573
return (member is Field) || ((member is Procedure) && member.isSetter);
7674
case CallKind.FieldInitializer:
77-
case CallKind.SetFieldInConstructor:
78-
return member is Field;
75+
return (member is Field);
7976
}
8077
return false;
8178
}
@@ -87,7 +84,6 @@ abstract class Selector {
8784
case CallKind.PropertyGet:
8885
return 'get ';
8986
case CallKind.PropertySet:
90-
case CallKind.SetFieldInConstructor:
9187
return 'set ';
9288
case CallKind.FieldInitializer:
9389
return 'init ';

pkg/vm/lib/transformations/type_flow/summary_collector.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ class SummaryCollector extends RecursiveVisitor<TypeExpr> {
800800
break;
801801

802802
case CallKind.PropertySet:
803-
case CallKind.SetFieldInConstructor:
804803
args.add(new Type.nullableAny());
805804
break;
806805

@@ -2072,11 +2071,8 @@ class SummaryCollector extends RecursiveVisitor<TypeExpr> {
20722071
TypeExpr visitFieldInitializer(FieldInitializer node) {
20732072
final value = _visit(node.value);
20742073
final args = new Args<TypeExpr>([_receiver, value]);
2075-
_makeCall(
2076-
node,
2077-
new DirectSelector(node.field,
2078-
callKind: CallKind.SetFieldInConstructor),
2079-
args);
2074+
_makeCall(node,
2075+
new DirectSelector(node.field, callKind: CallKind.PropertySet), args);
20802076
return null;
20812077
}
20822078

0 commit comments

Comments
 (0)