Commit 9686d081 authored by mvstanton's avatar mvstanton Committed by Commit bot

[turbofan] Type::Contains() and Constants() is unnecessary.

Cleanup.

BUG=

Review-Url: https://codereview.chromium.org/2379573002
Cr-Commit-Position: refs/heads/master@{#39830}
parent da33b67a
......@@ -516,18 +516,6 @@ Type* Type::GetRange() {
return NULL;
}
bool Type::Contains(i::Object* value) {
DisallowHeapAllocation no_allocation;
for (Iterator<i::Object> it = this->Constants(); !it.Done(); it.Advance()) {
if (*it.Current() == value) return true;
}
if (IsInteger(value)) {
Type* range = this->GetRange();
if (range != NULL && Contains(range->AsRange(), value)) return true;
}
return BitsetType::New(BitsetType::Lub(value))->Is(this);
}
bool UnionType::Wellformed() {
DisallowHeapAllocation no_allocation;
// This checks the invariants of the union representation:
......@@ -863,52 +851,6 @@ int Type::NumConstants() {
}
}
template <class T>
Type* Type::Iterator<T>::get_type() {
DCHECK(!Done());
return type_->IsUnion() ? type_->AsUnion()->Get(index_) : type_;
}
// C++ cannot specialise nested templates, so we have to go through this
// contortion with an auxiliary template to simulate it.
template <class T>
struct TypeImplIteratorAux {
static bool matches(Type* type);
static i::Handle<T> current(Type* type);
};
template <>
struct TypeImplIteratorAux<i::Object> {
static bool matches(Type* type) { return type->IsConstant(); }
static i::Handle<i::Object> current(Type* type) {
return type->AsConstant()->Value();
}
};
template <class T>
bool Type::Iterator<T>::matches(Type* type) {
return TypeImplIteratorAux<T>::matches(type);
}
template <class T>
i::Handle<T> Type::Iterator<T>::Current() {
return TypeImplIteratorAux<T>::current(get_type());
}
template <class T>
void Type::Iterator<T>::Advance() {
DisallowHeapAllocation no_allocation;
++index_;
if (type_->IsUnion()) {
for (int n = type_->AsUnion()->Length(); index_ < n; ++index_) {
if (matches(type_->AsUnion()->Get(index_))) return;
}
} else if (index_ == 0 && matches(type_)) {
return;
}
index_ = -1;
}
// -----------------------------------------------------------------------------
// Printing.
......@@ -1014,11 +956,6 @@ BitsetType::bitset BitsetType::UnsignedSmall() {
return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31;
}
// -----------------------------------------------------------------------------
// Instantiations.
template class Type::Iterator<i::Object>;
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -513,10 +513,6 @@ class Type {
bool Maybe(Type* that);
bool Equals(Type* that) { return this->Is(that) && that->Is(this); }
// Equivalent to Constant(val)->Is(this), but avoiding allocation.
bool Contains(i::Object* val);
bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); }
// Inspection.
bool IsRange() { return IsKind(TypeBase::kRange); }
bool IsConstant() { return IsKind(TypeBase::kConstant); }
......@@ -544,31 +540,6 @@ class Type {
int NumConstants();
template <class T>
class Iterator {
public:
bool Done() const { return index_ < 0; }
i::Handle<T> Current();
void Advance();
private:
friend class Type;
Iterator() : index_(-1) {}
explicit Iterator(Type* type) : type_(type), index_(-1) { Advance(); }
inline bool matches(Type* type);
inline Type* get_type();
Type* type_;
int index_;
};
Iterator<i::Object> Constants() {
if (this->IsBitset()) return Iterator<i::Object>();
return Iterator<i::Object>(this);
}
// Printing.
void PrintTo(std::ostream& os);
......
......@@ -649,18 +649,6 @@ struct Tests {
CheckUnordered(T.UninitializedConstant, T.Undefined);
}
void Contains() {
// T->Contains(V) iff Constant(V)->Is(T)
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) {
Type* type = *it;
Handle<i::Object> value = *vt;
Type* const_type = T.Constant(value);
CHECK(type->Contains(value) == const_type->Is(type));
}
}
}
void Maybe() {
// T->Maybe(Any) iff T inhabited
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
......@@ -1105,8 +1093,6 @@ TEST(Is1) { Tests().Is1(); }
TEST(Is2) { Tests().Is2(); }
TEST(Contains) { Tests().Contains(); }
TEST(Maybe) { Tests().Maybe(); }
TEST(Union1) { Tests().Union1(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment