| 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 // remove the number bits from the bitset. | 770 // remove the number bits from the bitset. |
| 771 if (!IsEmpty(lims)) { | 771 if (!IsEmpty(lims)) { |
| 772 size = UpdateRange(RangeType::New(lims, representation, region), result, | 772 size = UpdateRange(RangeType::New(lims, representation, region), result, |
| 773 size, region); | 773 size, region); |
| 774 | 774 |
| 775 // Remove the number bits. | 775 // Remove the number bits. |
| 776 bitset number_bits = BitsetType::NumberBits(bits); | 776 bitset number_bits = BitsetType::NumberBits(bits); |
| 777 bits &= ~number_bits; | 777 bits &= ~number_bits; |
| 778 result->Set(0, BitsetType::New(bits, region)); | 778 result->Set(0, BitsetType::New(bits, region)); |
| 779 } | 779 } |
| 780 return NormalizeUnion(result, size); | 780 return NormalizeUnion(result, size, region); |
| 781 } | 781 } |
| 782 | 782 |
| 783 | 783 |
| 784 template<class Config> | 784 template<class Config> |
| 785 int TypeImpl<Config>::UpdateRange( | 785 int TypeImpl<Config>::UpdateRange( |
| 786 RangeHandle range, UnionHandle result, int size, Region* region) { | 786 RangeHandle range, UnionHandle result, int size, Region* region) { |
| 787 if (size == 1) { | 787 if (size == 1) { |
| 788 result->Set(size++, range); | 788 result->Set(size++, range); |
| 789 } else { | 789 } else { |
| 790 // Make space for the range. | 790 // Make space for the range. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 } else if (range2 != NULL) { | 985 } else if (range2 != NULL) { |
| 986 range = NormalizeRangeAndBitset(handle(range2), &new_bitset, region); | 986 range = NormalizeRangeAndBitset(handle(range2), &new_bitset, region); |
| 987 } | 987 } |
| 988 new_bitset = SEMANTIC(new_bitset) | representation; | 988 new_bitset = SEMANTIC(new_bitset) | representation; |
| 989 TypeHandle bits = BitsetType::New(new_bitset, region); | 989 TypeHandle bits = BitsetType::New(new_bitset, region); |
| 990 result->Set(size++, bits); | 990 result->Set(size++, bits); |
| 991 if (!range->IsNone()) result->Set(size++, range); | 991 if (!range->IsNone()) result->Set(size++, range); |
| 992 | 992 |
| 993 size = AddToUnion(type1, result, size, region); | 993 size = AddToUnion(type1, result, size, region); |
| 994 size = AddToUnion(type2, result, size, region); | 994 size = AddToUnion(type2, result, size, region); |
| 995 return NormalizeUnion(result, size); | 995 return NormalizeUnion(result, size, region); |
| 996 } | 996 } |
| 997 | 997 |
| 998 | 998 |
| 999 // Add [type] to [result] unless [type] is bitset, range, or already subsumed. | 999 // Add [type] to [result] unless [type] is bitset, range, or already subsumed. |
| 1000 // Return new size of [result]. | 1000 // Return new size of [result]. |
| 1001 template<class Config> | 1001 template<class Config> |
| 1002 int TypeImpl<Config>::AddToUnion( | 1002 int TypeImpl<Config>::AddToUnion( |
| 1003 TypeHandle type, UnionHandle result, int size, Region* region) { | 1003 TypeHandle type, UnionHandle result, int size, Region* region) { |
| 1004 if (type->IsBitset() || type->IsRange()) return size; | 1004 if (type->IsBitset() || type->IsRange()) return size; |
| 1005 if (type->IsUnion()) { | 1005 if (type->IsUnion()) { |
| 1006 for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) { | 1006 for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) { |
| 1007 size = AddToUnion(type->AsUnion()->Get(i), result, size, region); | 1007 size = AddToUnion(type->AsUnion()->Get(i), result, size, region); |
| 1008 } | 1008 } |
| 1009 return size; | 1009 return size; |
| 1010 } | 1010 } |
| 1011 for (int i = 0; i < size; ++i) { | 1011 for (int i = 0; i < size; ++i) { |
| 1012 if (type->SemanticIs(result->Get(i)->unhandle())) return size; | 1012 if (type->SemanticIs(result->Get(i)->unhandle())) return size; |
| 1013 } | 1013 } |
| 1014 result->Set(size++, type); | 1014 result->Set(size++, type); |
| 1015 return size; | 1015 return size; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 | 1018 |
| 1019 template<class Config> | 1019 template <class Config> |
| 1020 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion( | 1020 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion( |
| 1021 UnionHandle unioned, int size) { | 1021 UnionHandle unioned, int size, Region* region) { |
| 1022 DCHECK(size >= 1); | 1022 DCHECK(size >= 1); |
| 1023 DCHECK(unioned->Get(0)->IsBitset()); | 1023 DCHECK(unioned->Get(0)->IsBitset()); |
| 1024 // If the union has just one element, return it. | 1024 // If the union has just one element, return it. |
| 1025 if (size == 1) { | 1025 if (size == 1) { |
| 1026 return unioned->Get(0); | 1026 return unioned->Get(0); |
| 1027 } | 1027 } |
| 1028 bitset bits = unioned->Get(0)->AsBitset(); | 1028 bitset bits = unioned->Get(0)->AsBitset(); |
| 1029 // If the union only consists of a range, we can get rid of the union. | 1029 // If the union only consists of a range, we can get rid of the union. |
| 1030 if (size == 2 && SEMANTIC(bits) == BitsetType::kNone) { | 1030 if (size == 2 && SEMANTIC(bits) == BitsetType::kNone) { |
| 1031 bitset representation = REPRESENTATION(bits); | 1031 bitset representation = REPRESENTATION(bits); |
| 1032 if (representation == unioned->Get(1)->Representation()) { | 1032 if (representation == unioned->Get(1)->Representation()) { |
| 1033 return unioned->Get(1); | 1033 return unioned->Get(1); |
| 1034 } | 1034 } |
| 1035 // TODO(jarin) If the element at 1 is range of constant, slap | 1035 if (unioned->Get(1)->IsRange()) { |
| 1036 // the representation on it and return that. | 1036 return RangeType::New(unioned->Get(1)->AsRange()->Min(), |
| 1037 unioned->Get(1)->AsRange()->Max(), unioned->Get(0), |
| 1038 region); |
| 1039 } |
| 1037 } | 1040 } |
| 1038 unioned->Shrink(size); | 1041 unioned->Shrink(size); |
| 1039 SLOW_DCHECK(unioned->Wellformed()); | 1042 SLOW_DCHECK(unioned->Wellformed()); |
| 1040 return unioned; | 1043 return unioned; |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1043 | 1046 |
| 1044 // ----------------------------------------------------------------------------- | 1047 // ----------------------------------------------------------------------------- |
| 1045 // Component extraction | 1048 // Component extraction |
| 1046 | 1049 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; | 1360 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
| 1358 | 1361 |
| 1359 template TypeImpl<ZoneTypeConfig>::TypeHandle | 1362 template TypeImpl<ZoneTypeConfig>::TypeHandle |
| 1360 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 1363 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
| 1361 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 1364 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
| 1362 template TypeImpl<HeapTypeConfig>::TypeHandle | 1365 template TypeImpl<HeapTypeConfig>::TypeHandle |
| 1363 TypeImpl<HeapTypeConfig>::Convert<Type>( | 1366 TypeImpl<HeapTypeConfig>::Convert<Type>( |
| 1364 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 1367 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
| 1365 | 1368 |
| 1366 } } // namespace v8::internal | 1369 } } // namespace v8::internal |
| OLD | NEW |