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

Unified Diff: test/mjsunit/math-52-mul-div.js

Issue 1433353006: [machine-operator-reducer] fix float truncation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/math-52-mul-div.js
diff --git a/test/mjsunit/regress/regress-3976.js b/test/mjsunit/math-52-mul-div.js
similarity index 60%
copy from test/mjsunit/regress/regress-3976.js
copy to test/mjsunit/math-52-mul-div.js
index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..75d6c0a739e344cb98f15d36b1a36cf3369c1b55 100644
--- a/test/mjsunit/regress/regress-3976.js
+++ b/test/mjsunit/math-52-mul-div.js
@@ -25,56 +25,61 @@
// (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 --turbo-filter=*
-table = [];
+function mul(a, b) {
+ const l = a & 0x3ffffff;
+ const h = b & 0x3ffffff;
-for (var i = 0; i < 32; i++) {
- table[i] = String.fromCharCode(i + 0x410);
+ return (l * h) | 0;
}
+function mulAndDiv(a, b) {
+ const l = a & 0x3ffffff;
+ const h = b & 0x3ffffff;
+ const m = l * h;
-var random = (function() {
- var seed = 10;
- return function() {
- seed = (seed * 1009) % 8831;
- return seed;
- };
-})();
+ const rl = m & 0x3ffffff;
+ const rh = (m / 0x4000000) | 0;
-
-function key(length) {
- var s = "";
- for (var i = 0; i < length; i++) {
- s += table[random() % 32];
- }
- return '"' + s + '"';
+ return rl | rh;
}
+function overflowMul(a, b) {
+ const l = a | 0;
+ const h = b | 0;
-function value() {
- return '[{' + '"field1" : ' + random() + ', "field2" : ' + random() + '}]';
+ return (l * h) | 0;
}
+function overflowDiv(a, b) {
+ const l = a & 0x3ffffff;
+ const h = b & 0x3ffffff;
+ const m = l * h;
-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;
+ return (m / 0x10) | 0;
}
+function nonPowerOfTwoDiv(a, b) {
+ const l = a & 0x3ffffff;
+ const h = b & 0x3ffffff;
+ const m = l * h;
-print("generating");
+ return (m / 0x4000001) | 0;
+}
-var str = generate(50000);
+function test(fn, a, b) {
titzer 2015/11/11 21:04:43 Can you add a few more inputs, e.g. some pseudo-ra
fedor.indutny 2015/11/11 21:35:58 Acknowledged.
+ const expected = fn(a, b);
+ fn(1, 2);
+ fn(0, 0);
+ %OptimizeFunctionOnNextCall(fn);
+ const actual = fn(a, b);
-print("parsing " + str.length);
-JSON.parse(str);
+ assertEquals(expected, actual);
+}
-print("done");
+test(mul, 0x3ffffff, 0x3ffffff);
+test(mulAndDiv, 0x3ffffff, 0x3ffffff);
+test(overflowMul, 0x4ffffff, 0x4ffffff);
+test(overflowDiv, 0x3ffffff, 0x3ffffff);
+test(nonPowerOfTwoDiv, 0x3ffffff, 0x3ffffff);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698