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

Unified Diff: test/mjsunit/math-ceil-minus-zero.js

Issue 1053143005: Collect type feedback on result of Math.[round|ceil|floor] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: MIPS port Created 5 years, 7 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/x64/macro-assembler-x64.cc ('k') | test/mjsunit/math-floor-minus-zero.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/math-ceil-minus-zero.js
diff --git a/test/mjsunit/regress/regress-3976.js b/test/mjsunit/math-ceil-minus-zero.js
similarity index 50%
copy from test/mjsunit/regress/regress-3976.js
copy to test/mjsunit/math-ceil-minus-zero.js
index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..660497c59e51735a853aa80661d993fb788d0e3d 100644
--- a/test/mjsunit/regress/regress-3976.js
+++ b/test/mjsunit/math-ceil-minus-zero.js
@@ -25,56 +25,51 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --max-old-space-size=60 --check-handle-count
+// Flags: --allow-natives-syntax --noalways-opt
-table = [];
-
-for (var i = 0; i < 32; i++) {
- table[i] = String.fromCharCode(i + 0x410);
+// Test that a -0 result doesn't cause deopt loops
+function noDeoptLoop(x) {
+ return Math.ceil(x);
}
-
-
-var random = (function() {
- var seed = 10;
- return function() {
- seed = (seed * 1009) % 8831;
- return seed;
- };
-})();
-
-
-function key(length) {
- var s = "";
- for (var i = 0; i < length; i++) {
- s += table[random() % 32];
- }
- return '"' + s + '"';
+assertEquals(1, noDeoptLoop(0.4));
+assertEquals(1, noDeoptLoop(0.4));
+assertEquals(1, noDeoptLoop(0.4));
+%OptimizeFunctionOnNextCall(noDeoptLoop);
+assertEquals(1, noDeoptLoop(0.4));
+assertEquals(1, noDeoptLoop(0.4));
+assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
+assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
+assertUnoptimized(noDeoptLoop);
+assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
+assertEquals(-1.0, 1/noDeoptLoop(-1.0));
+assertEquals(Infinity, 1/noDeoptLoop(0));
+%OptimizeFunctionOnNextCall(noDeoptLoop);
+assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
+assertEquals(-Infinity, 1/noDeoptLoop(-0.1));
+assertOptimized(noDeoptLoop);
+%ClearFunctionTypeFeedback(noDeoptLoop);
+%DeoptimizeFunction(noDeoptLoop);
+
+// Test that ceil that goes megamorphic is handled correctly.
+function notCeil(x) {
+ return -x;
}
-
-
-function value() {
- return '[{' + '"field1" : ' + random() + ', "field2" : ' + random() + '}]';
+function testMega(f, x) {
+ return f(x);
}
-
-
-function generate(n) {
- var s = '{';
- for (var i = 0; i < n; i++) {
- if (i > 0) s += ', ';
- s += key(random() % 10 + 7);
- s += ':';
- s += value();
- }
- s += '}';
- return s;
+assertEquals(8, testMega(Math.ceil, 7.4));
+assertEquals(8, testMega(Math.ceil, 7.4));
+assertEquals(8, testMega(Math.ceil, 7.4));
+assertEquals(-7.4, testMega(notCeil, 7.4));
+
+// Make sure that we can learn about ceil specialization from Cranskhaft, which
+// doesn't insert soft deopts for CallICs.
+function crankCeilLearn(x) {
+ return Math.ceil(x);
}
-
-
-print("generating");
-
-var str = generate(50000);
-
-print("parsing " + str.length);
-JSON.parse(str);
-
-print("done");
+%OptimizeFunctionOnNextCall(crankCeilLearn);
+assertEquals(12, crankCeilLearn(11.3));
+assertOptimized(crankCeilLearn);
+assertEquals(-Infinity, 1/crankCeilLearn(-0.0));
+assertOptimized(crankCeilLearn);
+assertEquals(-Infinity, 1/crankCeilLearn(-0.75));
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/mjsunit/math-floor-minus-zero.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698