Commit 3c9f9851 authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Use unboxed doubles in range types.

BUG=
R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/882063002

Cr-Commit-Position: refs/heads/master@{#26307}
parent b3de173d
......@@ -30,26 +30,23 @@ static void RelaxEffects(Node* node) {
JSTypedLowering::JSTypedLowering(JSGraph* jsgraph, Zone* zone)
: jsgraph_(jsgraph), simplified_(graph()->zone()), conversions_(zone) {
Handle<Object> zero = factory()->NewNumber(0.0);
Handle<Object> one = factory()->NewNumber(1.0);
zero_range_ = Type::Range(zero, zero, graph()->zone());
one_range_ = Type::Range(one, one, graph()->zone());
Handle<Object> thirtyone = factory()->NewNumber(31.0);
zero_thirtyone_range_ = Type::Range(zero, thirtyone, graph()->zone());
zero_range_ = Type::Range(0.0, 1.0, graph()->zone());
one_range_ = Type::Range(1.0, 1.0, graph()->zone());
zero_thirtyone_range_ = Type::Range(0.0, 31.0, graph()->zone());
// TODO(jarin): Can we have a correctification of the stupid type system?
// These stupid work-arounds are just stupid!
shifted_int32_ranges_[0] = Type::Signed32();
if (SmiValuesAre31Bits()) {
shifted_int32_ranges_[1] = Type::SignedSmall();
for (size_t k = 2; k < arraysize(shifted_int32_ranges_); ++k) {
Handle<Object> min = factory()->NewNumber(kMinInt / (1 << k));
Handle<Object> max = factory()->NewNumber(kMaxInt / (1 << k));
double min = kMinInt / (1 << k);
double max = kMaxInt / (1 << k);
shifted_int32_ranges_[k] = Type::Range(min, max, graph()->zone());
}
} else {
for (size_t k = 1; k < arraysize(shifted_int32_ranges_); ++k) {
Handle<Object> min = factory()->NewNumber(kMinInt / (1 << k));
Handle<Object> max = factory()->NewNumber(kMaxInt / (1 << k));
double min = kMinInt / (1 << k);
double max = kMaxInt / (1 << k);
shifted_int32_ranges_[k] = Type::Range(min, max, graph()->zone());
}
}
......
......@@ -75,10 +75,8 @@ class RepresentationSelector {
queue_(zone) {
memset(info_, 0, sizeof(NodeInfo) * count_);
Factory* f = jsgraph->isolate()->factory();
safe_int_additive_range_ =
Type::Range(f->NewNumber(-std::pow(2.0, 52.0)),
f->NewNumber(std::pow(2.0, 52.0)), zone);
Type::Range(-std::pow(2.0, 52.0), std::pow(2.0, 52.0), zone);
}
void Run(SimplifiedLowering* lowering) {
......
This diff is collapsed.
......@@ -65,8 +65,8 @@ class Typer {
Type* random_fun_;
LazyTypeCache* cache_;
ZoneVector<Handle<Object> > weaken_min_limits_;
ZoneVector<Handle<Object> > weaken_max_limits_;
ZoneVector<double> weaken_min_limits_;
ZoneVector<double> weaken_max_limits_;
DISALLOW_COPY_AND_ASSIGN(Typer);
};
......
......@@ -96,7 +96,18 @@ bool ZoneTypeConfig::is_bitset(Type* type) {
// static
bool ZoneTypeConfig::is_struct(Type* type, int tag) {
return !is_bitset(type) && struct_tag(as_struct(type)) == tag;
DCHECK(tag != kRangeStructTag);
if (is_bitset(type)) return false;
int type_tag = struct_tag(as_struct(type));
return type_tag == tag;
}
// static
bool ZoneTypeConfig::is_range(Type* type) {
if (is_bitset(type)) return false;
int type_tag = struct_tag(as_struct(type));
return type_tag == kRangeStructTag;
}
......@@ -120,6 +131,13 @@ ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) {
}
// static
ZoneTypeConfig::Range* ZoneTypeConfig::as_range(Type* type) {
DCHECK(!is_bitset(type));
return reinterpret_cast<Range*>(type);
}
// static
i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) {
UNREACHABLE();
......@@ -146,6 +164,12 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structure) {
}
// static
ZoneTypeConfig::Type* ZoneTypeConfig::from_range(Range* range) {
return reinterpret_cast<Type*>(range);
}
// static
ZoneTypeConfig::Type* ZoneTypeConfig::from_class(
i::Handle<i::Map> map, Zone* zone) {
......@@ -156,6 +180,7 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_class(
// static
ZoneTypeConfig::Struct* ZoneTypeConfig::struct_create(
int tag, int length, Zone* zone) {
DCHECK(tag != kRangeStructTag);
Struct* structure = reinterpret_cast<Struct*>(
zone->New(sizeof(void*) * (length + 2))); // NOLINT
structure[0] = reinterpret_cast<void*>(tag);
......@@ -214,6 +239,45 @@ void ZoneTypeConfig::struct_set_value(
}
// static
ZoneTypeConfig::Range* ZoneTypeConfig::range_create(Zone* zone) {
Range* range = reinterpret_cast<Range*>(zone->New(sizeof(Range))); // NOLINT
range->tag = reinterpret_cast<void*>(kRangeStructTag);
range->bitset = 0;
range->limits[0] = 1;
range->limits[1] = 0;
return range;
}
// static
int ZoneTypeConfig::range_get_bitset(ZoneTypeConfig::Range* range) {
return range->bitset;
}
// static
void ZoneTypeConfig::range_set_bitset(ZoneTypeConfig::Range* range, int value) {
range->bitset = value;
}
// static
double ZoneTypeConfig::range_get_double(ZoneTypeConfig::Range* range,
int index) {
DCHECK(index >= 0 && index < 2);
return range->limits[index];
}
// static
void ZoneTypeConfig::range_set_double(ZoneTypeConfig::Range* range, int index,
double value, Zone*) {
DCHECK(index >= 0 && index < 2);
range->limits[index] = value;
}
// -----------------------------------------------------------------------------
// HeapTypeConfig
......@@ -252,10 +316,17 @@ bool HeapTypeConfig::is_class(Type* type) {
// static
bool HeapTypeConfig::is_struct(Type* type, int tag) {
DCHECK(tag != kRangeStructTag);
return type->IsFixedArray() && struct_tag(as_struct(type)) == tag;
}
// static
bool HeapTypeConfig::is_range(Type* type) {
return type->IsFixedArray() && struct_tag(as_struct(type)) == kRangeStructTag;
}
// static
HeapTypeConfig::Type::bitset HeapTypeConfig::as_bitset(Type* type) {
// TODO(rossberg): Breaks the Smi abstraction. Fix once there is a better way.
......@@ -275,6 +346,12 @@ i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::as_struct(Type* type) {
}
// static
i::Handle<HeapTypeConfig::Range> HeapTypeConfig::as_range(Type* type) {
return i::handle(Range::cast(type));
}
// static
HeapTypeConfig::Type* HeapTypeConfig::from_bitset(Type::bitset bitset) {
// TODO(rossberg): Breaks the Smi abstraction. Fix once there is a better way.
......@@ -303,6 +380,13 @@ i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_struct(
}
// static
i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_range(
i::Handle<Range> range) {
return i::Handle<Type>::cast(i::Handle<Object>::cast(range));
}
// static
i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::struct_create(
int tag, int length, Isolate* isolate) {
......@@ -361,6 +445,46 @@ void HeapTypeConfig::struct_set_value(
structure->set(i + 1, *x);
}
// static
i::Handle<HeapTypeConfig::Range> HeapTypeConfig::range_create(
Isolate* isolate) {
i::Handle<Range> range = isolate->factory()->NewFixedArray(4);
range->set(0, i::Smi::FromInt(kRangeStructTag));
return range;
}
// static
int HeapTypeConfig::range_get_bitset(i::Handle<HeapTypeConfig::Range> range) {
Type* v = static_cast<Type*>(range->get(1));
return as_bitset(v);
}
// static
void HeapTypeConfig::range_set_bitset(i::Handle<HeapTypeConfig::Range> range,
int value) {
range->set(1, from_bitset(value));
}
// static
double HeapTypeConfig::range_get_double(i::Handle<HeapTypeConfig::Range> range,
int index) {
DCHECK(index >= 0 && index < 2);
return range->get(index + 2)->Number();
}
// static
void HeapTypeConfig::range_set_double(i::Handle<HeapTypeConfig::Range> range,
int index, double value,
Isolate* isolate) {
DCHECK(index >= 0 && index < 2);
i::Handle<Object> number = isolate->factory()->NewNumber(value);
range->set(index + 2, *number);
}
} } // namespace v8::internal
#endif // V8_TYPES_INL_H_
......@@ -26,8 +26,8 @@ typename TypeImpl<Config>::Limits TypeImpl<Config>::Intersect(
Limits lhs, Limits rhs) {
DisallowHeapAllocation no_allocation;
Limits result(lhs);
if (lhs.min->Number() < rhs.min->Number()) result.min = rhs.min;
if (lhs.max->Number() > rhs.max->Number()) result.max = rhs.max;
if (lhs.min < rhs.min) result.min = rhs.min;
if (lhs.max > rhs.max) result.max = rhs.max;
result.representation = lhs.representation & rhs.representation;
return result;
}
......@@ -35,7 +35,7 @@ typename TypeImpl<Config>::Limits TypeImpl<Config>::Intersect(
template <class Config>
bool TypeImpl<Config>::IsEmpty(Limits lim) {
return lim.min->Number() > lim.max->Number();
return lim.min > lim.max;
}
......@@ -44,8 +44,8 @@ typename TypeImpl<Config>::Limits TypeImpl<Config>::Union(Limits lhs,
Limits rhs) {
DisallowHeapAllocation no_allocation;
Limits result(lhs);
if (lhs.min->Number() > rhs.min->Number()) result.min = rhs.min;
if (lhs.max->Number() < rhs.max->Number()) result.max = rhs.max;
if (lhs.min > rhs.min) result.min = rhs.min;
if (lhs.max < rhs.max) result.max = rhs.max;
result.representation = lhs.representation | rhs.representation;
return result;
}
......@@ -57,7 +57,7 @@ bool TypeImpl<Config>::Overlap(
typename TypeImpl<Config>::RangeType* rhs) {
DisallowHeapAllocation no_allocation;
typename TypeImpl<Config>::Limits lim = Intersect(Limits(lhs), Limits(rhs));
return lim.min->Number() <= lim.max->Number();
return lim.min <= lim.max;
}
......@@ -66,9 +66,8 @@ bool TypeImpl<Config>::Contains(
typename TypeImpl<Config>::RangeType* lhs,
typename TypeImpl<Config>::RangeType* rhs) {
DisallowHeapAllocation no_allocation;
return rhs->Bound()->Is(lhs->Bound()) &&
lhs->Min()->Number() <= rhs->Min()->Number() &&
rhs->Max()->Number() <= lhs->Max()->Number();
return BitsetType::Is(rhs->Bound(), lhs->Bound()) &&
lhs->Min() <= rhs->Min() && rhs->Max() <= lhs->Max();
}
......@@ -76,9 +75,10 @@ template <class Config>
bool TypeImpl<Config>::Contains(typename TypeImpl<Config>::RangeType* lhs,
typename TypeImpl<Config>::ConstantType* rhs) {
DisallowHeapAllocation no_allocation;
return IsInteger(*rhs->Value()) && rhs->Bound()->Is(lhs->Bound()) &&
lhs->Min()->Number() <= rhs->Value()->Number() &&
rhs->Value()->Number() <= lhs->Max()->Number();
return IsInteger(*rhs->Value()) &&
BitsetType::Is(rhs->Bound()->AsBitset(), lhs->Bound()) &&
lhs->Min() <= rhs->Value()->Number() &&
rhs->Value()->Number() <= lhs->Max();
}
......@@ -87,9 +87,8 @@ bool TypeImpl<Config>::Contains(
typename TypeImpl<Config>::RangeType* range, i::Object* val) {
DisallowHeapAllocation no_allocation;
return IsInteger(val) &&
BitsetType::Is(BitsetType::Lub(val), range->Bound()->AsBitset()) &&
range->Min()->Number() <= val->Number() &&
val->Number() <= range->Max()->Number();
BitsetType::Is(BitsetType::Lub(val), range->Bound()) &&
range->Min() <= val->Number() && val->Number() <= range->Max();
}
......@@ -107,7 +106,7 @@ double TypeImpl<Config>::Min() {
}
return min;
}
if (this->IsRange()) return this->AsRange()->Min()->Number();
if (this->IsRange()) return this->AsRange()->Min();
if (this->IsConstant()) return this->AsConstant()->Value()->Number();
UNREACHABLE();
return 0;
......@@ -125,7 +124,7 @@ double TypeImpl<Config>::Max() {
}
return max;
}
if (this->IsRange()) return this->AsRange()->Max()->Number();
if (this->IsRange()) return this->AsRange()->Max();
if (this->IsConstant()) return this->AsConstant()->Value()->Number();
UNREACHABLE();
return 0;
......@@ -148,8 +147,8 @@ TypeImpl<Config>::BitsetType::Glb(TypeImpl* type) {
return type->AsUnion()->Get(0)->BitsetGlb() |
type->AsUnion()->Get(1)->BitsetGlb(); // Shortcut.
} else if (type->IsRange()) {
bitset glb = SEMANTIC(BitsetType::Glb(type->AsRange()->Min()->Number(),
type->AsRange()->Max()->Number()));
bitset glb = SEMANTIC(
BitsetType::Glb(type->AsRange()->Min(), type->AsRange()->Max()));
if (glb == 0) {
return kNone;
} else {
......@@ -181,7 +180,7 @@ TypeImpl<Config>::BitsetType::Lub(TypeImpl* type) {
type->AsClass()->Bound(NULL)->AsBitset();
}
if (type->IsConstant()) return type->AsConstant()->Bound()->AsBitset();
if (type->IsRange()) return type->AsRange()->Bound()->AsBitset();
if (type->IsRange()) return type->AsRange()->Bound();
if (type->IsContext()) return kInternal & kTaggedPointer;
if (type->IsArray()) return kArray;
if (type->IsFunction()) return kOtherObject; // TODO(rossberg): kFunction
......@@ -765,13 +764,7 @@ typename TypeImpl<Config>::Limits TypeImpl<Config>::ToLimits(bitset bits,
return Limits::Empty(region);
}
double bitset_min = BitsetType::Min(number_bits);
double bitset_max = BitsetType::Max(number_bits);
// TODO(jarin) Get rid of the heap numbers.
i::Factory* f = i::Isolate::Current()->factory();
return Limits(f->NewNumber(bitset_min), f->NewNumber(bitset_max),
return Limits(BitsetType::Min(number_bits), BitsetType::Max(number_bits),
representation);
}
......@@ -874,10 +867,8 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeRangeAndBitset(
double bitset_min = BitsetType::Min(number_bits);
double bitset_max = BitsetType::Max(number_bits);
i::Handle<i::Object> range_min_obj = range->Min();
i::Handle<i::Object> range_max_obj = range->Max();
double range_min = range_min_obj->Number();
double range_max = range_max_obj->Number();
double range_min = range->Min();
double range_max = range->Max();
bitset range_representation = REPRESENTATION(range->BitsetLub());
bitset bits_representation = REPRESENTATION(*bits);
......@@ -897,14 +888,12 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeRangeAndBitset(
}
if (bitset_min < range_min) {
// TODO(jarin) Get rid of the heap numbers.
range_min_obj = i::Isolate::Current()->factory()->NewNumber(bitset_min);
range_min = bitset_min;
}
if (bitset_max > range_max) {
// TODO(jarin) Get rid of the heap numbers.
range_max_obj = i::Isolate::Current()->factory()->NewNumber(bitset_max);
range_max = bitset_max;
}
return RangeType::New(range_min_obj, range_max_obj,
return RangeType::New(range_min, range_max,
BitsetType::New(representation, region), region);
}
......@@ -1227,8 +1216,8 @@ void TypeImpl<Config>::PrintTo(std::ostream& os, PrintDimension dim) {
} else if (this->IsRange()) {
std::ostream::fmtflags saved_flags = os.setf(std::ios::fixed);
std::streamsize saved_precision = os.precision(0);
os << "Range(" << this->AsRange()->Min()->Number() << ", "
<< this->AsRange()->Max()->Number() << ")";
os << "Range(" << this->AsRange()->Min() << ", " << this->AsRange()->Max()
<< ")";
os.flags(saved_flags);
os.precision(saved_precision);
} else if (this->IsContext()) {
......
This diff is collapsed.
......@@ -972,11 +972,8 @@ TEST(LowerNumberCmp_to_float64) {
TEST(LowerNumberAddSub_to_int32) {
HandleAndZoneScope scope;
Factory* f = scope.main_isolate()->factory();
Type* small_range =
Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone());
Type* large_range =
Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone());
Type* small_range = Type::Range(1, 10, scope.main_zone());
Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone());
static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range,
large_range};
......@@ -996,11 +993,8 @@ TEST(LowerNumberAddSub_to_int32) {
TEST(LowerNumberAddSub_to_uint32) {
HandleAndZoneScope scope;
Factory* f = scope.main_isolate()->factory();
Type* small_range =
Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone());
Type* large_range =
Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone());
Type* small_range = Type::Range(1, 10, scope.main_zone());
Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone());
static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range,
large_range};
......
......@@ -87,11 +87,8 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
}
Type* NewRange(double i, double j) {
Factory* f = isolate()->factory();
i::Handle<i::Object> min = f->NewNumber(i);
i::Handle<i::Object> max = f->NewNumber(j);
if (min->Number() > max->Number()) std::swap(min, max);
return Type::Range(min, max, main_zone());
if (i > j) std::swap(i, j);
return Type::Range(i, j, main_zone());
}
double RandomInt(double min, double max) {
......@@ -113,7 +110,7 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
}
double RandomInt(Type::RangeType* range) {
return RandomInt(range->Min()->Number(), range->Max()->Number());
return RandomInt(range->Min(), range->Max());
}
// Careful, this function runs O(max_width^5) trials.
......
......@@ -36,7 +36,8 @@ struct ZoneRep {
return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag;
}
static bool IsBitset(Type* t) { return reinterpret_cast<uintptr_t>(t) & 1; }
static bool IsUnion(Type* t) { return IsStruct(t, 6); }
// HACK: the number 5 below is the value of StructuralType::kUnionTag.
static bool IsUnion(Type* t) { return t->IsUnionForTesting(); }
static Struct* AsStruct(Type* t) {
return reinterpret_cast<Struct*>(t);
......@@ -69,7 +70,8 @@ struct HeapRep {
return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag;
}
static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); }
static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 6); }
// HACK: the number 5 below is the value of StructuralType::kUnionTag.
static bool IsUnion(Handle<HeapType> t) { return t->IsUnionForTesting(); }
static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); }
static bitset AsBitset(Handle<HeapType> t) {
......@@ -351,9 +353,9 @@ struct Tests : Rep {
// Constructor
for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) {
for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) {
i::Handle<i::Object> min = *i;
i::Handle<i::Object> max = *j;
if (min->Number() > max->Number()) std::swap(min, max);
double min = (*i)->Number();
double max = (*j)->Number();
if (min > max) std::swap(min, max);
TypeHandle type = T.Range(min, max);
CHECK(type->IsRange());
}
......@@ -362,12 +364,12 @@ struct Tests : Rep {
// Range attributes
for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) {
for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) {
i::Handle<i::Object> min = *i;
i::Handle<i::Object> max = *j;
if (min->Number() > max->Number()) std::swap(min, max);
double min = (*i)->Number();
double max = (*j)->Number();
if (min > max) std::swap(min, max);
TypeHandle type = T.Range(min, max);
CHECK(*min == *type->AsRange()->Min());
CHECK(*max == *type->AsRange()->Max());
CHECK(min == type->AsRange()->Min());
CHECK(max == type->AsRange()->Max());
}
}
......@@ -381,15 +383,15 @@ struct Tests : Rep {
i2 != T.integers.end(); ++i2) {
for (ValueIterator j2 = i2;
j2 != T.integers.end(); ++j2) {
i::Handle<i::Object> min1 = *i1;
i::Handle<i::Object> max1 = *j1;
i::Handle<i::Object> min2 = *i2;
i::Handle<i::Object> max2 = *j2;
if (min1->Number() > max1->Number()) std::swap(min1, max1);
if (min2->Number() > max2->Number()) std::swap(min2, max2);
double min1 = (*i1)->Number();
double max1 = (*j1)->Number();
double min2 = (*i2)->Number();
double max2 = (*j2)->Number();
if (min1 > max1) std::swap(min1, max1);
if (min2 > max2) std::swap(min2, max2);
TypeHandle type1 = T.Range(min1, max1);
TypeHandle type2 = T.Range(min2, max2);
CHECK(Equal(type1, type2) == (*min1 == *min2 && *max1 == *max2));
CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2));
}
}
}
......@@ -608,8 +610,6 @@ struct Tests : Rep {
}
void MinMax() {
Factory* fac = isolate->factory();
// If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b).
// TODO(neis): Need to ignore representation for this to be true.
/*
......@@ -662,8 +662,7 @@ struct Tests : Rep {
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
TypeHandle type = *it;
CHECK(!(type->Is(T.Integer) && !type->Is(T.None)) ||
type->Is(T.Range(fac->NewNumber(type->Min()),
fac->NewNumber(type->Max()))));
type->Is(T.Range(type->Min(), type->Max())));
}
}
......@@ -828,17 +827,15 @@ struct Tests : Rep {
i2 != T.integers.end(); ++i2) {
for (ValueIterator j2 = i2;
j2 != T.integers.end(); ++j2) {
i::Handle<i::Object> min1 = *i1;
i::Handle<i::Object> max1 = *j1;
i::Handle<i::Object> min2 = *i2;
i::Handle<i::Object> max2 = *j2;
if (min1->Number() > max1->Number()) std::swap(min1, max1);
if (min2->Number() > max2->Number()) std::swap(min2, max2);
double min1 = (*i1)->Number();
double max1 = (*j1)->Number();
double min2 = (*i2)->Number();
double max2 = (*j2)->Number();
if (min1 > max1) std::swap(min1, max1);
if (min2 > max2) std::swap(min2, max2);
TypeHandle type1 = T.Range(min1, max1);
TypeHandle type2 = T.Range(min2, max2);
CHECK(type1->Is(type2) ==
(min1->Number() >= min2->Number() &&
max1->Number() <= max2->Number()));
CHECK(type1->Is(type2) == (min1 >= min2 && max1 <= max2));
}
}
}
......@@ -898,8 +895,8 @@ struct Tests : Rep {
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
TypeHandle type = *it;
if (type->IsConstant() && IsInteger(*type->AsConstant()->Value())) {
CHECK(type->Is(
T.Range(type->AsConstant()->Value(), type->AsConstant()->Value())));
CHECK(type->Is(T.Range(type->AsConstant()->Value()->Number(),
type->AsConstant()->Value()->Number())));
}
}
......@@ -910,8 +907,8 @@ struct Tests : Rep {
TypeHandle type2 = *it2;
if (type1->IsConstant() && type2->IsRange() && type1->Is(type2)) {
double x = type1->AsConstant()->Value()->Number();
double min = type2->AsRange()->Min()->Number();
double max = type2->AsRange()->Max()->Number();
double min = type2->AsRange()->Min();
double max = type2->AsRange()->Max();
CHECK(IsInteger(x) && min <= x && x <= max);
}
}
......@@ -1848,8 +1845,8 @@ struct Tests : Rep {
TypeHandle type1 = *it1;
if (type1->IsRange()) {
typename Type::RangeType* range = type1->GetRange();
CHECK(type1->Min() == range->Min()->Number());
CHECK(type1->Max() == range->Max()->Number());
CHECK(type1->Min() == range->Min());
CHECK(type1->Max() == range->Max());
}
}
......@@ -1861,8 +1858,8 @@ struct Tests : Rep {
if (type1->IsConstant() && type2->IsRange()) {
TypeHandle u = T.Union(type1, type2);
CHECK(type2->Min() == u->GetRange()->Min()->Number());
CHECK(type2->Max() == u->GetRange()->Max()->Number());
CHECK(type2->Min() == u->GetRange()->Min());
CHECK(type2->Max() == u->GetRange()->Max());
}
}
}
......
......@@ -101,8 +101,7 @@ class Types {
if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x));
}
Integer = Type::Range(isolate->factory()->NewNumber(-V8_INFINITY),
isolate->factory()->NewNumber(+V8_INFINITY), region);
Integer = Type::Range(-V8_INFINITY, +V8_INFINITY, region);
NumberArray = Type::Array(Number, region);
StringArray = Type::Array(String, region);
......@@ -184,7 +183,7 @@ class Types {
return Type::Constant(value, region_);
}
TypeHandle Range(Handle<i::Object> min, Handle<i::Object> max) {
TypeHandle Range(double min, double max) {
return Type::Range(min, max, region_);
}
......@@ -263,9 +262,9 @@ class Types {
case 3: { // range
int i = rng_->NextInt(static_cast<int>(integers.size()));
int j = rng_->NextInt(static_cast<int>(integers.size()));
i::Handle<i::Object> min = integers[i];
i::Handle<i::Object> max = integers[j];
if (min->Number() > max->Number()) std::swap(min, max);
double min = integers[i]->Number();
double max = integers[j]->Number();
if (min > max) std::swap(min, max);
return Type::Range(min, max, region_);
}
case 4: { // context
......
......@@ -119,7 +119,6 @@ TEST_F(JSTypedLoweringTest, JSUnaryNotWithBoolean) {
TEST_F(JSTypedLoweringTest, JSUnaryNotWithFalsish) {
Handle<Object> zero = factory()->NewNumber(0);
Node* input = Parameter(
Type::Union(
Type::MinusZero(),
......@@ -133,7 +132,7 @@ TEST_F(JSTypedLoweringTest, JSUnaryNotWithFalsish) {
Type::Undetectable(),
Type::Union(
Type::Constant(factory()->false_value(), zone()),
Type::Range(zero, zero, zone()), zone()),
Type::Range(0.0, 0.0, zone()), zone()),
zone()),
zone()),
zone()),
......@@ -164,9 +163,7 @@ TEST_F(JSTypedLoweringTest, JSUnaryNotWithTruish) {
TEST_F(JSTypedLoweringTest, JSUnaryNotWithNonZeroPlainNumber) {
Node* input = Parameter(
Type::Range(factory()->NewNumber(1), factory()->NewNumber(42), zone()),
0);
Node* input = Parameter(Type::Range(1.0, 42.0, zone()), 0);
Node* context = Parameter(Type::Any(), 1);
Reduction r =
Reduce(graph()->NewNode(javascript()->UnaryNot(), input, context));
......@@ -259,8 +256,7 @@ TEST_F(JSTypedLoweringTest, ParameterWithPlainNumber) {
EXPECT_THAT(r.replacement(), IsNumberConstant(value));
}
TRACED_FOREACH(double, value, kIntegerValues) {
Handle<Object> constant = factory()->NewNumber(value);
Reduction r = Reduce(Parameter(Type::Range(constant, constant, zone())));
Reduction r = Reduce(Parameter(Type::Range(value, value, zone())));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsNumberConstant(value));
}
......@@ -299,7 +295,6 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithBoolean) {
TEST_F(JSTypedLoweringTest, JSToBooleanWithFalsish) {
Handle<Object> zero = factory()->NewNumber(0);
Node* input = Parameter(
Type::Union(
Type::MinusZero(),
......@@ -313,7 +308,7 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithFalsish) {
Type::Undetectable(),
Type::Union(
Type::Constant(factory()->false_value(), zone()),
Type::Range(zero, zero, zone()), zone()),
Type::Range(0.0, 0.0, zone()), zone()),
zone()),
zone()),
zone()),
......@@ -344,10 +339,7 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithTruish) {
TEST_F(JSTypedLoweringTest, JSToBooleanWithNonZeroPlainNumber) {
Node* input =
Parameter(Type::Range(factory()->NewNumber(1),
factory()->NewNumber(V8_INFINITY), zone()),
0);
Node* input = Parameter(Type::Range(1, V8_INFINITY, zone()), 0);
Node* context = Parameter(Type::Any(), 1);
Reduction r =
Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
......@@ -593,8 +585,7 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
int const element_size = static_cast<int>(array->element_size());
Node* key = Parameter(
Type::Range(factory()->NewNumber(kMinInt / element_size),
factory()->NewNumber(kMaxInt / element_size), zone()));
Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
Node* base = HeapConstant(array);
Node* context = UndefinedConstant();
Node* effect = graph()->start();
......@@ -640,8 +631,7 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
int min = random_number_generator()->NextInt(static_cast<int>(kLength));
int max = random_number_generator()->NextInt(static_cast<int>(kLength));
if (min > max) std::swap(min, max);
Node* key = Parameter(Type::Range(factory()->NewNumber(min),
factory()->NewNumber(max), zone()));
Node* key = Parameter(Type::Range(min, max, zone()));
Node* base = HeapConstant(array);
Node* context = UndefinedConstant();
Node* effect = graph()->start();
......@@ -681,8 +671,7 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
int const element_size = static_cast<int>(array->element_size());
Node* key = Parameter(
Type::Range(factory()->NewNumber(kMinInt / element_size),
factory()->NewNumber(kMaxInt / element_size), zone()));
Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
Node* base = HeapConstant(array);
Node* value =
Parameter(AccessBuilder::ForTypedArrayElement(type, true).type);
......@@ -728,8 +717,7 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) {
int const element_size = static_cast<int>(array->element_size());
Node* key = Parameter(
Type::Range(factory()->NewNumber(kMinInt / element_size),
factory()->NewNumber(kMaxInt / element_size), zone()));
Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
Node* base = HeapConstant(array);
Node* value = Parameter(Type::Any());
Node* context = UndefinedConstant();
......@@ -787,8 +775,7 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) {
int min = random_number_generator()->NextInt(static_cast<int>(kLength));
int max = random_number_generator()->NextInt(static_cast<int>(kLength));
if (min > max) std::swap(min, max);
Node* key = Parameter(Type::Range(factory()->NewNumber(min),
factory()->NewNumber(max), zone()));
Node* key = Parameter(Type::Range(min, max, zone()));
Node* base = HeapConstant(array);
Node* value = Parameter(access.type);
Node* context = UndefinedConstant();
......
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