| 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 #include <iomanip> | 5 #include <iomanip> |
| 6 | 6 |
| 7 #include "src/types.h" | 7 #include "src/types.h" |
| 8 | 8 |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 #include "src/types-inl.h" | 10 #include "src/types-inl.h" |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 } | 923 } |
| 924 if (lhs->SimplyEquals(rhs->unhandle())) { | 924 if (lhs->SimplyEquals(rhs->unhandle())) { |
| 925 return AddToUnion(lhs, result, size, region); | 925 return AddToUnion(lhs, result, size, region); |
| 926 } | 926 } |
| 927 return size; | 927 return size; |
| 928 } | 928 } |
| 929 | 929 |
| 930 | 930 |
| 931 // Make sure that we produce a well-formed range and bitset: | 931 // Make sure that we produce a well-formed range and bitset: |
| 932 // If the range is non-empty, the number bits in the bitset should be | 932 // If the range is non-empty, the number bits in the bitset should be |
| 933 // clear. Moreover, if we have a canonical range (such as Signed32(), | 933 // clear. Moreover, if we have a canonical range (such as Signed32), |
| 934 // we want to produce a bitset rather than a range. | 934 // we want to produce a bitset rather than a range. |
| 935 template <class Config> | 935 template <class Config> |
| 936 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeRangeAndBitset( | 936 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeRangeAndBitset( |
| 937 RangeHandle range, bitset* bits, Region* region) { | 937 RangeHandle range, bitset* bits, Region* region) { |
| 938 // Fast path: If the bitset does not mention numbers, we can just keep the | 938 // Fast path: If the bitset does not mention numbers, we can just keep the |
| 939 // range. | 939 // range. |
| 940 bitset number_bits = BitsetType::NumberBits(*bits); | 940 bitset number_bits = BitsetType::NumberBits(*bits); |
| 941 if (number_bits == 0) { | 941 if (number_bits == 0) { |
| 942 return range; | 942 return range; |
| 943 } | 943 } |
| 944 | 944 |
| 945 // If the range is contained within the bitset, return an empty range | 945 // If the range is semantically contained within the bitset, return None and |
| 946 // (but make sure we take the representation). | 946 // leave the bitset untouched. |
| 947 bitset range_lub = SEMANTIC(range->BitsetLub()); | 947 bitset range_lub = SEMANTIC(range->BitsetLub()); |
| 948 if (BitsetType::Is(BitsetType::NumberBits(range_lub), *bits)) { | 948 if (BitsetType::Is(BitsetType::NumberBits(range_lub), *bits)) { |
| 949 return None(region); | 949 return None(region); |
| 950 } | 950 } |
| 951 | 951 |
| 952 // Slow path: reconcile the bitset range and the range. | 952 // Slow path: reconcile the bitset range and the range. |
| 953 double bitset_min = BitsetType::Min(number_bits); | 953 double bitset_min = BitsetType::Min(number_bits); |
| 954 double bitset_max = BitsetType::Max(number_bits); | 954 double bitset_max = BitsetType::Max(number_bits); |
| 955 | 955 |
| 956 double range_min = range->Min(); | 956 double range_min = range->Min(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 986 // Fast case: top or bottom types. | 986 // Fast case: top or bottom types. |
| 987 if (type1->IsAny() || type2->IsNone()) return type1; | 987 if (type1->IsAny() || type2->IsNone()) return type1; |
| 988 if (type2->IsAny() || type1->IsNone()) return type2; | 988 if (type2->IsAny() || type1->IsNone()) return type2; |
| 989 | 989 |
| 990 // Semi-fast case. | 990 // Semi-fast case. |
| 991 if (type1->Is(type2)) return type2; | 991 if (type1->Is(type2)) return type2; |
| 992 if (type2->Is(type1)) return type1; | 992 if (type2->Is(type1)) return type1; |
| 993 | 993 |
| 994 // Figure out the representation of the result. | 994 // Figure out the representation of the result. |
| 995 // The rest of the method should not change this representation and | 995 // The rest of the method should not change this representation and |
| 996 // it should make any decisions based on representations (i.e., | 996 // it should not make any decisions based on representations (i.e., |
| 997 // it should only use the semantic part of types). | 997 // it should only use the semantic part of types). |
| 998 const bitset representation = | 998 const bitset representation = |
| 999 type1->Representation() | type2->Representation(); | 999 type1->Representation() | type2->Representation(); |
| 1000 | 1000 |
| 1001 // Slow case: create union. | 1001 // Slow case: create union. |
| 1002 int size1 = type1->IsUnion() ? type1->AsUnion()->Length() : 1; | 1002 int size1 = type1->IsUnion() ? type1->AsUnion()->Length() : 1; |
| 1003 int size2 = type2->IsUnion() ? type2->AsUnion()->Length() : 1; | 1003 int size2 = type2->IsUnion() ? type2->AsUnion()->Length() : 1; |
| 1004 if (!AddIsSafe(size1, size2)) return Any(region); | 1004 if (!AddIsSafe(size1, size2)) return Any(region); |
| 1005 int size = size1 + size2; | 1005 int size = size1 + size2; |
| 1006 if (!AddIsSafe(size, 2)) return Any(region); | 1006 if (!AddIsSafe(size, 2)) return Any(region); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 | 1400 |
| 1401 template TypeImpl<ZoneTypeConfig>::TypeHandle | 1401 template TypeImpl<ZoneTypeConfig>::TypeHandle |
| 1402 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 1402 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
| 1403 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 1403 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
| 1404 template TypeImpl<HeapTypeConfig>::TypeHandle | 1404 template TypeImpl<HeapTypeConfig>::TypeHandle |
| 1405 TypeImpl<HeapTypeConfig>::Convert<Type>( | 1405 TypeImpl<HeapTypeConfig>::Convert<Type>( |
| 1406 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 1406 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
| 1407 | 1407 |
| 1408 } // namespace internal | 1408 } // namespace internal |
| 1409 } // namespace v8 | 1409 } // namespace v8 |
| OLD | NEW |