| OLD | NEW |
| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
| 8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
| 9 R visitAwait(HAwait node); | 9 R visitAwait(HAwait node); |
| 10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 return canBePrimitiveNumber(compiler) | 915 return canBePrimitiveNumber(compiler) |
| 916 || canBePrimitiveArray(compiler) | 916 || canBePrimitiveArray(compiler) |
| 917 || canBePrimitiveBoolean(compiler) | 917 || canBePrimitiveBoolean(compiler) |
| 918 || canBePrimitiveString(compiler) | 918 || canBePrimitiveString(compiler) |
| 919 || isNull(); | 919 || isNull(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 bool canBePrimitiveNumber(Compiler compiler) { | 922 bool canBePrimitiveNumber(Compiler compiler) { |
| 923 ClassWorld classWorld = compiler.world; | 923 ClassWorld classWorld = compiler.world; |
| 924 JavaScriptBackend backend = compiler.backend; | 924 JavaScriptBackend backend = compiler.backend; |
| 925 BackendHelpers helpers = backend.helpers; |
| 925 // TODO(sra): It should be possible to test only jsDoubleClass and | 926 // TODO(sra): It should be possible to test only jsDoubleClass and |
| 926 // jsUInt31Class, since all others are superclasses of these two. | 927 // jsUInt31Class, since all others are superclasses of these two. |
| 927 return containsType(instructionType, backend.jsNumberClass, classWorld) | 928 return containsType(instructionType, helpers.jsNumberClass, classWorld) |
| 928 || containsType(instructionType, backend.jsIntClass, classWorld) | 929 || containsType(instructionType, helpers.jsIntClass, classWorld) |
| 929 || containsType(instructionType, backend.jsPositiveIntClass, classWorld) | 930 || containsType(instructionType, helpers.jsPositiveIntClass, classWorld) |
| 930 || containsType(instructionType, backend.jsUInt32Class, classWorld) | 931 || containsType(instructionType, helpers.jsUInt32Class, classWorld) |
| 931 || containsType(instructionType, backend.jsUInt31Class, classWorld) | 932 || containsType(instructionType, helpers.jsUInt31Class, classWorld) |
| 932 || containsType(instructionType, backend.jsDoubleClass, classWorld); | 933 || containsType(instructionType, helpers.jsDoubleClass, classWorld); |
| 933 } | 934 } |
| 934 | 935 |
| 935 bool canBePrimitiveBoolean(Compiler compiler) { | 936 bool canBePrimitiveBoolean(Compiler compiler) { |
| 936 ClassWorld classWorld = compiler.world; | 937 ClassWorld classWorld = compiler.world; |
| 937 JavaScriptBackend backend = compiler.backend; | 938 JavaScriptBackend backend = compiler.backend; |
| 938 return containsType(instructionType, backend.jsBoolClass, classWorld); | 939 BackendHelpers helpers = backend.helpers; |
| 940 return containsType(instructionType, helpers.jsBoolClass, classWorld); |
| 939 } | 941 } |
| 940 | 942 |
| 941 bool canBePrimitiveArray(Compiler compiler) { | 943 bool canBePrimitiveArray(Compiler compiler) { |
| 942 ClassWorld classWorld = compiler.world; | 944 ClassWorld classWorld = compiler.world; |
| 943 JavaScriptBackend backend = compiler.backend; | 945 JavaScriptBackend backend = compiler.backend; |
| 944 return containsType(instructionType, backend.jsArrayClass, classWorld) | 946 BackendHelpers helpers = backend.helpers; |
| 945 || containsType(instructionType, backend.jsFixedArrayClass, classWorld) | 947 return containsType(instructionType, helpers.jsArrayClass, classWorld) |
| 948 || containsType(instructionType, helpers.jsFixedArrayClass, classWorld) |
| 946 || containsType( | 949 || containsType( |
| 947 instructionType, backend.jsExtendableArrayClass, classWorld) | 950 instructionType, helpers.jsExtendableArrayClass, classWorld) |
| 948 || containsType(instructionType, | 951 || containsType(instructionType, |
| 949 backend.jsUnmodifiableArrayClass, classWorld); | 952 helpers.jsUnmodifiableArrayClass, classWorld); |
| 950 } | 953 } |
| 951 | 954 |
| 952 bool isIndexablePrimitive(Compiler compiler) { | 955 bool isIndexablePrimitive(Compiler compiler) { |
| 953 ClassWorld classWorld = compiler.world; | 956 ClassWorld classWorld = compiler.world; |
| 954 JavaScriptBackend backend = compiler.backend; | 957 JavaScriptBackend backend = compiler.backend; |
| 958 BackendHelpers helpers = backend.helpers; |
| 955 return instructionType.containsOnlyString(classWorld) | 959 return instructionType.containsOnlyString(classWorld) |
| 956 || isInstanceOf(instructionType, backend.jsIndexableClass, classWorld); | 960 || isInstanceOf(instructionType, helpers.jsIndexableClass, classWorld); |
| 957 } | 961 } |
| 958 | 962 |
| 959 bool isFixedArray(Compiler compiler) { | 963 bool isFixedArray(Compiler compiler) { |
| 960 ClassWorld classWorld = compiler.world; | 964 ClassWorld classWorld = compiler.world; |
| 961 JavaScriptBackend backend = compiler.backend; | 965 JavaScriptBackend backend = compiler.backend; |
| 966 BackendHelpers helpers = backend.helpers; |
| 962 // TODO(sra): Recognize the union of these types as well. | 967 // TODO(sra): Recognize the union of these types as well. |
| 963 return containsOnlyType( | 968 return containsOnlyType( |
| 964 instructionType, backend.jsFixedArrayClass, classWorld) | 969 instructionType, helpers.jsFixedArrayClass, classWorld) |
| 965 || containsOnlyType( | 970 || containsOnlyType( |
| 966 instructionType, backend.jsUnmodifiableArrayClass, classWorld); | 971 instructionType, helpers.jsUnmodifiableArrayClass, classWorld); |
| 967 } | 972 } |
| 968 | 973 |
| 969 bool isExtendableArray(Compiler compiler) { | 974 bool isExtendableArray(Compiler compiler) { |
| 970 ClassWorld classWorld = compiler.world; | 975 ClassWorld classWorld = compiler.world; |
| 971 JavaScriptBackend backend = compiler.backend; | 976 JavaScriptBackend backend = compiler.backend; |
| 977 BackendHelpers helpers = backend.helpers; |
| 972 return containsOnlyType( | 978 return containsOnlyType( |
| 973 instructionType, backend.jsExtendableArrayClass, classWorld); | 979 instructionType, helpers.jsExtendableArrayClass, classWorld); |
| 974 } | 980 } |
| 975 | 981 |
| 976 bool isMutableArray(Compiler compiler) { | 982 bool isMutableArray(Compiler compiler) { |
| 977 ClassWorld classWorld = compiler.world; | 983 ClassWorld classWorld = compiler.world; |
| 978 JavaScriptBackend backend = compiler.backend; | 984 JavaScriptBackend backend = compiler.backend; |
| 985 BackendHelpers helpers = backend.helpers; |
| 979 return isInstanceOf( | 986 return isInstanceOf( |
| 980 instructionType, backend.jsMutableArrayClass, classWorld); | 987 instructionType, helpers.jsMutableArrayClass, classWorld); |
| 981 } | 988 } |
| 982 | 989 |
| 983 bool isReadableArray(Compiler compiler) { | 990 bool isReadableArray(Compiler compiler) { |
| 984 ClassWorld classWorld = compiler.world; | 991 ClassWorld classWorld = compiler.world; |
| 985 JavaScriptBackend backend = compiler.backend; | 992 JavaScriptBackend backend = compiler.backend; |
| 986 return isInstanceOf(instructionType, backend.jsArrayClass, classWorld); | 993 BackendHelpers helpers = backend.helpers; |
| 994 return isInstanceOf(instructionType, helpers.jsArrayClass, classWorld); |
| 987 } | 995 } |
| 988 | 996 |
| 989 bool isMutableIndexable(Compiler compiler) { | 997 bool isMutableIndexable(Compiler compiler) { |
| 990 ClassWorld classWorld = compiler.world; | 998 ClassWorld classWorld = compiler.world; |
| 991 JavaScriptBackend backend = compiler.backend; | 999 JavaScriptBackend backend = compiler.backend; |
| 1000 BackendHelpers helpers = backend.helpers; |
| 992 return isInstanceOf(instructionType, | 1001 return isInstanceOf(instructionType, |
| 993 backend.jsMutableIndexableClass, classWorld); | 1002 helpers.jsMutableIndexableClass, classWorld); |
| 994 } | 1003 } |
| 995 | 1004 |
| 996 bool isArray(Compiler compiler) => isReadableArray(compiler); | 1005 bool isArray(Compiler compiler) => isReadableArray(compiler); |
| 997 | 1006 |
| 998 bool canBePrimitiveString(Compiler compiler) { | 1007 bool canBePrimitiveString(Compiler compiler) { |
| 999 ClassWorld classWorld = compiler.world; | 1008 ClassWorld classWorld = compiler.world; |
| 1000 JavaScriptBackend backend = compiler.backend; | 1009 JavaScriptBackend backend = compiler.backend; |
| 1001 return containsType(instructionType, backend.jsStringClass, classWorld); | 1010 BackendHelpers helpers = backend.helpers; |
| 1011 return containsType(instructionType, helpers.jsStringClass, classWorld); |
| 1002 } | 1012 } |
| 1003 | 1013 |
| 1004 bool isInteger(Compiler compiler) { | 1014 bool isInteger(Compiler compiler) { |
| 1005 ClassWorld classWorld = compiler.world; | 1015 ClassWorld classWorld = compiler.world; |
| 1006 return instructionType.containsOnlyInt(classWorld) | 1016 return instructionType.containsOnlyInt(classWorld) |
| 1007 && !instructionType.isNullable; | 1017 && !instructionType.isNullable; |
| 1008 } | 1018 } |
| 1009 | 1019 |
| 1010 bool isUInt32(Compiler compiler) { | 1020 bool isUInt32(Compiler compiler) { |
| 1011 ClassWorld classWorld = compiler.world; | 1021 ClassWorld classWorld = compiler.world; |
| 1012 JavaScriptBackend backend = compiler.backend; | 1022 JavaScriptBackend backend = compiler.backend; |
| 1023 BackendHelpers helpers = backend.helpers; |
| 1013 return !instructionType.isNullable | 1024 return !instructionType.isNullable |
| 1014 && isInstanceOf(instructionType, backend.jsUInt32Class, classWorld); | 1025 && isInstanceOf(instructionType, helpers.jsUInt32Class, classWorld); |
| 1015 } | 1026 } |
| 1016 | 1027 |
| 1017 bool isUInt31(Compiler compiler) { | 1028 bool isUInt31(Compiler compiler) { |
| 1018 ClassWorld classWorld = compiler.world; | 1029 ClassWorld classWorld = compiler.world; |
| 1019 JavaScriptBackend backend = compiler.backend; | 1030 JavaScriptBackend backend = compiler.backend; |
| 1031 BackendHelpers helpers = backend.helpers; |
| 1020 return !instructionType.isNullable | 1032 return !instructionType.isNullable |
| 1021 && isInstanceOf(instructionType, backend.jsUInt31Class, classWorld); | 1033 && isInstanceOf(instructionType, helpers.jsUInt31Class, classWorld); |
| 1022 } | 1034 } |
| 1023 | 1035 |
| 1024 bool isPositiveInteger(Compiler compiler) { | 1036 bool isPositiveInteger(Compiler compiler) { |
| 1025 ClassWorld classWorld = compiler.world; | 1037 ClassWorld classWorld = compiler.world; |
| 1026 JavaScriptBackend backend = compiler.backend; | 1038 JavaScriptBackend backend = compiler.backend; |
| 1039 BackendHelpers helpers = backend.helpers; |
| 1027 return !instructionType.isNullable && | 1040 return !instructionType.isNullable && |
| 1028 isInstanceOf(instructionType, backend.jsPositiveIntClass, classWorld); | 1041 isInstanceOf(instructionType, helpers.jsPositiveIntClass, classWorld); |
| 1029 } | 1042 } |
| 1030 | 1043 |
| 1031 bool isPositiveIntegerOrNull(Compiler compiler) { | 1044 bool isPositiveIntegerOrNull(Compiler compiler) { |
| 1032 ClassWorld classWorld = compiler.world; | 1045 ClassWorld classWorld = compiler.world; |
| 1033 JavaScriptBackend backend = compiler.backend; | 1046 JavaScriptBackend backend = compiler.backend; |
| 1047 BackendHelpers helpers = backend.helpers; |
| 1034 return isInstanceOf( | 1048 return isInstanceOf( |
| 1035 instructionType, backend.jsPositiveIntClass, classWorld); | 1049 instructionType, helpers.jsPositiveIntClass, classWorld); |
| 1036 } | 1050 } |
| 1037 | 1051 |
| 1038 bool isIntegerOrNull(Compiler compiler) { | 1052 bool isIntegerOrNull(Compiler compiler) { |
| 1039 ClassWorld classWorld = compiler.world; | 1053 ClassWorld classWorld = compiler.world; |
| 1040 return instructionType.containsOnlyInt(classWorld); | 1054 return instructionType.containsOnlyInt(classWorld); |
| 1041 } | 1055 } |
| 1042 | 1056 |
| 1043 bool isNumber(Compiler compiler) { | 1057 bool isNumber(Compiler compiler) { |
| 1044 ClassWorld classWorld = compiler.world; | 1058 ClassWorld classWorld = compiler.world; |
| 1045 return instructionType.containsOnlyNum(classWorld) | 1059 return instructionType.containsOnlyNum(classWorld) |
| (...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3327 class HDynamicType extends HRuntimeType { | 3341 class HDynamicType extends HRuntimeType { |
| 3328 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3342 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3329 : super(const <HInstruction>[], dartType, instructionType); | 3343 : super(const <HInstruction>[], dartType, instructionType); |
| 3330 | 3344 |
| 3331 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3345 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3332 | 3346 |
| 3333 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3347 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3334 | 3348 |
| 3335 bool typeEquals(HInstruction other) => other is HDynamicType; | 3349 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3336 } | 3350 } |
| OLD | NEW |