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

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

Issue 2721403006: Split NativeData (Closed)
Patch Set: Updated cf. comments. Created 3 years, 9 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 | « pkg/compiler/lib/src/types/types.dart ('k') | pkg/compiler/lib/src/world.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library universe; 5 library universe;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show Identifiers; 10 import '../common/names.dart' show Identifiers;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 void registerTypeInstantiation( 553 void registerTypeInstantiation(
554 ResolutionInterfaceType type, ClassUsedCallback classUsed, 554 ResolutionInterfaceType type, ClassUsedCallback classUsed,
555 {ConstructorElement constructor, 555 {ConstructorElement constructor,
556 bool byMirrors: false, 556 bool byMirrors: false,
557 bool isRedirection: false}) { 557 bool isRedirection: false}) {
558 ClassElement cls = type.element; 558 ClassElement cls = type.element;
559 cls.ensureResolved(_resolution); 559 cls.ensureResolved(_resolution);
560 InstantiationInfo info = 560 InstantiationInfo info =
561 _instantiationInfo.putIfAbsent(cls, () => new InstantiationInfo()); 561 _instantiationInfo.putIfAbsent(cls, () => new InstantiationInfo());
562 Instantiation kind = Instantiation.UNINSTANTIATED; 562 Instantiation kind = Instantiation.UNINSTANTIATED;
563 bool isNative = _backend.isNative(cls); 563 bool isNative = _backend.nativeData.isNativeClass(cls);
564 if (!cls.isAbstract || 564 if (!cls.isAbstract ||
565 // We can't use the closed-world assumption with native abstract 565 // We can't use the closed-world assumption with native abstract
566 // classes; a native abstract class may have non-abstract subclasses 566 // classes; a native abstract class may have non-abstract subclasses
567 // not declared to the program. Instances of these classes are 567 // not declared to the program. Instances of these classes are
568 // indistinguishable from the abstract class. 568 // indistinguishable from the abstract class.
569 isNative || 569 isNative ||
570 // Likewise, if this registration comes from the mirror system, 570 // Likewise, if this registration comes from the mirror system,
571 // all bets are off. 571 // all bets are off.
572 // TODO(herhut): Track classes required by mirrors seperately. 572 // TODO(herhut): Track classes required by mirrors seperately.
573 byMirrors) { 573 byMirrors) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 String memberName = member.name; 864 String memberName = member.name;
865 member.computeType(_resolution); 865 member.computeType(_resolution);
866 // The obvious thing to test here would be "member.isNative", 866 // The obvious thing to test here would be "member.isNative",
867 // however, that only works after metadata has been parsed/analyzed, 867 // however, that only works after metadata has been parsed/analyzed,
868 // and that may not have happened yet. 868 // and that may not have happened yet.
869 // So instead we use the enclosing class, which we know have had 869 // So instead we use the enclosing class, which we know have had
870 // its metadata parsed and analyzed. 870 // its metadata parsed and analyzed.
871 // Note: this assumes that there are no non-native fields on native 871 // Note: this assumes that there are no non-native fields on native
872 // classes, which may not be the case when a native class is subclassed. 872 // classes, which may not be the case when a native class is subclassed.
873 _instanceMemberUsage.putIfAbsent(member, () { 873 _instanceMemberUsage.putIfAbsent(member, () {
874 bool isNative = _backend.isNative(cls); 874 bool isNative = _backend.nativeData.isNativeClass(cls);
875 _MemberUsage usage = new _MemberUsage(member, isNative: isNative); 875 _MemberUsage usage = new _MemberUsage(member, isNative: isNative);
876 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); 876 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
877 useSet.addAll(usage.appliedUse); 877 useSet.addAll(usage.appliedUse);
878 if (member.isField && isNative) { 878 if (member.isField && isNative) {
879 registerUsedElement(member); 879 registerUsedElement(member);
880 } 880 }
881 if (member.isFunction && 881 if (member.isFunction &&
882 member.name == Identifiers.call && 882 member.name == Identifiers.call &&
883 !cls.typeVariables.isEmpty) { 883 !cls.typeVariables.isEmpty) {
884 callMethodsWithFreeTypeVariables.add(member); 884 callMethodsWithFreeTypeVariables.add(member);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 /// Register [type] as (directly) instantiated. 1253 /// Register [type] as (directly) instantiated.
1254 /// 1254 ///
1255 /// If [byMirrors] is `true`, the instantiation is through mirrors. 1255 /// If [byMirrors] is `true`, the instantiation is through mirrors.
1256 // TODO(johnniwinther): Fully enforce the separation between exact, through 1256 // TODO(johnniwinther): Fully enforce the separation between exact, through
1257 // subclass and through subtype instantiated types/classes. 1257 // subclass and through subtype instantiated types/classes.
1258 // TODO(johnniwinther): Support unknown type arguments for generic types. 1258 // TODO(johnniwinther): Support unknown type arguments for generic types.
1259 void registerTypeInstantiation( 1259 void registerTypeInstantiation(
1260 ResolutionInterfaceType type, ClassUsedCallback classUsed, 1260 ResolutionInterfaceType type, ClassUsedCallback classUsed,
1261 {bool byMirrors: false}) { 1261 {bool byMirrors: false}) {
1262 ClassElement cls = type.element; 1262 ClassElement cls = type.element;
1263 bool isNative = _backend.isNative(cls); 1263 bool isNative = _backend.nativeData.isNativeClass(cls);
1264 _instantiatedTypes.add(type); 1264 _instantiatedTypes.add(type);
1265 if (!cls.isAbstract 1265 if (!cls.isAbstract
1266 // We can't use the closed-world assumption with native abstract 1266 // We can't use the closed-world assumption with native abstract
1267 // classes; a native abstract class may have non-abstract subclasses 1267 // classes; a native abstract class may have non-abstract subclasses
1268 // not declared to the program. Instances of these classes are 1268 // not declared to the program. Instances of these classes are
1269 // indistinguishable from the abstract class. 1269 // indistinguishable from the abstract class.
1270 || 1270 ||
1271 isNative 1271 isNative
1272 // Likewise, if this registration comes from the mirror system, 1272 // Likewise, if this registration comes from the mirror system,
1273 // all bets are off. 1273 // all bets are off.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 _getMemberUsage(member, memberUsed); 1495 _getMemberUsage(member, memberUsed);
1496 }); 1496 });
1497 } 1497 }
1498 1498
1499 _MemberUsage _getMemberUsage( 1499 _MemberUsage _getMemberUsage(
1500 MemberElement member, MemberUsedCallback memberUsed) { 1500 MemberElement member, MemberUsedCallback memberUsed) {
1501 assert(invariant(member, member.isDeclaration)); 1501 assert(invariant(member, member.isDeclaration));
1502 return _instanceMemberUsage.putIfAbsent(member, () { 1502 return _instanceMemberUsage.putIfAbsent(member, () {
1503 String memberName = member.name; 1503 String memberName = member.name;
1504 ClassElement cls = member.enclosingClass; 1504 ClassElement cls = member.enclosingClass;
1505 bool isNative = _backend.isNative(cls); 1505 bool isNative = _backend.nativeData.isNativeClass(cls);
1506 _MemberUsage usage = new _MemberUsage(member, isNative: isNative); 1506 _MemberUsage usage = new _MemberUsage(member, isNative: isNative);
1507 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); 1507 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
1508 useSet.addAll(usage.appliedUse); 1508 useSet.addAll(usage.appliedUse);
1509 if (hasInvokedGetter(member, _world)) { 1509 if (hasInvokedGetter(member, _world)) {
1510 useSet.addAll(usage.read()); 1510 useSet.addAll(usage.read());
1511 } 1511 }
1512 if (hasInvokedSetter(member, _world)) { 1512 if (hasInvokedSetter(member, _world)) {
1513 useSet.addAll(usage.write()); 1513 useSet.addAll(usage.write());
1514 } 1514 }
1515 if (hasInvocation(member, _world)) { 1515 if (hasInvocation(member, _world)) {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 if (hasClosurization) { 1943 if (hasClosurization) {
1944 return MemberUses.NONE; 1944 return MemberUses.NONE;
1945 } 1945 }
1946 hasNormalUse = hasClosurization = true; 1946 hasNormalUse = hasClosurization = true;
1947 return _pendingUse.removeAll(MemberUses.ALL_STATIC); 1947 return _pendingUse.removeAll(MemberUses.ALL_STATIC);
1948 } 1948 }
1949 1949
1950 @override 1950 @override
1951 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC; 1951 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC;
1952 } 1952 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/types/types.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698