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

Unified Diff: src/compiler/typer.cc

Issue 2753773010: [compiler] Fix typing of ToLength. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | src/compiler/verifier.cc » ('j') | no next file with comments »
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 600940c897c4e0312183d6560a7bf21da1c2a8af..1055e11d3fb7c37682b63c06fdef0b808f58b505 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -454,9 +454,14 @@ Type* Typer::Visitor::ToLength(Type* type, Typer* t) {
type = ToInteger(type, t);
double min = type->Min();
double max = type->Max();
+ if (max <= 0.0) {
+ return Type::NewConstant(0, t->zone());
+ }
+ if (min >= kMaxSafeInteger) {
+ return Type::NewConstant(kMaxSafeInteger, t->zone());
+ }
if (min <= 0.0) min = 0.0;
- if (max > kMaxSafeInteger) max = kMaxSafeInteger;
- if (max <= min) max = min;
+ if (max >= kMaxSafeInteger) max = kMaxSafeInteger;
return Type::Range(min, max, t->zone());
}
« no previous file with comments | « no previous file | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698