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

Side by Side Diff: pkg/compiler/lib/src/ssa/nodes.dart

Issue 2659883002: Use entities in BackendClasses (Closed)
Patch Set: Created 3 years, 10 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
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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common/backend_api.dart' show BackendClasses; 7 import '../common/backend_api.dart' show BackendClasses;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 canBePrimitiveBoolean(closedWorld) || 971 canBePrimitiveBoolean(closedWorld) ||
972 canBePrimitiveString(closedWorld) || 972 canBePrimitiveString(closedWorld) ||
973 isNull(); 973 isNull();
974 } 974 }
975 975
976 bool canBePrimitiveNumber(ClosedWorld closedWorld) { 976 bool canBePrimitiveNumber(ClosedWorld closedWorld) {
977 BackendClasses backendClasses = closedWorld.backendClasses; 977 BackendClasses backendClasses = closedWorld.backendClasses;
978 // TODO(sra): It should be possible to test only jsDoubleClass and 978 // TODO(sra): It should be possible to test only jsDoubleClass and
979 // jsUInt31Class, since all others are superclasses of these two. 979 // jsUInt31Class, since all others are superclasses of these two.
980 return containsType( 980 return containsType(
981 instructionType, backendClasses.numImplementation, closedWorld) || 981 instructionType, backendClasses.numClass, closedWorld) ||
982 containsType(instructionType, backendClasses.intClass, closedWorld) ||
982 containsType( 983 containsType(
983 instructionType, backendClasses.intImplementation, closedWorld) || 984 instructionType, backendClasses.positiveIntClass, closedWorld) ||
984 containsType(instructionType, backendClasses.positiveIntImplementation,
985 closedWorld) ||
986 containsType(instructionType, backendClasses.uint32Implementation,
987 closedWorld) ||
988 containsType(instructionType, backendClasses.uint31Implementation,
989 closedWorld) ||
990 containsType( 985 containsType(
991 instructionType, backendClasses.doubleImplementation, closedWorld); 986 instructionType, backendClasses.uint32Class, closedWorld) ||
987 containsType(
988 instructionType, backendClasses.uint31Class, closedWorld) ||
989 containsType(instructionType, backendClasses.doubleClass, closedWorld);
992 } 990 }
993 991
994 bool canBePrimitiveBoolean(ClosedWorld closedWorld) { 992 bool canBePrimitiveBoolean(ClosedWorld closedWorld) {
995 return containsType(instructionType, 993 return containsType(
996 closedWorld.backendClasses.boolImplementation, closedWorld); 994 instructionType, closedWorld.backendClasses.boolClass, closedWorld);
997 } 995 }
998 996
999 bool canBePrimitiveArray(ClosedWorld closedWorld) { 997 bool canBePrimitiveArray(ClosedWorld closedWorld) {
1000 BackendClasses backendClasses = closedWorld.backendClasses; 998 BackendClasses backendClasses = closedWorld.backendClasses;
1001 return containsType( 999 return containsType(
1002 instructionType, backendClasses.listImplementation, closedWorld) || 1000 instructionType, backendClasses.listClass, closedWorld) ||
1003 containsType(instructionType, backendClasses.fixedListImplementation, 1001 containsType(
1004 closedWorld) || 1002 instructionType, backendClasses.fixedListClass, closedWorld) ||
1005 containsType(instructionType, backendClasses.growableListImplementation, 1003 containsType(
1006 closedWorld) || 1004 instructionType, backendClasses.growableListClass, closedWorld) ||
1007 containsType(instructionType, backendClasses.constListImplementation, 1005 containsType(
1008 closedWorld); 1006 instructionType, backendClasses.constListClass, closedWorld);
1009 } 1007 }
1010 1008
1011 bool isIndexablePrimitive(ClosedWorld closedWorld) { 1009 bool isIndexablePrimitive(ClosedWorld closedWorld) {
1012 return instructionType.containsOnlyString(closedWorld) || 1010 return instructionType.containsOnlyString(closedWorld) ||
1013 isInstanceOf(instructionType, 1011 isInstanceOf(instructionType, closedWorld.backendClasses.indexableClass,
1014 closedWorld.backendClasses.indexableImplementation, closedWorld); 1012 closedWorld);
1015 } 1013 }
1016 1014
1017 bool isFixedArray(ClosedWorld closedWorld) { 1015 bool isFixedArray(ClosedWorld closedWorld) {
1018 BackendClasses backendClasses = closedWorld.backendClasses; 1016 BackendClasses backendClasses = closedWorld.backendClasses;
1019 // TODO(sra): Recognize the union of these types as well. 1017 // TODO(sra): Recognize the union of these types as well.
1020 return containsOnlyType(instructionType, 1018 return containsOnlyType(
1021 backendClasses.fixedListImplementation, closedWorld) || 1019 instructionType, backendClasses.fixedListClass, closedWorld) ||
1022 containsOnlyType(instructionType, 1020 containsOnlyType(
1023 backendClasses.constListImplementation, closedWorld); 1021 instructionType, backendClasses.constListClass, closedWorld);
1024 } 1022 }
1025 1023
1026 bool isExtendableArray(ClosedWorld closedWorld) { 1024 bool isExtendableArray(ClosedWorld closedWorld) {
1027 return containsOnlyType(instructionType, 1025 return containsOnlyType(instructionType,
1028 closedWorld.backendClasses.growableListImplementation, closedWorld); 1026 closedWorld.backendClasses.growableListClass, closedWorld);
1029 } 1027 }
1030 1028
1031 bool isMutableArray(ClosedWorld closedWorld) { 1029 bool isMutableArray(ClosedWorld closedWorld) {
1032 return isInstanceOf(instructionType, 1030 return isInstanceOf(instructionType,
1033 closedWorld.backendClasses.mutableListImplementation, closedWorld); 1031 closedWorld.backendClasses.mutableListClass, closedWorld);
1034 } 1032 }
1035 1033
1036 bool isReadableArray(ClosedWorld closedWorld) { 1034 bool isReadableArray(ClosedWorld closedWorld) {
1037 return isInstanceOf(instructionType, 1035 return isInstanceOf(
1038 closedWorld.backendClasses.listImplementation, closedWorld); 1036 instructionType, closedWorld.backendClasses.listClass, closedWorld);
1039 } 1037 }
1040 1038
1041 bool isMutableIndexable(ClosedWorld closedWorld) { 1039 bool isMutableIndexable(ClosedWorld closedWorld) {
1042 return isInstanceOf(instructionType, 1040 return isInstanceOf(instructionType,
1043 closedWorld.backendClasses.mutableIndexableImplementation, closedWorld); 1041 closedWorld.backendClasses.mutableIndexableClass, closedWorld);
1044 } 1042 }
1045 1043
1046 bool isArray(ClosedWorld closedWorld) => isReadableArray(closedWorld); 1044 bool isArray(ClosedWorld closedWorld) => isReadableArray(closedWorld);
1047 1045
1048 bool canBePrimitiveString(ClosedWorld closedWorld) { 1046 bool canBePrimitiveString(ClosedWorld closedWorld) {
1049 return containsType(instructionType, 1047 return containsType(
1050 closedWorld.backendClasses.stringImplementation, closedWorld); 1048 instructionType, closedWorld.backendClasses.stringClass, closedWorld);
1051 } 1049 }
1052 1050
1053 bool isInteger(ClosedWorld closedWorld) { 1051 bool isInteger(ClosedWorld closedWorld) {
1054 return instructionType.containsOnlyInt(closedWorld) && 1052 return instructionType.containsOnlyInt(closedWorld) &&
1055 !instructionType.isNullable; 1053 !instructionType.isNullable;
1056 } 1054 }
1057 1055
1058 bool isUInt32(ClosedWorld closedWorld) { 1056 bool isUInt32(ClosedWorld closedWorld) {
1059 return !instructionType.isNullable && 1057 return !instructionType.isNullable &&
1060 isInstanceOf(instructionType, 1058 isInstanceOf(instructionType, closedWorld.backendClasses.uint32Class,
1061 closedWorld.backendClasses.uint32Implementation, closedWorld); 1059 closedWorld);
1062 } 1060 }
1063 1061
1064 bool isUInt31(ClosedWorld closedWorld) { 1062 bool isUInt31(ClosedWorld closedWorld) {
1065 return !instructionType.isNullable && 1063 return !instructionType.isNullable &&
1066 isInstanceOf(instructionType, 1064 isInstanceOf(instructionType, closedWorld.backendClasses.uint31Class,
1067 closedWorld.backendClasses.uint31Implementation, closedWorld); 1065 closedWorld);
1068 } 1066 }
1069 1067
1070 bool isPositiveInteger(ClosedWorld closedWorld) { 1068 bool isPositiveInteger(ClosedWorld closedWorld) {
1071 return !instructionType.isNullable && 1069 return !instructionType.isNullable &&
1072 isInstanceOf(instructionType, 1070 isInstanceOf(instructionType,
1073 closedWorld.backendClasses.positiveIntImplementation, closedWorld); 1071 closedWorld.backendClasses.positiveIntClass, closedWorld);
1074 } 1072 }
1075 1073
1076 bool isPositiveIntegerOrNull(ClosedWorld closedWorld) { 1074 bool isPositiveIntegerOrNull(ClosedWorld closedWorld) {
1077 return isInstanceOf(instructionType, 1075 return isInstanceOf(instructionType,
1078 closedWorld.backendClasses.positiveIntImplementation, closedWorld); 1076 closedWorld.backendClasses.positiveIntClass, closedWorld);
1079 } 1077 }
1080 1078
1081 bool isIntegerOrNull(ClosedWorld closedWorld) { 1079 bool isIntegerOrNull(ClosedWorld closedWorld) {
1082 return instructionType.containsOnlyInt(closedWorld); 1080 return instructionType.containsOnlyInt(closedWorld);
1083 } 1081 }
1084 1082
1085 bool isNumber(ClosedWorld closedWorld) { 1083 bool isNumber(ClosedWorld closedWorld) {
1086 return instructionType.containsOnlyNum(closedWorld) && 1084 return instructionType.containsOnlyNum(closedWorld) &&
1087 !instructionType.isNullable; 1085 !instructionType.isNullable;
1088 } 1086 }
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 class HDynamicType extends HRuntimeType { 3471 class HDynamicType extends HRuntimeType {
3474 HDynamicType(DynamicType dartType, TypeMask instructionType) 3472 HDynamicType(DynamicType dartType, TypeMask instructionType)
3475 : super(const <HInstruction>[], dartType, instructionType); 3473 : super(const <HInstruction>[], dartType, instructionType);
3476 3474
3477 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3475 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3478 3476
3479 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3477 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3480 3478
3481 bool typeEquals(HInstruction other) => other is HDynamicType; 3479 bool typeEquals(HInstruction other) => other is HDynamicType;
3482 } 3480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698