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

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: Add all resolved types in the program to the class hierarchy 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(_classEnsurer.ensureClassesInType);
962 closurizedMembers.forEach((function) {
963 _classEnsurer
964 .ensureClassesInType(_elementEnvironment.getFunctionType(function));
965 });
966
947 _classHierarchyNodes.keys.toList().forEach(_ensureClassSet); 967 _classHierarchyNodes.keys.toList().forEach(_ensureClassSet);
948 968
949 return typesImplementedBySubclasses; 969 return typesImplementedBySubclasses;
950 } 970 }
951 971
952 Iterable<MemberEntity> computeAssignedInstanceMembers() { 972 Iterable<MemberEntity> computeAssignedInstanceMembers() {
953 Set<MemberEntity> assignedInstanceMembers = new Set<MemberEntity>(); 973 Set<MemberEntity> assignedInstanceMembers = new Set<MemberEntity>();
954 for (MemberEntity instanceMember in _liveInstanceMembers) { 974 for (MemberEntity instanceMember in _liveInstanceMembers) {
955 if (hasInvokedSetter(instanceMember)) { 975 if (hasInvokedSetter(instanceMember)) {
956 assignedInstanceMembers.add(instanceMember); 976 assignedInstanceMembers.add(instanceMember);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 typesImplementedBySubclasses: typesImplementedBySubclasses, 1043 typesImplementedBySubclasses: typesImplementedBySubclasses,
1024 classHierarchyNodes: _classHierarchyNodes, 1044 classHierarchyNodes: _classHierarchyNodes,
1025 classSets: _classSets); 1045 classSets: _classSets);
1026 } 1046 }
1027 1047
1028 @override 1048 @override
1029 void registerClass(ClassEntity cls) { 1049 void registerClass(ClassEntity cls) {
1030 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); 1050 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass');
1031 } 1051 }
1032 } 1052 }
1053
1054 // TODO(het): Make this have a type of BaseResolutionDartTypeVisitor<void, Null>
1055 class _ClassEnsurer extends BaseResolutionDartTypeVisitor<dynamic, Null> {
Siggi Cherem (dart-lang) 2017/09/05 18:20:33 consider adding a second TODO: to explain why you
Harry Terkelsen 2017/09/05 18:31:11 Done.
1056 final ResolutionWorldBuilderBase worldBuilder;
1057
1058 _ClassEnsurer(this.worldBuilder);
1059
1060 void ensureClassesInType(DartType type) {
1061 type.accept(this, null);
1062 }
1063
1064 @override
1065 visitType(DartType type, _) {}
1066
1067 @override
1068 visitFunctionType(FunctionType type, _) {
1069 type.returnType.accept(this, null);
1070 type.parameterTypes.forEach((t) {
1071 t.accept(this, null);
1072 });
1073 type.optionalParameterTypes.forEach((t) {
1074 t.accept(this, null);
1075 });
1076 type.namedParameterTypes.forEach((t) {
1077 t.accept(this, null);
1078 });
1079 }
1080 //
1081 // @override
1082 // visitGenericType(GenericType type, _) {
Siggi Cherem (dart-lang) 2017/09/05 18:20:33 delete?
Harry Terkelsen 2017/09/05 18:31:11 Done.
1083 // type.typeArguments.forEach((t) {
1084 // t.accept(this, null);
1085 // });
1086 // }
1087
1088 @override
1089 visitInterfaceType(InterfaceType type, _) {
1090 worldBuilder._ensureClassSet(type.element);
1091 type.typeArguments.forEach((t) {
1092 t.accept(this, null);
1093 });
1094 }
1095
1096 @override
1097 visitTypedefType(TypedefType type, _) {
1098 type.typeArguments.forEach((t) {
1099 t.accept(this, null);
1100 });
1101 var functionType =
1102 worldBuilder._elementEnvironment.getFunctionTypeOfTypedef(type.element);
1103 functionType.accept(this, null);
1104 }
1105 }
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