OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_TYPES_H_ | 5 #ifndef V8_TYPES_H_ |
6 #define V8_TYPES_H_ | 6 #define V8_TYPES_H_ |
7 | 7 |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 // Unrestricted bounds. | 1028 // Unrestricted bounds. |
1029 static BoundsImpl Unbounded(Region* region) { | 1029 static BoundsImpl Unbounded(Region* region) { |
1030 return BoundsImpl(Type::None(region), Type::Any(region)); | 1030 return BoundsImpl(Type::None(region), Type::Any(region)); |
1031 } | 1031 } |
1032 | 1032 |
1033 // Meet: both b1 and b2 are known to hold. | 1033 // Meet: both b1 and b2 are known to hold. |
1034 static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region* region) { | 1034 static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region* region) { |
1035 TypeHandle lower = Type::Union(b1.lower, b2.lower, region); | 1035 TypeHandle lower = Type::Union(b1.lower, b2.lower, region); |
1036 TypeHandle upper = Type::Intersect(b1.upper, b2.upper, region); | 1036 TypeHandle upper = Type::Intersect(b1.upper, b2.upper, region); |
1037 // Lower bounds are considered approximate, correct as necessary. | 1037 // Lower bounds are considered approximate, correct as necessary. |
1038 lower = Type::Intersect(lower, upper, region); | 1038 if (!lower->Is(upper)) lower = upper; |
1039 return BoundsImpl(lower, upper); | 1039 return BoundsImpl(lower, upper); |
1040 } | 1040 } |
1041 | 1041 |
1042 // Join: either b1 or b2 is known to hold. | 1042 // Join: either b1 or b2 is known to hold. |
1043 static BoundsImpl Either(BoundsImpl b1, BoundsImpl b2, Region* region) { | 1043 static BoundsImpl Either(BoundsImpl b1, BoundsImpl b2, Region* region) { |
1044 TypeHandle lower = Type::Intersect(b1.lower, b2.lower, region); | 1044 TypeHandle lower = Type::Intersect(b1.lower, b2.lower, region); |
1045 TypeHandle upper = Type::Union(b1.upper, b2.upper, region); | 1045 TypeHandle upper = Type::Union(b1.upper, b2.upper, region); |
1046 return BoundsImpl(lower, upper); | 1046 return BoundsImpl(lower, upper); |
1047 } | 1047 } |
1048 | 1048 |
1049 static BoundsImpl NarrowLower(BoundsImpl b, TypeHandle t, Region* region) { | 1049 static BoundsImpl NarrowLower(BoundsImpl b, TypeHandle t, Region* region) { |
| 1050 TypeHandle lower = Type::Union(b.lower, t, region); |
1050 // Lower bounds are considered approximate, correct as necessary. | 1051 // Lower bounds are considered approximate, correct as necessary. |
1051 t = Type::Intersect(t, b.upper, region); | 1052 if (!lower->Is(b.upper)) lower = b.upper; |
1052 TypeHandle lower = Type::Union(b.lower, t, region); | |
1053 return BoundsImpl(lower, b.upper); | 1053 return BoundsImpl(lower, b.upper); |
1054 } | 1054 } |
1055 static BoundsImpl NarrowUpper(BoundsImpl b, TypeHandle t, Region* region) { | 1055 static BoundsImpl NarrowUpper(BoundsImpl b, TypeHandle t, Region* region) { |
1056 TypeHandle lower = Type::Intersect(b.lower, t, region); | 1056 TypeHandle lower = b.lower; |
1057 TypeHandle upper = Type::Intersect(b.upper, t, region); | 1057 TypeHandle upper = Type::Intersect(b.upper, t, region); |
| 1058 // Lower bounds are considered approximate, correct as necessary. |
| 1059 if (!lower->Is(upper)) lower = upper; |
1058 return BoundsImpl(lower, upper); | 1060 return BoundsImpl(lower, upper); |
1059 } | 1061 } |
1060 | 1062 |
1061 bool Narrows(BoundsImpl that) { | 1063 bool Narrows(BoundsImpl that) { |
1062 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 1064 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
1063 } | 1065 } |
1064 }; | 1066 }; |
1065 | 1067 |
1066 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 1068 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
1067 | 1069 |
1068 } } // namespace v8::internal | 1070 } } // namespace v8::internal |
1069 | 1071 |
1070 #endif // V8_TYPES_H_ | 1072 #endif // V8_TYPES_H_ |
OLD | NEW |