Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: pkg/compiler/lib/src/universe/resolution_world_builder.dart

Issue 3011793002: Add types referenced in is-checks to the class hierarchy (Closed)
Patch Set: use a type visitor Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of world_builder; 5 part of world_builder;
6 6
7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { 7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld {
8 /// Set of all local functions in the program. Used by the mirror tracking 8 /// Set of all local functions in the program. Used by the mirror tracking
9 /// system to find all live closure instances. 9 /// system to find all live closure instances.
10 Iterable<Local> get localFunctions; 10 Iterable<Local> get localFunctions;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 /// Map containing instance methods of live classes that are not yet 313 /// Map containing instance methods of live classes that are not yet
314 /// closurized. 314 /// closurized.
315 final Map<String, Set<_MemberUsage>> _instanceFunctionsByName = 315 final Map<String, Set<_MemberUsage>> _instanceFunctionsByName =
316 <String, Set<_MemberUsage>>{}; 316 <String, Set<_MemberUsage>>{};
317 317
318 /// Fields set. 318 /// Fields set.
319 final Set<FieldEntity> fieldSetters = new Set<FieldEntity>(); 319 final Set<FieldEntity> fieldSetters = new Set<FieldEntity>();
320 final Set<DartType> isChecks = new Set<DartType>(); 320 final Set<DartType> isChecks = new Set<DartType>();
321 321
322 _ClassEnsurer _classEnsurer;
323
322 /// Set of all closures in the program. Used by the mirror tracking system 324 /// Set of all closures in the program. Used by the mirror tracking system
323 /// to find all live closure instances. 325 /// to find all live closure instances.
324 final Set<Local> localFunctions = new Set<Local>(); 326 final Set<Local> localFunctions = new Set<Local>();
325 327
326 /// Set of live local functions (closures) whose signatures reference type 328 /// Set of live local functions (closures) whose signatures reference type
327 /// variables. 329 /// variables.
328 /// 330 ///
329 /// A local function is considered live if the enclosing member function is 331 /// A local function is considered live if the enclosing member function is
330 /// live. 332 /// live.
331 final Set<Local> localFunctionsWithFreeTypeVariables = new Set<Local>(); 333 final Set<Local> localFunctionsWithFreeTypeVariables = new Set<Local>();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 this._elementEnvironment, 387 this._elementEnvironment,
386 this._dartTypes, 388 this._dartTypes,
387 this._commonElements, 389 this._commonElements,
388 this._constantSystem, 390 this._constantSystem,
389 this._nativeBasicData, 391 this._nativeBasicData,
390 this._nativeDataBuilder, 392 this._nativeDataBuilder,
391 this._interceptorDataBuilder, 393 this._interceptorDataBuilder,
392 this._backendUsageBuilder, 394 this._backendUsageBuilder,
393 this._rtiNeedBuilder, 395 this._rtiNeedBuilder,
394 this._nativeResolutionEnqueuer, 396 this._nativeResolutionEnqueuer,
395 this.selectorConstraintsStrategy); 397 this.selectorConstraintsStrategy) {
398 _classEnsurer = new _ClassEnsurer(this);
399 }
396 400
397 Iterable<ClassEntity> get processedClasses => _processedClasses.keys 401 Iterable<ClassEntity> get processedClasses => _processedClasses.keys
398 .where((cls) => _processedClasses[cls].isInstantiated); 402 .where((cls) => _processedClasses[cls].isInstantiated);
399 403
400 bool isMemberProcessed(MemberEntity member) => 404 bool isMemberProcessed(MemberEntity member) =>
401 _processedMembers.contains(member); 405 _processedMembers.contains(member);
402 void registerProcessedMember(MemberEntity member) { 406 void registerProcessedMember(MemberEntity member) {
403 _processedMembers.add(member); 407 _processedMembers.add(member);
404 } 408 }
405 409
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 superclass = getSuperClass(superclass); 941 superclass = getSuperClass(superclass);
938 } 942 }
939 } 943 }
940 944
941 // Use the [:seenClasses:] set to include non-instantiated 945 // Use the [:seenClasses:] set to include non-instantiated
942 // classes: if the superclass of these classes require RTI, then 946 // classes: if the superclass of these classes require RTI, then
943 // they also need RTI, so that a constructor passes the type 947 // they also need RTI, so that a constructor passes the type
944 // variables to the super constructor. 948 // variables to the super constructor.
945 forEachInstantiatedClass(addSubtypes); 949 forEachInstantiatedClass(addSubtypes);
946 950
951 instantiatedTypes.forEach((type) {
952 var callType = _dartTypes.getCallType(type);
953 if (callType != null) {
954 _classEnsurer.ensureClassesInType(callType);
955 }
956 });
957 localFunctions.forEach((function) {
958 _classEnsurer.ensureClassesInType(
959 _elementEnvironment.getLocalFunctionType(function));
960 });
961 isChecks.forEach((t) {
Siggi Cherem (dart-lang) 2017/09/01 19:05:12 nit: isChecks.forEach(_classEnsurer.ensureClassesI
Harry Terkelsen 2017/09/01 21:48:57 Done.
962 _classEnsurer.ensureClassesInType(t);
963 });
964 closurizedMembers.forEach((function) {
Siggi Cherem (dart-lang) 2017/09/01 19:05:12 I'm surprised we were missing so many here. This c
Johnni Winther 2017/09/01 19:59:56 Because ClassElement.ensureResolved registers the
Harry Terkelsen 2017/09/01 21:25:33 The old pipeline adds classes to the hierarchy as
965 _classEnsurer
966 .ensureClassesInType(_elementEnvironment.getFunctionType(function));
967 });
968
947 _classHierarchyNodes.keys.toList().forEach(_ensureClassSet); 969 _classHierarchyNodes.keys.toList().forEach(_ensureClassSet);
948 970
949 return typesImplementedBySubclasses; 971 return typesImplementedBySubclasses;
950 } 972 }
951 973
952 Iterable<MemberEntity> computeAssignedInstanceMembers() { 974 Iterable<MemberEntity> computeAssignedInstanceMembers() {
953 Set<MemberEntity> assignedInstanceMembers = new Set<MemberEntity>(); 975 Set<MemberEntity> assignedInstanceMembers = new Set<MemberEntity>();
954 for (MemberEntity instanceMember in _liveInstanceMembers) { 976 for (MemberEntity instanceMember in _liveInstanceMembers) {
955 if (hasInvokedSetter(instanceMember)) { 977 if (hasInvokedSetter(instanceMember)) {
956 assignedInstanceMembers.add(instanceMember); 978 assignedInstanceMembers.add(instanceMember);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 typesImplementedBySubclasses: typesImplementedBySubclasses, 1045 typesImplementedBySubclasses: typesImplementedBySubclasses,
1024 classHierarchyNodes: _classHierarchyNodes, 1046 classHierarchyNodes: _classHierarchyNodes,
1025 classSets: _classSets); 1047 classSets: _classSets);
1026 } 1048 }
1027 1049
1028 @override 1050 @override
1029 void registerClass(ClassEntity cls) { 1051 void registerClass(ClassEntity cls) {
1030 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); 1052 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass');
1031 } 1053 }
1032 } 1054 }
1055
1056 // TODO(het): Make this have a type of BaseDartTypeVisitor<void, Null>
1057 class _ClassEnsurer extends BaseDartTypeVisitor<dynamic, Null> {
1058 final ResolutionWorldBuilderBase worldBuilder;
1059
1060 _ClassEnsurer(this.worldBuilder);
1061
1062 void ensureClassesInType(DartType type) {
1063 type.accept(this, null);
1064 }
1065
1066 @override
1067 visitType(DartType type, _) {}
1068
1069 @override
1070 visitFunctionType(FunctionType type, _) {
1071 type.returnType.accept(this, null);
1072 type.parameterTypes.forEach((t) {
1073 t.accept(this, null);
1074 });
1075 type.optionalParameterTypes.forEach((t) {
1076 t.accept(this, null);
1077 });
1078 type.namedParameterTypes.forEach((t) {
1079 t.accept(this, null);
1080 });
1081 }
1082
1083 @override
1084 visitInterfaceType(InterfaceType type, _) {
1085 worldBuilder._ensureClassSet(type.element);
1086 type.typeArguments.forEach((t) {
1087 t.accept(this, null);
1088 });
1089 }
1090 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698