Reviewers: Yang,
Message:
Please take a look.
Description:
Correctly set kCanBeDivByZero flag for HMathFloorOfDiv.
After r13289 the divisor can be non-constant, so we should check for zero.
BUG=171641
[email protected]
Please review this at https://chromiumcodereview.appspot.com/12047050/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
A + test/mjsunit/regress/regress-171641.js
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
7988d2f25968c851c9074c38d8043fb7f18ebfc6..dc899b43a7daf4cab2925a63510a854efc5fcb90
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -3111,6 +3111,9 @@ class HMathFloorOfDiv: public HBinaryOperation {
set_representation(Representation::Integer32());
SetFlag(kUseGVN);
SetFlag(kCanOverflow);
+ if (!right->IsConstant()) {
+ SetFlag(kCanBeDivByZero);
+ }
}
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
Index: test/mjsunit/regress/regress-171641.js
diff --git a/test/mjsunit/regress/regress-2499.js
b/test/mjsunit/regress/regress-171641.js
similarity index 88%
copy from test/mjsunit/regress/regress-2499.js
copy to test/mjsunit/regress/regress-171641.js
index
52aad874db6fcdc89f5ee1ae4db45304e64b0e77..8db6781821325f8f6253eb2df4abb2b362b001c0
100644
--- a/test/mjsunit/regress/regress-2499.js
+++ b/test/mjsunit/regress/regress-171641.js
@@ -27,14 +27,14 @@
// Flags: --allow-natives-syntax
-function foo(word, nBits) {
- return (word[1] >>> nBits) | (word[0] << (32 - nBits));
+function foo(k, p) {
+ for (var i = 0; i < 1; i++) {
+ p = Math.min(p, i);
+ }
+ m = Math.floor((k | 0) / p);
}
-word = [0x1001, 0];
-
-var expected = foo(word, 1);
-foo(word, 1);
+foo(0, 1);
+foo(0, 1);
%OptimizeFunctionOnNextCall(foo);
-var optimized = foo(word, 1);
-assertEquals(expected, optimized)
+foo(0, 1);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev