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

Side by Side Diff: tests/language/mint_arithmetic_test.dart

Issue 18563006: More tests updated to optimize code (Part 2). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
4 5
5 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
6 7
7 // Test arithmetic on 64-bit integers. 8 // Test arithmetic on 64-bit integers.
8 9
9 test_and_1() { 10 test_and_1() {
10 try { // Avoid optimizing this function. 11 try { // Avoid optimizing this function.
11 f(a, b) { 12 f(a, b) {
12 var s = b; 13 var s = b;
13 var t = a & s; 14 var t = a & s;
14 return t == b; 15 return t == b;
15 } 16 }
16 var x = 0xffffffff; 17 var x = 0xffffffff;
17 for (var i = 0; i < 10000; i++) f(x, 0); 18 for (var i = 0; i < 20; i++) f(x, 0);
18 Expect.equals(true, f(x, 0)); 19 Expect.equals(true, f(x, 0));
19 Expect.equals(false, f(x, -1)); // Triggers deoptimization. 20 Expect.equals(false, f(x, -1)); // Triggers deoptimization.
20 } finally { } 21 } finally { }
21 } 22 }
22 23
23 test_and_2() { 24 test_and_2() {
24 try { // Avoid optimizing this function. 25 try { // Avoid optimizing this function.
25 f(a, b) { 26 f(a, b) {
26 return a & b; 27 return a & b;
27 } 28 }
28 var x = 0xffffffff; 29 var x = 0xffffffff;
29 for (var i = 0; i < 10000; i++) f(x, x); 30 for (var i = 0; i < 20; i++) f(x, x);
30 Expect.equals(x, f(x, x)); 31 Expect.equals(x, f(x, x));
31 Expect.equals(1234, f(0xffffffff, 1234)); 32 Expect.equals(1234, f(0xffffffff, 1234));
32 Expect.equals(0x100000001, f(0x100000001,-1)); 33 Expect.equals(0x100000001, f(0x100000001,-1));
33 Expect.equals(-0x40000000, f(-0x40000000, -1)); 34 Expect.equals(-0x40000000, f(-0x40000000, -1));
34 Expect.equals(0x40000000, f(0x40000000, -1)); 35 Expect.equals(0x40000000, f(0x40000000, -1));
35 Expect.equals(0x3fffffff, f(0x3fffffff, -1)); 36 Expect.equals(0x3fffffff, f(0x3fffffff, -1));
36 } finally { } 37 } finally { }
37 } 38 }
38 39
39 test_xor_1() { 40 test_xor_1() {
40 try { // Avoid optimizing this function. 41 try { // Avoid optimizing this function.
41 f(a, b) { 42 f(a, b) {
42 var s = b; 43 var s = b;
43 var t = a ^ s; 44 var t = a ^ s;
44 return t; 45 return t;
45 } 46 }
46 var x = 0xffffffff; 47 var x = 0xffffffff;
47 for (var i = 0; i < 10000; i++) f(x, x); 48 for (var i = 0; i < 20; i++) f(x, x);
48 Expect.equals(0, f(x, x)); 49 Expect.equals(0, f(x, x));
49 Expect.equals(-x - 1, f(x, -1)); 50 Expect.equals(-x - 1, f(x, -1));
50 var y = 0xffffffffffffffff; 51 var y = 0xffffffffffffffff;
51 Expect.equals(-y - 1, f(y, -1)); // Triggers deoptimization. 52 Expect.equals(-y - 1, f(y, -1)); // Triggers deoptimization.
52 } finally { } 53 } finally { }
53 } 54 }
54 55
55 test_or_1() { 56 test_or_1() {
56 try { // Avoid optimizing this function. 57 try { // Avoid optimizing this function.
57 f(a, b) { 58 f(a, b) {
58 var s = b; 59 var s = b;
59 var t = a | s; 60 var t = a | s;
60 return t; 61 return t;
61 } 62 }
62 var x = 0xffffffff; 63 var x = 0xffffffff;
63 for (var i = 0; i < 10000; i++) f(x, x); 64 for (var i = 0; i < 20; i++) f(x, x);
64 Expect.equals(x, f(x, x)); 65 Expect.equals(x, f(x, x));
65 Expect.equals(-1, f(x, -1)); 66 Expect.equals(-1, f(x, -1));
66 var y = 0xffffffffffffffff; 67 var y = 0xffffffffffffffff;
67 Expect.equals(-1, f(y, -1)); // Triggers deoptimization. 68 Expect.equals(-1, f(y, -1)); // Triggers deoptimization.
68 } finally { } 69 } finally { }
69 } 70 }
70 71
71 test_func(x, y) => (x & y) + 1.0; 72 test_func(x, y) => (x & y) + 1.0;
72 73
73 test_mint_double_op() { 74 test_mint_double_op() {
74 for (var i=0; i<10000; i++) test_func(4294967295, 1); 75 for (var i = 0; i < 20; i++) test_func(4294967295, 1);
75 Expect.equals(2.0, test_func(4294967295, 1)); 76 Expect.equals(2.0, test_func(4294967295, 1));
76 } 77 }
77 78
78 main() { 79 main() {
79 for (var i = 0; i < 5; i++) { 80 for (var i = 0; i < 5; i++) {
80 test_and_1(); 81 test_and_1();
81 test_and_2(); 82 test_and_2();
82 test_xor_1(); 83 test_xor_1();
83 test_or_1(); 84 test_or_1();
84 test_mint_double_op(); 85 test_mint_double_op();
85 } 86 }
86 } 87 }
OLDNEW
« no previous file with comments | « tests/language/megamorphic_no_such_method_test.dart ('k') | tests/language/mint_compares_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698