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

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

Issue 1841993002: [builtins] Make Math.ceil, Math.trunc and Math.round optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « test/mjsunit/es6/math-trunc.js ('k') | test/mjsunit/math-floor-part1.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --max-semi-space-size=1 --allow-natives-syntax
6
7 var test_id = 0;
8
9 function testCeil(expect, input) {
10 var test = new Function('n',
11 '"' + (test_id++) + '";return Math.ceil(n)');
12 assertEquals(expect, test(input));
13 assertEquals(expect, test(input));
14 assertEquals(expect, test(input));
15 %OptimizeFunctionOnNextCall(test);
16 assertEquals(expect, test(input));
17
18 var test_double_input = new Function(
19 'n',
20 '"' + (test_id++) + '";return Math.ceil(+n)');
21 assertEquals(expect, test_double_input(input));
22 assertEquals(expect, test_double_input(input));
23 assertEquals(expect, test_double_input(input));
24 %OptimizeFunctionOnNextCall(test_double_input);
25 assertEquals(expect, test_double_input(input));
26
27 var test_double_output = new Function(
28 'n',
29 '"' + (test_id++) + '";return Math.ceil(n) + -0.0');
30 assertEquals(expect, test_double_output(input));
31 assertEquals(expect, test_double_output(input));
32 assertEquals(expect, test_double_output(input));
33 %OptimizeFunctionOnNextCall(test_double_output);
34 assertEquals(expect, test_double_output(input));
35
36 var test_via_floor = new Function(
37 'n',
38 '"' + (test_id++) + '";return -Math.floor(-n)');
39 assertEquals(expect, test_via_floor(input));
40 assertEquals(expect, test_via_floor(input));
41 assertEquals(expect, test_via_floor(input));
42 %OptimizeFunctionOnNextCall(test_via_floor);
43 assertEquals(expect, test_via_floor(input));
44
45 if (input <= 0) {
46 var test_via_trunc = new Function(
47 'n',
48 '"' + (test_id++) + '";return Math.trunc(n)');
49 assertEquals(expect, test_via_trunc(input));
50 assertEquals(expect, test_via_trunc(input));
51 assertEquals(expect, test_via_trunc(input));
52 %OptimizeFunctionOnNextCall(test_via_trunc);
53 assertEquals(expect, test_via_trunc(input));
54 }
55 }
56
57 function test() {
58 testCeil(0, 0);
59 testCeil(+0, +0);
60 testCeil(-0, -0);
61 testCeil(1, 0.49999);
62 testCeil(1, 0.6);
63 testCeil(1, 0.5);
64 testCeil(-0, -0.1);
65 testCeil(-0, -0.5);
66 testCeil(-0, -0.6);
67 testCeil(-1, -1.6);
68 testCeil(-0, -0.50001);
69 testCeil(Infinity, Infinity);
70 testCeil(-Infinity, -Infinity);
71 }
72
73
74 // Test in a loop to cover the custom IC and GC-related issues.
75 for (var i = 0; i < 10; i++) {
76 test();
77 new Array(i * 10000);
78 }
OLDNEW
« no previous file with comments | « test/mjsunit/es6/math-trunc.js ('k') | test/mjsunit/math-floor-part1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698