Skip to content

Commit cf1681e

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] Remove more unused old rti helpers
Change-Id: Icbc50554f2b3ae2cb74b32c9876c7c0cdf15c75b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150640 Reviewed-by: Joshua Litt <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent 920ddae commit cf1681e

37 files changed

+662
-1310
lines changed

pkg/compiler/lib/src/common_elements.dart

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ abstract class CommonElements {
424424

425425
FunctionEntity get throwAbstractClassInstantiationError;
426426

427+
/// Recognizes the `checkConcurrentModificationError` helper without needing
428+
/// it to be resolved.
429+
bool isCheckConcurrentModificationError(MemberEntity member);
430+
427431
FunctionEntity get checkConcurrentModificationError;
428432

429433
FunctionEntity get throwConcurrentModificationError;
@@ -442,16 +446,10 @@ abstract class CommonElements {
442446

443447
FunctionEntity get getRuntimeTypeInfo;
444448

445-
FunctionEntity get getTypeArgumentByIndex;
446-
447449
FunctionEntity get computeSignature;
448450

449451
FunctionEntity get getRuntimeTypeArguments;
450452

451-
FunctionEntity get getRuntimeTypeArgument;
452-
453-
FunctionEntity get getRuntimeTypeArgumentIntercepted;
454-
455453
FunctionEntity get checkDeferredIsLoaded;
456454

457455
FunctionEntity get throwNoSuchMethod;
@@ -476,8 +474,6 @@ abstract class CommonElements {
476474

477475
FunctionEntity get instantiatedGenericFunctionType;
478476

479-
FunctionEntity get extractFunctionTypeObjectFromInternal;
480-
481477
// From dart:_rti
482478

483479
FunctionEntity get findType;
@@ -1732,12 +1728,20 @@ class CommonElementsImpl
17321728
_findHelperFunction('throwUnsupportedError');
17331729

17341730
@override
1735-
FunctionEntity get throwTypeError => _findHelperFunction('throwTypeError');
1731+
FunctionEntity get throwTypeError => _findRtiFunction('throwTypeError');
17361732

17371733
@override
17381734
FunctionEntity get throwAbstractClassInstantiationError =>
17391735
_findHelperFunction('throwAbstractClassInstantiationError');
17401736

1737+
@override
1738+
bool isCheckConcurrentModificationError(MemberEntity member) {
1739+
return member.name == 'checkConcurrentModificationError' &&
1740+
member.isFunction &&
1741+
member.isTopLevel &&
1742+
member.library == jsHelperLibrary;
1743+
}
1744+
17411745
FunctionEntity _cachedCheckConcurrentModificationError;
17421746
@override
17431747
FunctionEntity get checkConcurrentModificationError =>
@@ -1799,10 +1803,6 @@ class CommonElementsImpl
17991803
FunctionEntity get getRuntimeTypeInfo =>
18001804
_findHelperFunction('getRuntimeTypeInfo');
18011805

1802-
@override
1803-
FunctionEntity get getTypeArgumentByIndex =>
1804-
_findHelperFunction('getTypeArgumentByIndex');
1805-
18061806
@override
18071807
FunctionEntity get computeSignature =>
18081808
_findHelperFunction('computeSignature');
@@ -1811,14 +1811,6 @@ class CommonElementsImpl
18111811
FunctionEntity get getRuntimeTypeArguments =>
18121812
_findHelperFunction('getRuntimeTypeArguments');
18131813

1814-
@override
1815-
FunctionEntity get getRuntimeTypeArgument =>
1816-
_findHelperFunction('getRuntimeTypeArgument');
1817-
1818-
@override
1819-
FunctionEntity get getRuntimeTypeArgumentIntercepted =>
1820-
_findHelperFunction('getRuntimeTypeArgumentIntercepted');
1821-
18221814
@override
18231815
FunctionEntity get checkDeferredIsLoaded =>
18241816
_findHelperFunction('checkDeferredIsLoaded');
@@ -1889,10 +1881,6 @@ class CommonElementsImpl
18891881
FunctionEntity get instantiatedGenericFunctionType =>
18901882
_findHelperFunction('instantiatedGenericFunctionType');
18911883

1892-
@override
1893-
FunctionEntity get extractFunctionTypeObjectFromInternal =>
1894-
_findHelperFunction('extractFunctionTypeObjectFromInternal');
1895-
18961884
@override
18971885
bool isInstantiationClass(ClassEntity cls) {
18981886
return cls.library == _jsHelperLibrary &&

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@ class BackendImpacts {
9898
BackendImpact _getRuntimeTypeArgument;
9999

100100
BackendImpact get getRuntimeTypeArgument {
101-
return _getRuntimeTypeArgument ??= new BackendImpact(globalUses: [
102-
_commonElements.getRuntimeTypeArgumentIntercepted,
103-
_commonElements.getRuntimeTypeArgument,
104-
_commonElements.getTypeArgumentByIndex,
105-
], otherImpacts: [
101+
return _getRuntimeTypeArgument ??=
102+
new BackendImpact(globalUses: [], otherImpacts: [
106103
newRtiImpact,
107104
]);
108105
}
@@ -167,7 +164,6 @@ class BackendImpacts {
167164

168165
BackendImpact get typeVariableBoundCheck {
169166
return _typeVariableBoundCheck ??= new BackendImpact(staticUses: [
170-
_commonElements.throwTypeError,
171167
_commonElements.checkTypeBound,
172168
]);
173169
}
@@ -671,7 +667,6 @@ class BackendImpacts {
671667
globalUses: [
672668
_commonElements.jsArrayTypedConstructor,
673669
_commonElements.setRuntimeTypeInfo,
674-
_commonElements.getTypeArgumentByIndex
675670
]);
676671
}
677672

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class InstantiationStubGenerator {
104104
///
105105
/// ```
106106
/// $signature:: function() {
107-
/// return H.instantiatedGenericFunctionType(
108-
/// H.extractFunctionTypeObjectFromInternal(this._genericClosure),
107+
/// return H.instantiatedGenericFunctionTypeNewRti(
108+
/// H.closureFunctionType(this._genericClosure),
109109
/// this.$ti);
110110
/// }
111111
/// ```

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ class KernelSsaGraphBuilder extends ir.Visitor {
365365
return false;
366366
case 'USE_CONTENT_SECURITY_POLICY':
367367
return options.useContentSecurityPolicy;
368-
case 'USE_NEW_RTI':
369-
return true;
370368
case 'VARIANCE':
371369
return options.enableVariance;
372370
case 'NNBD':
@@ -3952,9 +3950,9 @@ class KernelSsaGraphBuilder extends ir.Visitor {
39523950
//
39533951
// r = extractTypeArguments<Map>(e, f)
39543952
// -->
3955-
// interceptor = getInterceptor(e);
3956-
// T1 = getRuntimeTypeArgumentIntercepted(interceptor, e, 'Map', 0);
3957-
// T2 = getRuntimeTypeArgumentIntercepted(interceptor, e, 'Map', 1);
3953+
// environment = HInstanceEnvironment(e);
3954+
// T1 = HTypeEval( environment, 'Map.K');
3955+
// T2 = HTypeEval( environment, 'Map.V');
39583956
// r = f<T1, T2>();
39593957
//
39603958
// TODO(sra): Should we add a check before the variable extraction? We could

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
20892089
_nativeData.registerAllowInterop();
20902090
}
20912091

2092-
if (element == _commonElements.checkConcurrentModificationError) {
2092+
if (_commonElements.isCheckConcurrentModificationError(element)) {
20932093
// Manually inline the [checkConcurrentModificationError] function. This
20942094
// function is only called from a for-loop update. Ideally we would just
20952095
// generate the conditionalcontrol flow in the builder but it adds basic

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
16061606
if (node.inputs.length == 2) {
16071607
return handleArrayTypeInfo(node);
16081608
}
1609-
} else if (element == commonElements.checkConcurrentModificationError) {
1609+
} else if (commonElements.isCheckConcurrentModificationError(element)) {
16101610
if (node.inputs.length == 2) {
16111611
HInstruction firstArgument = node.inputs[0];
16121612
if (firstArgument is HConstant) {
@@ -1679,7 +1679,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
16791679
if (user is HInterceptor) continue;
16801680
if (user is HInvokeStatic) {
16811681
MemberEntity element = user.element;
1682-
if (element == commonElements.checkConcurrentModificationError) {
1682+
if (commonElements.isCheckConcurrentModificationError(element)) {
16831683
// CME check escapes the array, but we don't care.
16841684
continue;
16851685
}
@@ -3729,8 +3729,8 @@ class MemorySet {
37293729
if (user is HIdentity && user.usedBy.length == 1) {
37303730
HInstruction user2 = user.usedBy.single;
37313731
if (user2 is HInvokeStatic &&
3732-
user2.element ==
3733-
closedWorld.commonElements.checkConcurrentModificationError) {
3732+
closedWorld.commonElements
3733+
.isCheckConcurrentModificationError(user2.element)) {
37343734
return null;
37353735
}
37363736
}
@@ -3791,9 +3791,8 @@ class MemorySet {
37913791
}
37923792
}
37933793
if (use is HInvokeStatic) {
3794-
if (use.element ==
3795-
closedWorld.commonElements.checkConcurrentModificationError)
3796-
return true;
3794+
if (closedWorld.commonElements
3795+
.isCheckConcurrentModificationError(use.element)) return true;
37973796
}
37983797

37993798
return false;

pkg/compiler/test/impact/data/classes.dart

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,7 @@ class ForwardingConstructorGenericSuperClass<T> {
269269
_isString(1),
270270
_isTop(1),
271271
findType(1),
272-
getRuntimeTypeArgument(3),
273-
getRuntimeTypeArgumentIntercepted(4),
274272
getRuntimeTypeInfo(1),
275-
getTypeArgumentByIndex(2),
276273
instanceType(1),
277274
setRuntimeTypeInfo(2)],
278275
type=[
@@ -322,10 +319,7 @@ class ForwardingConstructorGenericSuperClass<T> {
322319
_isString(1),
323320
_isTop(1),
324321
findType(1),
325-
getRuntimeTypeArgument(3),
326-
getRuntimeTypeArgumentIntercepted(4),
327322
getRuntimeTypeInfo(1),
328-
getTypeArgumentByIndex(2),
329323
instanceType(1),
330324
setRuntimeTypeInfo(2)],
331325
type=[
@@ -344,7 +338,12 @@ class ForwardingConstructorGenericSuperClass<T> {
344338
class ForwardingConstructorGenericClass<
345339
S> = ForwardingConstructorGenericSuperClass<S> with EmptyMixin;
346340

347-
/*member: testForwardingConstructorGeneric:static=[ForwardingConstructorGenericClass.(1),checkTypeBound(4),throwTypeError(1)],type=[inst:JSNull]*/
341+
/*member: testForwardingConstructorGeneric:
342+
static=[
343+
ForwardingConstructorGenericClass.(1),
344+
checkTypeBound(4)],
345+
type=[inst:JSNull]
346+
*/
348347
testForwardingConstructorGeneric() {
349348
new ForwardingConstructorGenericClass<int>(null);
350349
}
@@ -400,10 +399,7 @@ testEnum() => Enum.A;
400399
_isString(1),
401400
_isTop(1),
402401
findType(1),
403-
getRuntimeTypeArgument(3),
404-
getRuntimeTypeArgumentIntercepted(4),
405402
getRuntimeTypeInfo(1),
406-
getTypeArgumentByIndex(2),
407403
instanceType(1),
408404
setRuntimeTypeInfo(2)],
409405
type=[
@@ -454,10 +450,7 @@ testEnum() => Enum.A;
454450
_isString(1),
455451
_isTop(1),
456452
findType(1),
457-
getRuntimeTypeArgument(3),
458-
getRuntimeTypeArgumentIntercepted(4),
459453
getRuntimeTypeInfo(1),
460-
getTypeArgumentByIndex(2),
461454
instanceType(1),
462455
setRuntimeTypeInfo(2)],
463456
type=[
@@ -475,8 +468,8 @@ testEnum() => Enum.A;
475468
List<T> staticGenericMethod<T>(T arg) => [arg];
476469

477470
/*spec:nnbd-off.member: testStaticGenericMethod:
478-
static=[staticGenericMethod<bool>(1)],
479-
type=[inst:JSBool]
471+
static=[staticGenericMethod<bool>(1)],
472+
type=[inst:JSBool]
480473
*/
481474
/*spec:nnbd-sdk.member: testStaticGenericMethod:
482475
static=[staticGenericMethod<bool*>(1)],
@@ -486,13 +479,18 @@ testStaticGenericMethod() {
486479
staticGenericMethod<bool>(true);
487480
}
488481

489-
/*spec:nnbd-off.member: testInstanceGenericMethod:dynamic=[exact:GenericClass.genericMethod<bool>(1)],static=[GenericClass.generative(0),checkTypeBound(4),throwTypeError(1)],type=[inst:JSBool]*/
482+
/*spec:nnbd-off.member: testInstanceGenericMethod:
483+
dynamic=[exact:GenericClass.genericMethod<bool>(1)],
484+
static=[
485+
GenericClass.generative(0),
486+
checkTypeBound(4)],
487+
type=[inst:JSBool]
488+
*/
490489
/*spec:nnbd-sdk.member: testInstanceGenericMethod:
491490
dynamic=[exact:GenericClass.genericMethod<bool*>(1)],
492491
static=[
493492
GenericClass.generative(0),
494-
checkTypeBound(4),
495-
throwTypeError(1)],
493+
checkTypeBound(4)],
496494
type=[inst:JSBool]
497495
*/
498496
testInstanceGenericMethod() {
@@ -516,10 +514,14 @@ testMixinInstantiation() => new Sub();
516514
/*member: testNamedMixinInstantiation:static=[NamedMixin.(0)]*/
517515
testNamedMixinInstantiation() => new NamedMixin();
518516

519-
/*member: testGenericMixinInstantiation:static=[GenericSub.(0),checkTypeBound(4),throwTypeError(1)]*/
517+
/*member: testGenericMixinInstantiation:static=[
518+
GenericSub.(0),
519+
checkTypeBound(4)]*/
520520
testGenericMixinInstantiation() => new GenericSub<int, String>();
521521

522-
/*member: testGenericNamedMixinInstantiation:static=[GenericNamedMixin.(0),checkTypeBound(4),throwTypeError(1)]*/
522+
/*member: testGenericNamedMixinInstantiation:static=[
523+
GenericNamedMixin.(0),
524+
checkTypeBound(4)]*/
523525
testGenericNamedMixinInstantiation() => new GenericNamedMixin<int, String>();
524526

525527
class Class {
@@ -563,10 +565,7 @@ class GenericClass<X, Y> {
563565
_isString(1),
564566
_isTop(1),
565567
findType(1),
566-
getRuntimeTypeArgument(3),
567-
getRuntimeTypeArgumentIntercepted(4),
568568
getRuntimeTypeInfo(1),
569-
getTypeArgumentByIndex(2),
570569
instanceType(1),
571570
setRuntimeTypeInfo(2)],
572571
type=[
@@ -618,10 +617,7 @@ class GenericClass<X, Y> {
618617
_isString(1),
619618
_isTop(1),
620619
findType(1),
621-
getRuntimeTypeArgument(3),
622-
getRuntimeTypeArgumentIntercepted(4),
623620
getRuntimeTypeInfo(1),
624-
getTypeArgumentByIndex(2),
625621
instanceType(1),
626622
setRuntimeTypeInfo(2)],
627623
type=[

pkg/compiler/test/impact/data/constants/lib.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ const typeLiteralField = String;
7777
_isString(1),
7878
_isTop(1),
7979
findType(1),
80-
getRuntimeTypeArgument(3),
81-
getRuntimeTypeArgumentIntercepted(4),
8280
getRuntimeTypeInfo(1),
83-
getTypeArgumentByIndex(2),
8481
instanceType(1),
8582
setRuntimeTypeInfo(2)],
8683
type=[
@@ -130,10 +127,7 @@ const typeLiteralField = String;
130127
_isString(1),
131128
_isTop(1),
132129
findType(1),
133-
getRuntimeTypeArgument(3),
134-
getRuntimeTypeArgumentIntercepted(4),
135130
getRuntimeTypeInfo(1),
136-
getTypeArgumentByIndex(2),
137131
instanceType(1),
138132
setRuntimeTypeInfo(2)],
139133
type=[

0 commit comments

Comments
 (0)