Chromium Code Reviews| Index: src/types.cc |
| diff --git a/src/types.cc b/src/types.cc |
| index c4e32f7823e6a15ac684a163c864b5de929bcc25..125fd02875239a2ce63a96e9ed4384c630452c68 100644 |
| --- a/src/types.cc |
| +++ b/src/types.cc |
| @@ -65,6 +65,8 @@ int TypeImpl<Config>::BitsetType::Lub(TypeImpl* type) { |
| type->AsClass()->Bound(NULL)->AsBitset(); |
| } else if (type->IsConstant()) { |
| return type->AsConstant()->Bound()->AsBitset(); |
| + } else if (type->IsRange()) { |
| + return type->AsRange()->Bound()->AsBitset(); |
| } else if (type->IsContext()) { |
| return type->AsContext()->Bound()->AsBitset(); |
| } else if (type->IsArray()) { |
| @@ -95,6 +97,9 @@ int TypeImpl<Config>::BitsetType::InherentLub(TypeImpl* type) { |
| return Lub(*type->AsClass()->Map()); |
| } else if (type->IsConstant()) { |
| return Lub(*type->AsConstant()->Value()); |
| + } else if (type->IsRange()) { |
| + return RangeType::InherentLub( |
| + type->AsRange()->Min(), type->AsRange()->Max()); |
| } else if (type->IsContext()) { |
| return kInternal & kTaggedPtr; |
| } else if (type->IsArray()) { |
| @@ -274,8 +279,14 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
| } |
| if (that->IsConstant()) { |
| return this->IsConstant() |
| - && *this->AsConstant()->Value() == *that->AsConstant()->Value() |
| - && this->AsConstant()->Bound()->Is(that->AsConstant()->Bound()); |
| + && this->AsConstant()->Bound()->Is(that->AsConstant()->Bound()) |
| + && *this->AsConstant()->Value() == *that->AsConstant()->Value(); |
|
rossberg
2014/08/05 14:49:15
Check value first, since that is faster.
neis
2014/08/06 13:15:01
Done.
|
| + } |
| + if (that->IsRange()) { |
| + return this->IsRange() |
| + && this->AsRange()->Bound()->Is(that->AsRange()->Bound()) |
| + && RangeType::le(that->AsRange()->Min(), this->AsRange()->Min()) |
| + && RangeType::le(this->AsRange()->Max(), that->AsRange()->Max()); |
| } |
| if (that->IsContext()) { |
| return this->IsContext() |
| @@ -409,6 +420,12 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) { |
| template<class Config> |
| bool TypeImpl<Config>::Contains(i::Object* value) { |
| DisallowHeapAllocation no_allocation; |
| + if (this->IsRange()) { |
| + return value->IsNumber() && |
| + RangeType::le(this->AsRange()->Min(), value->Number()) && |
| + RangeType::le(value->Number(), this->AsRange()->Max()) && |
| + BitsetType::Is(BitsetType::Lub(value), this->BitsetLub()); |
| + } |
| for (Iterator<i::Object> it = this->Constants(); !it.Done(); it.Advance()) { |
| if (*it.Current() == value) return true; |
| } |
| @@ -441,6 +458,9 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Rebound( |
| return ClassType::New(this->AsClass()->Map(), bound, region); |
| } else if (this->IsConstant()) { |
| return ConstantType::New(this->AsConstant()->Value(), bound, region); |
| + } else if (this->IsRange()) { |
| + return RangeType::New( |
| + this->AsRange()->Min(), this->AsRange()->Max(), bound, region); |
| } else if (this->IsContext()) { |
| return ContextType::New(this->AsContext()->Outer(), bound, region); |
| } else if (this->IsArray()) { |
| @@ -529,8 +549,8 @@ int TypeImpl<Config>::ExtendUnion( |
| } |
| } |
| } else if (!type->IsBitset()) { |
| - DCHECK(type->IsClass() || type->IsConstant() || |
| - type->IsArray() || type->IsFunction() || type->IsContext()); |
| + DCHECK(type->IsClass() || type->IsConstant() || type->IsRange() || |
| + type->IsContext() || type->IsArray() || type->IsFunction()); |
| int inherent_bound = type->InherentBitsetLub(); |
| int old_bound = type->BitsetLub(); |
| int other_bound = type->BoundBy(other->unhandle()) & inherent_bound; |
| @@ -797,6 +817,10 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert( |
| return ConstantType::New( |
| type->AsConstant()->Value(), |
| Convert<OtherType>(type->AsConstant()->Bound(), region), region); |
| + } else if (type->IsRange()) { |
| + return RangeType::New( |
| + type->AsRange()->Min(), type->AsRange()->Max(), |
| + Convert<OtherType>(type->AsRange()->Bound(), region), region); |
| } else if (type->IsContext()) { |
| TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region); |
| return ContextType::New(outer, region); |