| 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/ostreams.h" | 10 #include "src/ostreams.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // static | 399 // static |
| 400 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) { | 400 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) { |
| 401 return value->IsHeapNumber() && | 401 return value->IsHeapNumber() && |
| 402 IsOtherNumberConstant(HeapNumber::cast(value)->value()); | 402 IsOtherNumberConstant(HeapNumber::cast(value)->value()); |
| 403 } | 403 } |
| 404 | 404 |
| 405 HeapConstantType::HeapConstantType(BitsetType::bitset bitset, | 405 HeapConstantType::HeapConstantType(BitsetType::bitset bitset, |
| 406 i::Handle<i::HeapObject> object) | 406 i::Handle<i::HeapObject> object) |
| 407 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) { | 407 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) { |
| 408 DCHECK(!object->IsHeapNumber()); | 408 DCHECK(!object->IsHeapNumber()); |
| 409 DCHECK(!object->IsString()); |
| 409 } | 410 } |
| 410 | 411 |
| 411 // ----------------------------------------------------------------------------- | 412 // ----------------------------------------------------------------------------- |
| 412 // Predicates. | 413 // Predicates. |
| 413 | 414 |
| 414 bool Type::SimplyEquals(Type* that) { | 415 bool Type::SimplyEquals(Type* that) { |
| 415 DisallowHeapAllocation no_allocation; | 416 DisallowHeapAllocation no_allocation; |
| 416 if (this->IsHeapConstant()) { | 417 if (this->IsHeapConstant()) { |
| 417 return that->IsHeapConstant() && | 418 return that->IsHeapConstant() && |
| 418 this->AsHeapConstant()->Value().address() == | 419 this->AsHeapConstant()->Value().address() == |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 DCHECK(OtherNumberConstantType::IsOtherNumberConstant(value)); | 775 DCHECK(OtherNumberConstantType::IsOtherNumberConstant(value)); |
| 775 return OtherNumberConstant(value, zone); | 776 return OtherNumberConstant(value, zone); |
| 776 } | 777 } |
| 777 | 778 |
| 778 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { | 779 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { |
| 779 if (IsInteger(*value)) { | 780 if (IsInteger(*value)) { |
| 780 double v = value->Number(); | 781 double v = value->Number(); |
| 781 return Range(v, v, zone); | 782 return Range(v, v, zone); |
| 782 } else if (value->IsHeapNumber()) { | 783 } else if (value->IsHeapNumber()) { |
| 783 return NewConstant(value->Number(), zone); | 784 return NewConstant(value->Number(), zone); |
| 785 } else if (value->IsString()) { |
| 786 bitset b = BitsetType::Lub(*value); |
| 787 DCHECK(b == BitsetType::kInternalizedString || |
| 788 b == BitsetType::kOtherString); |
| 789 if (b == BitsetType::kInternalizedString) { |
| 790 return Type::InternalizedString(); |
| 791 } else if (b == BitsetType::kOtherString) { |
| 792 return Type::OtherString(); |
| 793 } else { |
| 794 UNREACHABLE(); |
| 795 } |
| 784 } | 796 } |
| 785 return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone); | 797 return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone); |
| 786 } | 798 } |
| 787 | 799 |
| 788 Type* Type::Union(Type* type1, Type* type2, Zone* zone) { | 800 Type* Type::Union(Type* type1, Type* type2, Zone* zone) { |
| 789 // Fast case: bit sets. | 801 // Fast case: bit sets. |
| 790 if (type1->IsBitset() && type2->IsBitset()) { | 802 if (type1->IsBitset() && type2->IsBitset()) { |
| 791 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); | 803 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); |
| 792 } | 804 } |
| 793 | 805 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; | 1006 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; |
| 995 } | 1007 } |
| 996 | 1008 |
| 997 BitsetType::bitset BitsetType::UnsignedSmall() { | 1009 BitsetType::bitset BitsetType::UnsignedSmall() { |
| 998 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; | 1010 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; |
| 999 } | 1011 } |
| 1000 | 1012 |
| 1001 } // namespace compiler | 1013 } // namespace compiler |
| 1002 } // namespace internal | 1014 } // namespace internal |
| 1003 } // namespace v8 | 1015 } // namespace v8 |
| OLD | NEW |