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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/crankshaft/hydrogen-instructions.h" 5 #include "src/crankshaft/hydrogen-instructions.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/ieee754.h" 8 #include "src/base/ieee754.h"
9 #include "src/base/safe_math.h" 9 #include "src/base/safe_math.h"
10 #include "src/crankshaft/hydrogen-infer-representation.h" 10 #include "src/crankshaft/hydrogen-infer-representation.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 lower_ = kMinInt; 252 lower_ = kMinInt;
253 } 253 }
254 set_can_be_minus_zero(false); 254 set_can_be_minus_zero(false);
255 } 255 }
256 256
257 257
258 bool Range::AddAndCheckOverflow(const Representation& r, Range* other) { 258 bool Range::AddAndCheckOverflow(const Representation& r, Range* other) {
259 bool may_overflow = false; 259 bool may_overflow = false;
260 lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow); 260 lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow);
261 upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow); 261 upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow);
262 KeepOrder(); 262 if (may_overflow) {
263 Clear();
264 } else {
265 KeepOrder();
266 }
263 #ifdef DEBUG 267 #ifdef DEBUG
264 Verify(); 268 Verify();
265 #endif 269 #endif
266 return may_overflow; 270 return may_overflow;
267 } 271 }
268 272
269 273
270 bool Range::SubAndCheckOverflow(const Representation& r, Range* other) { 274 bool Range::SubAndCheckOverflow(const Representation& r, Range* other) {
271 bool may_overflow = false; 275 bool may_overflow = false;
272 lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow); 276 lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow);
273 upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow); 277 upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow);
274 KeepOrder(); 278 if (may_overflow) {
279 Clear();
280 } else {
281 KeepOrder();
282 }
275 #ifdef DEBUG 283 #ifdef DEBUG
276 Verify(); 284 Verify();
277 #endif 285 #endif
278 return may_overflow; 286 return may_overflow;
279 } 287 }
280 288
289 void Range::Clear() {
290 lower_ = kMinInt;
291 upper_ = kMaxInt;
292 }
281 293
282 void Range::KeepOrder() { 294 void Range::KeepOrder() {
283 if (lower_ > upper_) { 295 if (lower_ > upper_) {
284 int32_t tmp = lower_; 296 int32_t tmp = lower_;
285 lower_ = upper_; 297 lower_ = upper_;
286 upper_ = tmp; 298 upper_ = tmp;
287 } 299 }
288 } 300 }
289 301
290 302
291 #ifdef DEBUG 303 #ifdef DEBUG
292 void Range::Verify() const { 304 void Range::Verify() const {
293 DCHECK(lower_ <= upper_); 305 DCHECK(lower_ <= upper_);
294 } 306 }
295 #endif 307 #endif
296 308
297 309
298 bool Range::MulAndCheckOverflow(const Representation& r, Range* other) { 310 bool Range::MulAndCheckOverflow(const Representation& r, Range* other) {
299 bool may_overflow = false; 311 bool may_overflow = false;
300 int v1 = MulWithoutOverflow(r, lower_, other->lower(), &may_overflow); 312 int v1 = MulWithoutOverflow(r, lower_, other->lower(), &may_overflow);
301 int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow); 313 int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow);
302 int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow); 314 int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow);
303 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow); 315 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow);
304 lower_ = Min(Min(v1, v2), Min(v3, v4)); 316 if (may_overflow) {
305 upper_ = Max(Max(v1, v2), Max(v3, v4)); 317 Clear();
318 } else {
319 lower_ = Min(Min(v1, v2), Min(v3, v4));
320 upper_ = Max(Max(v1, v2), Max(v3, v4));
321 }
306 #ifdef DEBUG 322 #ifdef DEBUG
307 Verify(); 323 Verify();
308 #endif 324 #endif
309 return may_overflow; 325 return may_overflow;
310 } 326 }
311 327
312 328
313 bool HValue::IsDefinedAfter(HBasicBlock* other) const { 329 bool HValue::IsDefinedAfter(HBasicBlock* other) const {
314 return block()->block_id() > other->block_id(); 330 return block()->block_id() > other->block_id();
315 } 331 }
(...skipping 3707 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 case HObjectAccess::kExternalMemory: 4039 case HObjectAccess::kExternalMemory:
4024 os << "[external-memory]"; 4040 os << "[external-memory]";
4025 break; 4041 break;
4026 } 4042 }
4027 4043
4028 return os << "@" << access.offset(); 4044 return os << "@" << access.offset();
4029 } 4045 }
4030 4046
4031 } // namespace internal 4047 } // namespace internal
4032 } // namespace v8 4048 } // namespace v8
OLDNEW
« 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