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

Side by Side Diff: test/mjsunit/math-floor.js

Issue 7514040: tighten invariants of HValue::InferRange (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: another wee presubmit thing, sigh Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 function test() { 46 function test() {
47 testFloor(0, 0); 47 testFloor(0, 0);
48 testFloor(0, zero()); 48 testFloor(0, zero());
49 testFloor(-0, -0); 49 testFloor(-0, -0);
50 testFloor(Infinity, Infinity); 50 testFloor(Infinity, Infinity);
51 testFloor(-Infinity, -Infinity); 51 testFloor(-Infinity, -Infinity);
52 testFloor(NaN, NaN); 52 testFloor(NaN, NaN);
53 53
54 // Ensure that a negative zero coming from Math.floor is properly
55 // handled by other ops that take unboxed doubles. See cr7514040.
Kevin Millikin (Chromium) 2011/08/02 10:24:14 No need to cross reference the code review in the
56 function ifloor(x) {
57 return 1/Math.floor(x);
58 }
59 assertEquals(-Infinity, ifloor(-0));
60 assertEquals(-Infinity, ifloor(-0));
61 assertEquals(-Infinity, ifloor(-0));
62 %OptimizeFunctionOnNextCall(ifloor);
63 assertEquals(-Infinity, ifloor(-0));
64
54 testFloor(0, 0.1); 65 testFloor(0, 0.1);
55 testFloor(0, 0.49999999999999994); 66 testFloor(0, 0.49999999999999994);
56 testFloor(0, 0.5); 67 testFloor(0, 0.5);
57 testFloor(0, 0.7); 68 testFloor(0, 0.7);
58 testFloor(-1, -0.1); 69 testFloor(-1, -0.1);
59 testFloor(-1, -0.49999999999999994); 70 testFloor(-1, -0.49999999999999994);
60 testFloor(-1, -0.5); 71 testFloor(-1, -0.5);
61 testFloor(-1, -0.7); 72 testFloor(-1, -0.7);
62 testFloor(1, 1); 73 testFloor(1, 1);
63 testFloor(1, 1.1); 74 testFloor(1, 1.1);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 testFloor(-two_52 + 1, -two_52 + 1 + 0.1); 133 testFloor(-two_52 + 1, -two_52 + 1 + 0.1);
123 testFloor(-two_52 + 1, -two_52 + 1 + 0.5); 134 testFloor(-two_52 + 1, -two_52 + 1 + 0.5);
124 testFloor(-two_52 + 1, -two_52 + 1 + 0.7); 135 testFloor(-two_52 + 1, -two_52 + 1 + 0.7);
125 } 136 }
126 137
127 138
128 // Test in a loop to cover the custom IC and GC-related issues. 139 // Test in a loop to cover the custom IC and GC-related issues.
129 for (var i = 0; i < 500; i++) { 140 for (var i = 0; i < 500; i++) {
130 test(); 141 test();
131 } 142 }
143
144
145 // Ensure that a negative zero coming from Math.floor is properly
146 // handled by other ops that take unboxed doubles. See cr7514040.
147 function floorsum(i,n) {
148 var ret = Math.floor(n);
149 while (--i > 0) {
150 ret += Math.floor(n);
151 }
152 return ret;
153 }
154 assertEquals(-0, floorsum(1000,-0));
155 %OptimizeFunctionOnNextCall(floorsum);
156 // It seems that %OptimizeFunctionOnNextCall doesn't always work! Here
Kevin Millikin (Chromium) 2011/08/02 10:24:14 It should always work (or else that's a bug). I t
157 // we push iterations up to a large number to ensure that we try to
158 // unbox doubles as much as possible.
159 assertEquals(-0, floorsum(1000000,-0));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698