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

Unified Diff: src/crankshaft/hydrogen-instructions.cc

Issue 2412853002: [crankshaft] Range analysis should not rely on overflowed ranges. (Closed)
Patch Set: Created 4 years, 2 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/crankshaft/hydrogen-instructions.h ('k') | test/mjsunit/regress/regress-crbug-645438.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen-instructions.cc
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc
index 17d268cfe16d2e17a0dd59b9d1908a31a6ccc7e8..85222f63a376884d7bda88db0427f00645309ebc 100644
--- a/src/crankshaft/hydrogen-instructions.cc
+++ b/src/crankshaft/hydrogen-instructions.cc
@@ -259,7 +259,11 @@ bool Range::AddAndCheckOverflow(const Representation& r, Range* other) {
bool may_overflow = false;
lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow);
upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow);
- KeepOrder();
+ if (may_overflow) {
+ Clear();
+ } else {
+ KeepOrder();
+ }
#ifdef DEBUG
Verify();
#endif
@@ -271,13 +275,21 @@ bool Range::SubAndCheckOverflow(const Representation& r, Range* other) {
bool may_overflow = false;
lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow);
upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow);
- KeepOrder();
+ if (may_overflow) {
+ Clear();
+ } else {
+ KeepOrder();
+ }
#ifdef DEBUG
Verify();
#endif
return may_overflow;
}
+void Range::Clear() {
+ lower_ = kMinInt;
+ upper_ = kMaxInt;
+}
void Range::KeepOrder() {
if (lower_ > upper_) {
@@ -301,8 +313,12 @@ bool Range::MulAndCheckOverflow(const Representation& r, Range* other) {
int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow);
int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow);
int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow);
- lower_ = Min(Min(v1, v2), Min(v3, v4));
- upper_ = Max(Max(v1, v2), Max(v3, v4));
+ if (may_overflow) {
+ Clear();
+ } else {
+ lower_ = Min(Min(v1, v2), Min(v3, v4));
+ upper_ = Max(Max(v1, v2), Max(v3, v4));
+ }
#ifdef DEBUG
Verify();
#endif
« no previous file with comments | « src/crankshaft/hydrogen-instructions.h ('k') | test/mjsunit/regress/regress-crbug-645438.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698