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

Unified Diff: tests/language/src/OptimizationTest.dart

Issue 8972005: More optimizations cleanup. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/stub_code_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/src/OptimizationTest.dart
===================================================================
--- tests/language/src/OptimizationTest.dart (revision 0)
+++ tests/language/src/OptimizationTest.dart (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (c) 2011, 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.
+// Test various optimizations and deoptimizations of optimizing compiler..
+
+addThem(a, b) {
+ return a + b;
+}
+
+isItInt(a) {
+ return a is int;
+}
+
+doNeg(a) {
+ return -a;
+}
+
+doNot(a) {
+ return !a;
+}
+
+doBitNot(a) {
+ return ~a;
+}
+
+main() {
+ for (int i = 0; i < 2000; i++) {
+ Expect.stringEquals("HI 5", addThem("HI ", 5));
+ Expect.equals(true, isItInt(5));
+ }
+ Expect.equals(8, addThem(3, 5));
+ for (int i = 0; i < 2000; i++) {
+ Expect.stringEquals("HI 5", addThem("HI ", 5));
+ Expect.equals(8, addThem(3, 5));
+ }
+ for (int i = -500; i < 500; i++) {
+ var r = doNeg(i);
+ var p = doNeg(r);
+ Expect.equals(i, p);
+ }
+ var maxSmi = (1 << 30) - 1;
+ Expect.equals(maxSmi, doNeg(doNeg(maxSmi)));
+ // Deoptimize because of overflow.
+ var minInt = -(1 << 30);
+ Expect.equals(minInt, doNeg(doNeg(minInt)));
+
+ for (int i = 0; i < 1000; i++) {
+ Expect.equals(false, doNot(true));
+ Expect.equals(true, doNot(doNot(true)));
+ }
+ for (int i = 0; i < 1000; i++) {
+ Expect.equals(-57, doBitNot(56));
+ Expect.equals(55, doBitNot(-56));
+ }
+}
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698