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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/equality_test.dart
===================================================================
--- tests/language/equality_test.dart (revision 25632)
+++ tests/language/equality_test.dart (working copy)
@@ -1,7 +1,7 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// VMOptions=--optimization-counter-threshold=10
+// VMOptions=--optimization-counter-threshold=10 --no-use-osr
import "package:expect/expect.dart";
@@ -53,6 +53,30 @@
}
}
+boolEqualityPositiveA(a) => a == true;
+boolEqualityNegativeA(a) => a != true;
+
+boolEqualityPositiveB(a) => true == a;
+boolEqualityNegativeB(a) => true != a;
+
main() {
- for (int i = 0; i < 20; i++) tests();
+ for (int i = 0; i < 20; i++) {
+ tests();
+ // Do not inline calls to prevent constant folding.
+ Expect.isTrue(boolEqualityPositiveA(true));
+ Expect.isFalse(boolEqualityPositiveA(false));
+ Expect.isFalse(boolEqualityNegativeA(true));
+ Expect.isTrue(boolEqualityNegativeA(false));
+
+ Expect.isTrue(boolEqualityPositiveB(true));
+ Expect.isFalse(boolEqualityPositiveB(false));
+ Expect.isFalse(boolEqualityNegativeB(true));
+ Expect.isTrue(boolEqualityNegativeB(false));
+ }
+
+ // Deoptimize.
+ Expect.isFalse(boolEqualityPositiveA(1));
+ Expect.isTrue(boolEqualityNegativeA("hi"));
+ Expect.isFalse(boolEqualityPositiveB(2.0));
+ Expect.isTrue(boolEqualityNegativeB([]));
}
« 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