Index: src/compiler/typer.cc |
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc |
index 6bde0c02fdb30497dfbedfd4f5f3af2b6cb3d24c..39267c9af019a71109ad38248d00cbfc322d0799 100644 |
--- a/src/compiler/typer.cc |
+++ b/src/compiler/typer.cc |
@@ -129,8 +129,7 @@ class LazyTypeCache FINAL : public ZoneObject { |
} |
Type* CreateRange(double min, double max) const { |
- return Type::Range(factory()->NewNumber(min), factory()->NewNumber(max), |
- zone()); |
+ return Type::Range(min, max, zone()); |
} |
Factory* factory() const { return isolate()->factory(); } |
@@ -164,8 +163,6 @@ Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) |
Zone* zone = this->zone(); |
Factory* f = isolate->factory(); |
- Handle<Object> zero = f->NewNumber(0); |
- Handle<Object> one = f->NewNumber(1); |
Handle<Object> infinity = f->NewNumber(+V8_INFINITY); |
Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY); |
@@ -183,8 +180,8 @@ Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) |
undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone); |
singleton_false = Type::Constant(f->false_value(), zone); |
singleton_true = Type::Constant(f->true_value(), zone); |
- singleton_zero = Type::Range(zero, zero, zone); |
- singleton_one = Type::Range(one, one, zone); |
+ singleton_zero = Type::Range(0.0, 0.0, zone); |
+ singleton_one = Type::Range(1.0, 1.0, zone); |
zero_or_one = Type::Union(singleton_zero, singleton_one, zone); |
zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); |
signed32ish = Type::Union(signed32, truncating_to_zero, zone); |
@@ -196,7 +193,7 @@ Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) |
truish = Type::Union( |
singleton_true, |
Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone); |
- integer = Type::Range(minusinfinity, infinity, zone); |
+ integer = Type::Range(-V8_INFINITY, V8_INFINITY, zone); |
weakint = Type::Union(integer, nan_or_minuszero, zone); |
number_fun0_ = Type::Function(number, zone); |
@@ -212,11 +209,11 @@ Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) |
weaken_max_limits_.reserve(limits_count + 1); |
double limit = 1 << 30; |
- weaken_min_limits_.push_back(f->NewNumber(0)); |
- weaken_max_limits_.push_back(f->NewNumber(0)); |
+ weaken_min_limits_.push_back(0); |
+ weaken_max_limits_.push_back(0); |
for (int i = 0; i < limits_count; i++) { |
- weaken_min_limits_.push_back(f->NewNumber(-limit)); |
- weaken_max_limits_.push_back(f->NewNumber(limit - 1)); |
+ weaken_min_limits_.push_back(-limit); |
+ weaken_max_limits_.push_back(limit - 1); |
limit *= 2; |
} |
@@ -496,8 +493,7 @@ Type* Typer::Visitor::Rangify(Type* type, Typer* t) { |
DCHECK(std::isnan(max)); |
return type; |
} |
- Factory* f = t->isolate()->factory(); |
- return Type::Range(f->NewNumber(min), f->NewNumber(max), t->zone()); |
+ return Type::Range(min, max, t->zone()); |
} |
@@ -610,8 +606,7 @@ Bounds Typer::Visitor::TypeOsrValue(Node* node) { |
Bounds Typer::Visitor::TypeInt32Constant(Node* node) { |
- Factory* f = isolate()->factory(); |
- Handle<Object> number = f->NewNumber(OpParameter<int32_t>(node)); |
+ double number = OpParameter<int32_t>(node); |
return Bounds(Type::Intersect( |
Type::Range(number, number, zone()), Type::UntaggedSigned32(), zone())); |
} |
@@ -826,7 +821,6 @@ Type* Typer::Visitor::JSGreaterThanOrEqualTyper( |
Type* Typer::Visitor::JSBitwiseOrTyper(Type* lhs, Type* rhs, Typer* t) { |
- Factory* f = t->isolate()->factory(); |
lhs = NumberToInt32(ToNumber(lhs, t), t); |
rhs = NumberToInt32(ToNumber(rhs, t), t); |
double lmin = lhs->Min(); |
@@ -854,13 +848,12 @@ Type* Typer::Visitor::JSBitwiseOrTyper(Type* lhs, Type* rhs, Typer* t) { |
// value. |
max = std::min(max, -1.0); |
} |
- return Type::Range(f->NewNumber(min), f->NewNumber(max), t->zone()); |
+ return Type::Range(min, max, t->zone()); |
// TODO(neis): Be precise for singleton inputs, here and elsewhere. |
} |
Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) { |
- Factory* f = t->isolate()->factory(); |
lhs = NumberToInt32(ToNumber(lhs, t), t); |
rhs = NumberToInt32(ToNumber(rhs, t), t); |
double lmin = lhs->Min(); |
@@ -882,7 +875,7 @@ Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) { |
min = 0; |
max = std::min(max, rmax); |
} |
- return Type::Range(f->NewNumber(min), f->NewNumber(max), t->zone()); |
+ return Type::Range(min, max, t->zone()); |
} |
@@ -942,8 +935,7 @@ Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { |
// TODO(jarin) Ideally, the following micro-optimization should be performed |
// by the type constructor. |
if (max != Type::Signed32()->Max() || min != Type::Signed32()->Min()) { |
- Factory* f = t->isolate()->factory(); |
- return Type::Range(f->NewNumber(min), f->NewNumber(max), t->zone()); |
+ return Type::Range(min, max, t->zone()); |
} |
return Type::Signed32(); |
} |
@@ -951,11 +943,8 @@ Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { |
Type* Typer::Visitor::JSShiftRightLogicalTyper(Type* lhs, Type* rhs, Typer* t) { |
lhs = NumberToUint32(ToNumber(lhs, t), t); |
- Factory* f = t->isolate()->factory(); |
// Logical right-shifting any value cannot make it larger. |
- Handle<Object> min = f->NewNumber(0); |
- Handle<Object> max = f->NewNumber(lhs->Max()); |
- return Type::Range(min, max, t->zone()); |
+ return Type::Range(0.0, lhs->Max(), t->zone()); |
} |
@@ -997,10 +986,10 @@ static double array_max(double a[], size_t n) { |
Type* Typer::Visitor::JSAddRanger(Type::RangeType* lhs, Type::RangeType* rhs, |
Typer* t) { |
double results[4]; |
- results[0] = lhs->Min()->Number() + rhs->Min()->Number(); |
- results[1] = lhs->Min()->Number() + rhs->Max()->Number(); |
- results[2] = lhs->Max()->Number() + rhs->Min()->Number(); |
- results[3] = lhs->Max()->Number() + rhs->Max()->Number(); |
+ results[0] = lhs->Min() + rhs->Min(); |
+ results[1] = lhs->Min() + rhs->Max(); |
+ results[2] = lhs->Max() + rhs->Min(); |
+ results[3] = lhs->Max() + rhs->Max(); |
// Since none of the inputs can be -0, the result cannot be -0 either. |
// However, it can be nan (the sum of two infinities of opposite sign). |
// On the other hand, if none of the "results" above is nan, then the actual |
@@ -1010,9 +999,8 @@ Type* Typer::Visitor::JSAddRanger(Type::RangeType* lhs, Type::RangeType* rhs, |
if (std::isnan(results[i])) ++nans; |
} |
if (nans == 4) return Type::NaN(); // [-inf..-inf] + [inf..inf] or vice versa |
- Factory* f = t->isolate()->factory(); |
- Type* range = Type::Range(f->NewNumber(array_min(results, 4)), |
- f->NewNumber(array_max(results, 4)), t->zone()); |
+ Type* range = |
+ Type::Range(array_min(results, 4), array_max(results, 4), t->zone()); |
return nans == 0 ? range : Type::Union(range, Type::NaN(), t->zone()); |
// Examples: |
// [-inf, -inf] + [+inf, +inf] = NaN |
@@ -1046,10 +1034,10 @@ Type* Typer::Visitor::JSAddTyper(Type* lhs, Type* rhs, Typer* t) { |
Type* Typer::Visitor::JSSubtractRanger(Type::RangeType* lhs, |
Type::RangeType* rhs, Typer* t) { |
double results[4]; |
- results[0] = lhs->Min()->Number() - rhs->Min()->Number(); |
- results[1] = lhs->Min()->Number() - rhs->Max()->Number(); |
- results[2] = lhs->Max()->Number() - rhs->Min()->Number(); |
- results[3] = lhs->Max()->Number() - rhs->Max()->Number(); |
+ results[0] = lhs->Min() - rhs->Min(); |
+ results[1] = lhs->Min() - rhs->Max(); |
+ results[2] = lhs->Max() - rhs->Min(); |
+ results[3] = lhs->Max() - rhs->Max(); |
// Since none of the inputs can be -0, the result cannot be -0. |
// However, it can be nan (the subtraction of two infinities of same sign). |
// On the other hand, if none of the "results" above is nan, then the actual |
@@ -1059,9 +1047,8 @@ Type* Typer::Visitor::JSSubtractRanger(Type::RangeType* lhs, |
if (std::isnan(results[i])) ++nans; |
} |
if (nans == 4) return Type::NaN(); // [inf..inf] - [inf..inf] (all same sign) |
- Factory* f = t->isolate()->factory(); |
- Type* range = Type::Range(f->NewNumber(array_min(results, 4)), |
- f->NewNumber(array_max(results, 4)), t->zone()); |
+ Type* range = |
+ Type::Range(array_min(results, 4), array_max(results, 4), t->zone()); |
return nans == 0 ? range : Type::Union(range, Type::NaN(), t->zone()); |
// Examples: |
// [-inf, +inf] - [-inf, +inf] = [-inf, +inf] \/ NaN |
@@ -1085,10 +1072,10 @@ Type* Typer::Visitor::JSSubtractTyper(Type* lhs, Type* rhs, Typer* t) { |
Type* Typer::Visitor::JSMultiplyRanger(Type::RangeType* lhs, |
Type::RangeType* rhs, Typer* t) { |
double results[4]; |
- double lmin = lhs->Min()->Number(); |
- double lmax = lhs->Max()->Number(); |
- double rmin = rhs->Min()->Number(); |
- double rmax = rhs->Max()->Number(); |
+ double lmin = lhs->Min(); |
+ double lmax = lhs->Max(); |
+ double rmin = rhs->Min(); |
+ double rmax = rhs->Max(); |
results[0] = lmin * rmin; |
results[1] = lmin * rmax; |
results[2] = lmax * rmin; |
@@ -1104,9 +1091,8 @@ Type* Typer::Visitor::JSMultiplyRanger(Type::RangeType* lhs, |
if (maybe_nan) return t->weakint; // Giving up. |
bool maybe_minuszero = (lhs->Maybe(t->singleton_zero) && rmin < 0) || |
(rhs->Maybe(t->singleton_zero) && lmin < 0); |
- Factory* f = t->isolate()->factory(); |
- Type* range = Type::Range(f->NewNumber(array_min(results, 4)), |
- f->NewNumber(array_max(results, 4)), t->zone()); |
+ Type* range = |
+ Type::Range(array_min(results, 4), array_max(results, 4), t->zone()); |
return maybe_minuszero ? Type::Union(range, Type::MinusZero(), t->zone()) |
: range; |
} |
@@ -1139,10 +1125,10 @@ Type* Typer::Visitor::JSDivideTyper(Type* lhs, Type* rhs, Typer* t) { |
Type* Typer::Visitor::JSModulusRanger(Type::RangeType* lhs, |
Type::RangeType* rhs, Typer* t) { |
- double lmin = lhs->Min()->Number(); |
- double lmax = lhs->Max()->Number(); |
- double rmin = rhs->Min()->Number(); |
- double rmax = rhs->Max()->Number(); |
+ double lmin = lhs->Min(); |
+ double lmax = lhs->Max(); |
+ double rmin = rhs->Min(); |
+ double rmax = rhs->Max(); |
double labs = std::max(std::abs(lmin), std::abs(lmax)); |
double rabs = std::max(std::abs(rmin), std::abs(rmax)) - 1; |
@@ -1163,8 +1149,7 @@ Type* Typer::Visitor::JSModulusRanger(Type::RangeType* lhs, |
maybe_minus_zero = true; |
} |
- Factory* f = t->isolate()->factory(); |
- Type* result = Type::Range(f->NewNumber(omin), f->NewNumber(omax), t->zone()); |
+ Type* result = Type::Range(omin, omax, t->zone()); |
if (maybe_minus_zero) |
result = Type::Union(result, Type::MinusZero(), t->zone()); |
return result; |
@@ -1287,29 +1272,28 @@ Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) { |
Type::RangeType* previous = previous_number->AsRange(); |
Type::RangeType* current = current_number->AsRange(); |
- double current_min = current->Min()->Number(); |
- Handle<Object> new_min = current->Min(); |
- |
+ double current_min = current->Min(); |
+ double new_min = current_min; |
// Find the closest lower entry in the list of allowed |
// minima (or negative infinity if there is no such entry). |
- if (current_min != previous->Min()->Number()) { |
+ if (current_min != previous->Min()) { |
new_min = typer_->integer->AsRange()->Min(); |
for (const auto val : typer_->weaken_min_limits_) { |
- if (val->Number() <= current_min) { |
+ if (val <= current_min) { |
new_min = val; |
break; |
} |
} |
} |
- double current_max = current->Max()->Number(); |
- Handle<Object> new_max = current->Max(); |
+ double current_max = current->Max(); |
+ double new_max = current_max; |
// Find the closest greater entry in the list of allowed |
// maxima (or infinity if there is no such entry). |
- if (current_max != previous->Max()->Number()) { |
+ if (current_max != previous->Max()) { |
new_max = typer_->integer->AsRange()->Max(); |
for (const auto val : typer_->weaken_max_limits_) { |
- if (val->Number() >= current_max) { |
+ if (val >= current_max) { |
new_max = val; |
break; |
} |