Skip to content

Commit 73d9a8d

Browse files
rakudramaCommit Queue
authored andcommitted
[dart2js] Cleanup
Rename DummyInterceptorConstantValue to DummyConstantValue. It was actually used as a dummy *receiver* argument and could be used against any unused parameter. Remove unused CompilerOptions argument in SSA as-checks and is-tests. Pass the checked input explicitly to facilitate testing on other inputs (e.g. to do partial redundancy elimination by pushing the operation into the arms of a phi.) Change-Id: I4b450bfcf5fc877de731bf83201e3c9248ffcb0c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433104 Reviewed-by: Mayank Patke <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent 0ac78fb commit 73d9a8d

File tree

14 files changed

+63
-78
lines changed

14 files changed

+63
-78
lines changed

pkg/compiler/lib/src/constants/values.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum ConstantValueKind {
2929
interceptor,
3030
javaScriptObject,
3131
jsName,
32-
dummyInterceptor,
32+
dummy,
3333
lateSentinel,
3434
unreachable,
3535
instantiation,
@@ -62,10 +62,7 @@ abstract class ConstantValueVisitor<R, A> {
6262
covariant JavaScriptObjectConstantValue constant,
6363
covariant A arg,
6464
);
65-
R visitDummyInterceptor(
66-
covariant DummyInterceptorConstantValue constant,
67-
covariant A arg,
68-
);
65+
R visitDummy(covariant DummyConstantValue constant, covariant A arg);
6966
R visitLateSentinel(
7067
covariant LateSentinelConstantValue constant,
7168
covariant A arg,
@@ -826,14 +823,14 @@ class JsNameConstantValue extends ConstantValue {
826823
}
827824
}
828825

829-
/// A constant used as the dummy receiver value for intercepted calls with
830-
/// a known non-interceptor target.
831-
// TODO(sra): Rename fo 'DummyReceiverConstantValue'.
832-
class DummyInterceptorConstantValue extends ConstantValue {
833-
factory DummyInterceptorConstantValue() =>
834-
const DummyInterceptorConstantValue._();
826+
/// A constant used as an argument or receiver when the target does not use the
827+
/// corresponding parameter. Used as the dummy receiver value for calls using
828+
/// the intercepted calling convention when the target is 'self-intercepting'
829+
/// and does not use the explicit receiver parameter.
830+
class DummyConstantValue extends ConstantValue {
831+
factory DummyConstantValue() => const DummyConstantValue._();
835832

836-
const DummyInterceptorConstantValue._();
833+
const DummyConstantValue._();
837834

838835
@override
839836
bool get isDummy => true;
@@ -843,20 +840,20 @@ class DummyInterceptorConstantValue extends ConstantValue {
843840

844841
@override
845842
R accept<R, A>(ConstantValueVisitor<R, A> visitor, A arg) {
846-
return visitor.visitDummyInterceptor(this, arg);
843+
return visitor.visitDummy(this, arg);
847844
}
848845

849846
@override
850847
DartType getType(CommonElements types) => types.dynamicType;
851848

852849
@override
853-
ConstantValueKind get kind => ConstantValueKind.dummyInterceptor;
850+
ConstantValueKind get kind => ConstantValueKind.dummy;
854851

855852
@override
856-
String toDartText(DartTypes? dartTypes) => 'dummy_interceptor()';
853+
String toDartText(DartTypes? dartTypes) => 'dummy()';
857854

858855
@override
859-
String toStructuredText(DartTypes? dartTypes) => 'DummyInterceptorConstant()';
856+
String toStructuredText(DartTypes? dartTypes) => 'DummyConstant()';
860857
}
861858

862859
/// A constant used to represent the sentinel for uninitialized late fields and

pkg/compiler/lib/src/inferrer/typemasks/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ConstantValueTypeMasks extends ConstantValueVisitor<TypeMask, Null> {
5555
}
5656

5757
@override
58-
TypeMask visitDummyInterceptor(DummyInterceptorConstantValue constant, _) =>
58+
TypeMask visitDummy(DummyConstantValue constant, _) =>
5959
_abstractValueDomain.dynamicType;
6060

6161
@override

pkg/compiler/lib/src/js_backend/constant_emitter.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ class ModularConstantEmitter
162162
}
163163

164164
@override
165-
js_ast.Expression visitDummyInterceptor(
166-
DummyInterceptorConstantValue constant, [
167-
_,
168-
]) {
165+
js_ast.Expression visitDummy(DummyConstantValue constant, [_]) {
169166
return js_ast.LiteralNumber('0');
170167
}
171168

pkg/compiler/lib/src/js_backend/impact_transformer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class CodegenImpactTransformer {
119119
break;
120120
case ConstantValueKind.bool:
121121
case ConstantValueKind.double:
122-
case ConstantValueKind.dummyInterceptor:
122+
case ConstantValueKind.dummy:
123123
case ConstantValueKind.function:
124124
case ConstantValueKind.int:
125125
case ConstantValueKind.interceptor:

pkg/compiler/lib/src/js_backend/namer.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,8 @@ class ConstantNamingVisitor implements ConstantValueVisitor<void, Null> {
14981498
}
14991499

15001500
@override
1501-
void visitDummyInterceptor(DummyInterceptorConstantValue constant, [_]) {
1502-
add('dummy_interceptor');
1501+
void visitDummy(DummyConstantValue constant, [_]) {
1502+
add('dummy');
15031503
}
15041504

15051505
@override
@@ -1669,10 +1669,10 @@ class ConstantCanonicalHasher implements ConstantValueVisitor<int, Null> {
16691669
}
16701670

16711671
@override
1672-
int visitDummyInterceptor(DummyInterceptorConstantValue constant, [_]) {
1672+
int visitDummy(DummyConstantValue constant, [_]) {
16731673
throw failedAt(
16741674
noLocationSpannable,
1675-
'DummyInterceptorConstantValue should never be named and '
1675+
'DummyConstantValue should never be named and '
16761676
'never be subconstant',
16771677
);
16781678
}

pkg/compiler/lib/src/js_emitter/constant_ordering.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,7 @@ class _ConstantOrdering
162162
}
163163

164164
@override
165-
int visitDummyInterceptor(
166-
DummyInterceptorConstantValue a,
167-
DummyInterceptorConstantValue b,
168-
) {
169-
// Never emitted.
165+
int visitDummy(DummyConstantValue a, DummyConstantValue b) {
170166
return 0;
171167
}
172168

pkg/compiler/lib/src/js_model/js_to_frontend_map.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ class _ConstantConverter implements ConstantValueVisitor<ConstantValue, Null> {
317317
@override
318318
StringConstantValue visitString(StringConstantValue constant, _) => constant;
319319
@override
320-
DummyInterceptorConstantValue visitDummyInterceptor(
321-
DummyInterceptorConstantValue constant,
322-
_,
323-
) => constant;
320+
DummyConstantValue visitDummy(DummyConstantValue constant, _) => constant;
324321
@override
325322
LateSentinelConstantValue visitLateSentinel(
326323
LateSentinelConstantValue constant,

pkg/compiler/lib/src/serialization/sink.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ class DataSinkWriter {
10211021
writeConstant(constant.referenced);
10221022
writeOutputUnitReference(constant.unit);
10231023
break;
1024-
case ConstantValueKind.dummyInterceptor:
1024+
case ConstantValueKind.dummy:
10251025
break;
10261026
case ConstantValueKind.lateSentinel:
10271027
break;

pkg/compiler/lib/src/serialization/source.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,8 +1335,8 @@ class DataSourceReader {
13351335
ConstantValue constant = readConstant();
13361336
OutputUnit unit = readOutputUnitReference();
13371337
return DeferredGlobalConstantValue(constant, unit);
1338-
case ConstantValueKind.dummyInterceptor:
1339-
return DummyInterceptorConstantValue();
1338+
case ConstantValueKind.dummy:
1339+
return DummyConstantValue();
13401340
case ConstantValueKind.lateSentinel:
13411341
return LateSentinelConstantValue();
13421342
case ConstantValueKind.unreachable:

pkg/compiler/lib/src/ssa/interceptor_finalizer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class SsaFinalizeInterceptors extends HBaseVisitor<void>
269269

270270
void _replaceReceiverArgumentWithDummy(HInvoke node, int receiverIndex) {
271271
assert(!node.isCallOnInterceptor, 'node: $node');
272-
ConstantValue constant = DummyInterceptorConstantValue();
272+
ConstantValue constant = DummyConstantValue();
273273
HConstant dummy = _graph.addConstant(constant, _closedWorld);
274274
node.replaceInput(receiverIndex, dummy);
275275
}

0 commit comments

Comments
 (0)