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

Unified Diff: test/mjsunit/math-floor-of-div-nosudiv.js

Issue 11624022: Handle non-constant divisor in MathFloorOfDiv, on ia32/x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years 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 | « test/mjsunit/math-floor-of-div.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/math-floor-of-div-nosudiv.js
===================================================================
--- test/mjsunit/math-floor-of-div-nosudiv.js (revision 13283)
+++ test/mjsunit/math-floor-of-div-nosudiv.js (working copy)
@@ -184,10 +184,38 @@
%OptimizeFunctionOnNextCall(test_div);
test_div();
+// Test for ia32/x64 flooring correctness.
+var values2 = [1, 3, 10, 99, 100, 101, 0x7fffffff];
+function test_div2() {
+ for (var i = 0; i < values2.length; i++) {
+ for (var j = 0; j < values2.length; j++) {
+ assertEquals(Math.floor(div((values2[i] | 0), (values2[j] | 0))),
+ Math.floor((values2[i] | 0) / (values2[j] | 0)));
+ assertEquals(Math.floor(div(-(values2[i] | 0), (values2[j] | 0))),
+ Math.floor(-(values2[i] | 0) / (values2[j] | 0)));
+ assertEquals(Math.floor(div((values2[i] | 0), -(values2[j] | 0))),
+ Math.floor((values2[i] | 0) / -(values2[j] | 0)));
+ assertEquals(Math.floor(div(-(values2[i] | 0), -(values2[j] | 0))),
+ Math.floor(-(values2[i] | 0) / -(values2[j] | 0)));
+ }
+ }
+}
+
+test_div2();
+%OptimizeFunctionOnNextCall(test_div2);
+test_div2();
+
+
// Test for negative zero, overflow and division by 0.
// Separate the tests to prevent deoptimizations from making the other optimized
// test unreachable.
+// We box the value in an array to avoid constant propagation.
+var neg_one_in_array = [-1];
+var zero_in_array = [0];
+var min_int_in_array = [-2147483648];
+
+// Test for dividing by constant.
function IsNegativeZero(x) {
assertTrue(x == 0); // Is 0 or -0.
var y = 1 / x;
@@ -196,15 +224,12 @@
}
function test_div_deopt_minus_zero() {
- var zero_in_array = [0];
for (var i = 0; i < 2; ++i) {
assertTrue(IsNegativeZero(Math.floor((zero_in_array[0] | 0) / -1)));
}
}
function test_div_deopt_overflow() {
- // We box the value in an array to avoid constant propagation.
- var min_int_in_array = [-2147483648];
for (var i = 0; i < 2; ++i) {
// We use '| 0' to force the representation to int32.
assertEquals(-min_int_in_array[0],
@@ -228,3 +253,35 @@
test_div_deopt_minus_zero();
test_div_deopt_overflow();
test_div_deopt_div_by_zero();
+
+// Test for dividing by variable.
+function test_div_deopt_minus_zero_v() {
+ for (var i = 0; i < 2; ++i) {
+ assertTrue(IsNegativeZero(Math.floor((zero_in_array[0] | 0) / neg_one_in_array[0])));
+ }
+}
+
+function test_div_deopt_overflow_v() {
+ for (var i = 0; i < 2; ++i) {
+ // We use '| 0' to force the representation to int32.
+ assertEquals(-min_int_in_array[0],
+ Math.floor((min_int_in_array[0] | 0) / neg_one_in_array[0]));
+ }
+}
+
+function test_div_deopt_div_by_zero_v() {
+ for (var i = 0; i < 2; ++i) {
+ assertEquals(div(i, 0),
+ Math.floor(i / zero_in_array[0]));
+ }
+}
+
+test_div_deopt_minus_zero_v();
+test_div_deopt_overflow_v();
+test_div_deopt_div_by_zero_v();
+%OptimizeFunctionOnNextCall(test_div_deopt_minus_zero_v);
+%OptimizeFunctionOnNextCall(test_div_deopt_overflow_v);
+%OptimizeFunctionOnNextCall(test_div_deopt_div_by_zero_v);
+test_div_deopt_minus_zero_v();
+test_div_deopt_overflow_v();
+test_div_deopt_div_by_zero_v();
« no previous file with comments | « test/mjsunit/math-floor-of-div.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698