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

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

Issue 21013005: Optimize equuality operation for two Boolean arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 8
9 class A { 9 class A {
10 bool _result; 10 bool _result;
11 A(this._result); 11 A(this._result);
12 operator ==(x) { return _result; } 12 operator ==(x) { return _result; }
13 } 13 }
14 14
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 if (death() == nullFn()) { 47 if (death() == nullFn()) {
48 throw "failed"; 48 throw "failed";
49 } 49 }
50 if (death() != nullFn()) { 50 if (death() != nullFn()) {
51 } else { 51 } else {
52 throw "failed"; 52 throw "failed";
53 } 53 }
54 } 54 }
55 55
56 boolEqualityPositiveA(a) => a == true;
57 boolEqualityNegativeA(a) => a != true;
58
59 boolEqualityPositiveB(a) => true == a;
60 boolEqualityNegativeB(a) => true != a;
61
56 main() { 62 main() {
57 for (int i = 0; i < 20; i++) tests(); 63 for (int i = 0; i < 20; i++) {
64 tests();
65 // Do not inline calls to prevent constant folding.
66 Expect.isTrue(boolEqualityPositiveA(true));
67 Expect.isFalse(boolEqualityPositiveA(false));
68 Expect.isFalse(boolEqualityNegativeA(true));
69 Expect.isTrue(boolEqualityNegativeA(false));
70
71 Expect.isTrue(boolEqualityPositiveB(true));
72 Expect.isFalse(boolEqualityPositiveB(false));
73 Expect.isFalse(boolEqualityNegativeB(true));
74 Expect.isTrue(boolEqualityNegativeB(false));
75 }
76
77 // Deoptimize.
78 Expect.isFalse(boolEqualityPositiveA(1));
79 Expect.isTrue(boolEqualityNegativeA("hi"));
80 Expect.isFalse(boolEqualityPositiveB(2.0));
81 Expect.isTrue(boolEqualityNegativeB([]));
58 } 82 }
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698