Index: src/compiler/types.cc |
diff --git a/src/compiler/types.cc b/src/compiler/types.cc |
index 43d2f804837b1ce596b0c8a7235e63dc11b18b49..11c4247f1f526c7cdd8de35abede11d101b9b987 100644 |
--- a/src/compiler/types.cc |
+++ b/src/compiler/types.cc |
@@ -83,6 +83,8 @@ double Type::Min() { |
} |
if (this->IsRange()) return this->AsRange()->Min(); |
if (this->IsConstant()) return this->AsConstant()->Value()->Number(); |
Jarin
2016/10/04 13:14:55
Remove this line, please (Constants should be only
mvstanton
2016/10/05 13:51:10
Done.
|
+ if (this->IsOtherNumberConstant()) |
+ return this->AsOtherNumberConstant()->Value(); |
UNREACHABLE(); |
return 0; |
} |
@@ -99,6 +101,8 @@ double Type::Max() { |
} |
if (this->IsRange()) return this->AsRange()->Max(); |
if (this->IsConstant()) return this->AsConstant()->Value()->Number(); |
Jarin
2016/10/04 13:14:55
Remove.
mvstanton
2016/10/05 13:51:10
Done.
|
+ if (this->IsOtherNumberConstant()) |
+ return this->AsOtherNumberConstant()->Value(); |
UNREACHABLE(); |
return 0; |
} |
@@ -140,6 +144,8 @@ Type::bitset BitsetType::Lub(Type* type) { |
return bitset; |
} |
if (type->IsConstant()) return type->AsConstant()->Lub(); |
+ if (type->IsOtherNumberConstant()) |
+ return type->AsOtherNumberConstant()->Lub(); |
if (type->IsRange()) return type->AsRange()->Lub(); |
if (type->IsTuple()) return kOtherInternal; |
UNREACHABLE(); |
@@ -399,6 +405,14 @@ bool Type::SimplyEquals(Type* that) { |
return that->IsConstant() && |
*this->AsConstant()->Value() == *that->AsConstant()->Value(); |
} |
+ if (this->IsOtherNumberConstant()) { |
+ return that->IsOtherNumberConstant() && |
+ this->AsOtherNumberConstant()->Value() == |
+ that->AsOtherNumberConstant()->Value(); |
+ } |
+ if (this->IsRange()) { |
+ if (that->IsOtherNumberConstant()) return false; |
+ } |
if (this->IsTuple()) { |
if (!that->IsTuple()) return false; |
TupleType* this_tuple = this->AsTuple(); |
@@ -743,6 +757,24 @@ Type* Type::NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone) { |
return RangeType::New(range_min, range_max, zone); |
} |
+Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { |
+ if (IsInteger(*value)) { |
+ double v = value->IsSmi() ? Smi::cast(*value)->value() |
+ : HeapNumber::cast(*value)->value(); |
+ return Range(v, v, zone); |
+ } else if (value->IsHeapNumber()) { |
+ double v = HeapNumber::cast(*value)->value(); |
+ if (i::IsMinusZero(v)) { |
+ return Type::MinusZero(); |
+ } else if (std::isnan(v)) { |
+ return Type::NaN(); |
+ } else if (OtherNumberConstantType::IsOtherNumberConstant(v)) { |
+ return OtherNumberConstant(v, zone); |
+ } |
+ } |
+ return Constant(value, zone); |
+} |
+ |
Type* Type::Union(Type* type1, Type* type2, Zone* zone) { |
// Fast case: bit sets. |
if (type1->IsBitset() && type2->IsBitset()) { |
@@ -833,12 +865,9 @@ Type* Type::NormalizeUnion(Type* union_type, int size, Zone* zone) { |
return union_type; |
} |
-// ----------------------------------------------------------------------------- |
-// Iteration. |
- |
int Type::NumConstants() { |
DisallowHeapAllocation no_allocation; |
- if (this->IsConstant()) { |
+ if (this->IsConstant() || this->IsOtherNumberConstant()) { |
return 1; |
} else if (this->IsUnion()) { |
int result = 0; |
@@ -907,6 +936,9 @@ void Type::PrintTo(std::ostream& os) { |
BitsetType::Print(os, this->AsBitset()); |
} else if (this->IsConstant()) { |
os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")"; |
+ } else if (this->IsOtherNumberConstant()) { |
+ os << "OtherNumberConstant(" << this->AsOtherNumberConstant()->Value() |
+ << ")"; |
} else if (this->IsRange()) { |
std::ostream::fmtflags saved_flags = os.setf(std::ios::fixed); |
std::streamsize saved_precision = os.precision(0); |