OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
ahe
2013/02/13 14:46:23
Add empty line between copyright and file comment.
Vyacheslav Egorov (Google)
2013/03/19 20:27:25
I am not sure what are style here is. I see a lot
| |
4 // Test that branch fusion correctly sets branch environment for comparisons | |
5 // that require unboxing and does not fuse branches that can deoptimize. | |
6 | |
7 var sideEffect = true; | |
8 | |
9 barDouble(a, b) { | |
10 sideEffect = false; | |
11 final result = (a == b); | |
12 sideEffect = !sideEffect; | |
13 return result; | |
14 } | |
15 fooDouble(a, b) => barDouble(a, b) ? 1 : 0; | |
16 | |
17 barMint(a, b) { | |
18 sideEffect = false; | |
19 final result = (a == b); | |
20 sideEffect = !sideEffect; | |
21 return result; | |
22 } | |
23 fooMint(a, b) => barMint(a, b) ? 1 : 0; | |
24 | |
25 class A { | |
26 operator == (other) => identical(this, other); | |
27 } | |
28 | |
29 class B extends A { | |
30 } | |
31 | |
32 class C extends A { | |
33 } | |
34 | |
35 barPoly(a, b) { | |
36 sideEffect = false; | |
37 final result = a == b; | |
38 sideEffect = !sideEffect; | |
39 return result; | |
40 } | |
41 | |
42 fooPoly(a, b) => barPoly(a, b) ? 1 : 0; | |
43 | |
44 main () { | |
45 final a = 1.0; | |
46 final b = 1 << 62; | |
47 final x = new A(), y = new B(), z = new C(); | |
48 for (var i = 0; i < 10000; i++) { | |
49 Expect.equals(1, fooDouble(a, a)); | |
50 Expect.isTrue(sideEffect); | |
51 Expect.equals(0, fooMint(b, 0)); | |
52 Expect.isTrue(sideEffect); | |
53 Expect.equals(1, fooPoly(x, x)); | |
54 Expect.equals(0, fooPoly(y, x)); | |
55 } | |
56 Expect.equals(1, fooDouble(z, z)); | |
57 Expect.isTrue(sideEffect); | |
58 Expect.equals(1, fooMint(z, z)); | |
59 Expect.isTrue(sideEffect); | |
60 Expect.equals(1, fooPoly(z, z)); | |
61 Expect.isTrue(sideEffect); | |
62 } | |
63 | |
64 | |
65 | |
ahe
2013/02/13 14:46:23
Extra lines.
Vyacheslav Egorov (Google)
2013/03/19 20:27:25
I will remove this.
| |
OLD | NEW |