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

Unified Diff: test/mjsunit/es6/math-fround.js

Issue 425943002: Inline Math.fround in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: arm64 port Created 6 years, 5 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 | « test/mjsunit/constant-folding-2.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/math-fround.js
diff --git a/test/mjsunit/es6/math-fround.js b/test/mjsunit/es6/math-fround.js
index 6142eb39eda0556633b10650149ff14cf2092687..c53396a38a13743967bee02b4d31fe7b8707b9ef 100644
--- a/test/mjsunit/es6/math-fround.js
+++ b/test/mjsunit/es6/math-fround.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Flags: --allow-natives-syntax
+
// Monkey-patch Float32Array.
Float32Array = function(x) { this[0] = 0; };
@@ -9,15 +11,33 @@ assertTrue(isNaN(Math.fround(NaN)));
assertTrue(isNaN(Math.fround(function() {})));
assertTrue(isNaN(Math.fround({ toString: function() { return NaN; } })));
assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } })));
-assertEquals("Infinity", String(1/Math.fround(0)));
-assertEquals("-Infinity", String(1/Math.fround(-0)));
-assertEquals("Infinity", String(Math.fround(Infinity)));
-assertEquals("-Infinity", String(Math.fround(-Infinity)));
+assertTrue(isNaN(Math.fround(NaN)));
+assertTrue(isNaN(Math.fround(function() {})));
+assertTrue(isNaN(Math.fround({ toString: function() { return NaN; } })));
+assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } })));
-assertEquals("Infinity", String(Math.fround(1E200)));
-assertEquals("-Infinity", String(Math.fround(-1E200)));
-assertEquals("Infinity", String(1/Math.fround(1E-300)));
-assertEquals("-Infinity", String(1/Math.fround(-1E-300)));
+function unopt(x) { return Math.fround(x); }
+function opt(y) { return Math.fround(y); }
+
+opt(0.1);
+opt(0.1);
+unopt(0.1);
+%NeverOptimizeFunction(unopt);
+%OptimizeFunctionOnNextCall(opt);
+
+function test(f) {
+ assertEquals("Infinity", String(1/f(0)));
+ assertEquals("-Infinity", String(1/f(-0)));
+ assertEquals("Infinity", String(f(Infinity)));
+ assertEquals("-Infinity", String(f(-Infinity)));
+ assertEquals("Infinity", String(f(1E200)));
+ assertEquals("-Infinity", String(f(-1E200)));
+ assertEquals("Infinity", String(1/f(1E-300)));
+ assertEquals("-Infinity", String(1/f(-1E-300)));
+}
+
+test(opt);
+test(unopt);
mantissa_23_shift = Math.pow(2, -23);
mantissa_29_shift = Math.pow(2, -23-29);
@@ -79,13 +99,16 @@ ieee754float.prototype.toSingleSubnormal = function(sign, exponent) {
var pi = new ieee754float(0, 0x400, 0x490fda, 0x14442d18);
-assertEquals(pi.toSingle(), Math.fround(pi.toDouble()));
+assertEquals(pi.toSingle(), opt(pi.toDouble()));
+assertEquals(pi.toSingle(), unopt(pi.toDouble()));
+
function fuzz_mantissa(sign, exp, m1inc, m2inc) {
for (var m1 = 0; m1 < (1 << 23); m1 += m1inc) {
for (var m2 = 0; m2 < (1 << 29); m2 += m2inc) {
var float = new ieee754float(sign, exp, m1, m2);
- assertEquals(float.toSingle(), Math.fround(float.toDouble()));
+ assertEquals(float.toSingle(), unopt(float.toDouble()));
+ assertEquals(float.toSingle(), opt(float.toDouble()));
}
}
}
« no previous file with comments | « test/mjsunit/constant-folding-2.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698