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

Unified Diff: src/compiler/typer.cc

Issue 2229343002: [turbofan] Improve typing for CheckBounds. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix redundancy check. Created 4 years, 4 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/simplified-lowering.cc ('k') | no next file » | 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 8693b7e1c421887afff2ae7a8c6b408b0b22e7fb..57643c3e1f9882591c09758e34e5643382a083ee 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -1537,8 +1537,14 @@ Type* Typer::Visitor::TypeStringFromCharCode(Node* node) {
}
Type* Typer::Visitor::TypeCheckBounds(Node* node) {
- // TODO(bmeurer): We could do better here based on the limit.
- return Type::Unsigned31();
+ Type* index = Operand(node, 0);
+ Type* length = Operand(node, 1);
+ index = Type::Intersect(index, Type::Integral32(), zone());
+ if (!index->IsInhabited() || !length->IsInhabited()) return Type::None();
+ double min = std::max(index->Min(), 0.0);
+ double max = std::min(index->Max(), length->Min() - 1);
+ if (max < min) return Type::None();
+ return Type::Range(min, max, zone());
}
Type* Typer::Visitor::TypeCheckMaps(Node* node) {
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698