Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: src/compiler/typer.cc

Issue 877643002: Reland of "Steps towards unification of number bitset and range types." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid (some of the) uninhabited type normalization based on representation. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | src/types.h » ('j') | src/types.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 4b3a8830a0fff9cbed6694b9588742225d262814..871a3ff9ad36d14a14649beca625e1c66024fef7 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -891,12 +891,12 @@ Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) {
double rmax = rhs->Max();
if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) {
// Xor-ing negative or non-negative values results in a non-negative value.
- return Type::NonNegativeSigned32();
+ return Type::Unsigned31();
}
if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) {
// Xor-ing a negative and a non-negative value results in a negative value.
// TODO(jarin) Use a range here.
- return Type::NegativeSigned32();
+ return Type::Negative32();
}
return Type::Signed32();
}
@@ -1261,43 +1261,54 @@ Bounds Typer::Visitor::TypeJSLoadNamed(Node* node) {
// in the graph. In the current implementation, we are
// increasing the limits to the closest power of two.
Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) {
- Type::RangeType* previous = previous_type->GetRange();
- Type::RangeType* current = current_type->GetRange();
- if (previous != NULL && current != NULL) {
- double current_min = current->Min()->Number();
- Handle<Object> 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()) {
- new_min = typer_->integer->AsRange()->Min();
- for (const auto val : typer_->weaken_min_limits_) {
- if (val->Number() <= current_min) {
- new_min = val;
- break;
- }
+ // If the types have nothing to do with integers, return the types.
+ if (!current_type->Maybe(typer_->integer) ||
+ !previous_type->Maybe(typer_->integer)) {
+ return current_type;
+ }
+
+ Type* previous_number =
+ Type::Intersect(previous_type, typer_->integer, zone());
+ Type* current_number = Type::Intersect(current_type, typer_->integer, zone());
+ if (!current_number->IsRange() || !previous_number->IsRange()) {
+ return current_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();
+
+ // 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()) {
+ new_min = typer_->integer->AsRange()->Min();
+ for (const auto val : typer_->weaken_min_limits_) {
+ if (val->Number() <= current_min) {
+ new_min = val;
+ break;
}
}
+ }
- double current_max = current->Max()->Number();
- Handle<Object> 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()) {
- new_max = typer_->integer->AsRange()->Max();
- for (const auto val : typer_->weaken_max_limits_) {
- if (val->Number() >= current_max) {
- new_max = val;
- break;
- }
+ double current_max = current->Max()->Number();
+ Handle<Object> 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()) {
+ new_max = typer_->integer->AsRange()->Max();
+ for (const auto val : typer_->weaken_max_limits_) {
+ if (val->Number() >= current_max) {
+ new_max = val;
+ break;
}
}
-
- return Type::Union(current_type,
- Type::Range(new_min, new_max, typer_->zone()),
- typer_->zone());
}
- return current_type;
+
+ return Type::Union(current_type,
+ Type::Range(new_min, new_max, typer_->zone()),
+ typer_->zone());
}
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | src/types.h » ('j') | src/types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698