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/compiler/types.h" | 7 #include "src/compiler/types.h" |
8 | 8 |
9 #include "src/handles-inl.h" | 9 #include "src/handles-inl.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 // static | 457 // static |
458 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) { | 458 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) { |
459 return value->IsHeapNumber() && | 459 return value->IsHeapNumber() && |
460 IsOtherNumberConstant(HeapNumber::cast(value)->value()); | 460 IsOtherNumberConstant(HeapNumber::cast(value)->value()); |
461 } | 461 } |
462 | 462 |
463 HeapConstantType::HeapConstantType(BitsetType::bitset bitset, | 463 HeapConstantType::HeapConstantType(BitsetType::bitset bitset, |
464 i::Handle<i::HeapObject> object) | 464 i::Handle<i::HeapObject> object) |
465 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) { | 465 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) { |
466 DCHECK(!object->IsHeapNumber()); | 466 DCHECK(!object->IsHeapNumber()); |
467 DCHECK(!object->IsString()); | 467 DCHECK_IMPLIES(object->IsString(), object->IsInternalizedString()); |
468 } | 468 } |
469 | 469 |
470 // ----------------------------------------------------------------------------- | 470 // ----------------------------------------------------------------------------- |
471 // Predicates. | 471 // Predicates. |
472 | 472 |
473 bool Type::SimplyEquals(Type* that) { | 473 bool Type::SimplyEquals(Type* that) { |
474 DisallowHeapAllocation no_allocation; | 474 DisallowHeapAllocation no_allocation; |
475 if (this->IsHeapConstant()) { | 475 if (this->IsHeapConstant()) { |
476 return that->IsHeapConstant() && | 476 return that->IsHeapConstant() && |
477 this->AsHeapConstant()->Value().address() == | 477 this->AsHeapConstant()->Value().address() == |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 DCHECK(OtherNumberConstantType::IsOtherNumberConstant(value)); | 833 DCHECK(OtherNumberConstantType::IsOtherNumberConstant(value)); |
834 return OtherNumberConstant(value, zone); | 834 return OtherNumberConstant(value, zone); |
835 } | 835 } |
836 | 836 |
837 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { | 837 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { |
838 if (IsInteger(*value)) { | 838 if (IsInteger(*value)) { |
839 double v = value->Number(); | 839 double v = value->Number(); |
840 return Range(v, v, zone); | 840 return Range(v, v, zone); |
841 } else if (value->IsHeapNumber()) { | 841 } else if (value->IsHeapNumber()) { |
842 return NewConstant(value->Number(), zone); | 842 return NewConstant(value->Number(), zone); |
843 } else if (value->IsString()) { | 843 } else if (value->IsString() && !value->IsInternalizedString()) { |
844 bitset b = BitsetType::Lub(*value); | 844 return Type::OtherString(); |
845 DCHECK(b == BitsetType::kInternalizedString || | |
846 b == BitsetType::kOtherString); | |
847 if (b == BitsetType::kInternalizedString) { | |
848 return Type::InternalizedString(); | |
849 } else if (b == BitsetType::kOtherString) { | |
850 return Type::OtherString(); | |
851 } else { | |
852 UNREACHABLE(); | |
853 } | |
854 } | 845 } |
855 return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone); | 846 return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone); |
856 } | 847 } |
857 | 848 |
858 Type* Type::Union(Type* type1, Type* type2, Zone* zone) { | 849 Type* Type::Union(Type* type1, Type* type2, Zone* zone) { |
859 // Fast case: bit sets. | 850 // Fast case: bit sets. |
860 if (type1->IsBitset() && type2->IsBitset()) { | 851 if (type1->IsBitset() && type2->IsBitset()) { |
861 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); | 852 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); |
862 } | 853 } |
863 | 854 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; | 1055 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; |
1065 } | 1056 } |
1066 | 1057 |
1067 BitsetType::bitset BitsetType::UnsignedSmall() { | 1058 BitsetType::bitset BitsetType::UnsignedSmall() { |
1068 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; | 1059 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; |
1069 } | 1060 } |
1070 | 1061 |
1071 } // namespace compiler | 1062 } // namespace compiler |
1072 } // namespace internal | 1063 } // namespace internal |
1073 } // namespace v8 | 1064 } // namespace v8 |
OLD | NEW |