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

Unified Diff: tests/language/try_catch_osr_test.dart

Issue 335793003: Enable OSR optimization for functions with try-catch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: improved tests Created 6 years, 6 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 | « tests/language/try_catch_optimized3_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/try_catch_osr_test.dart
===================================================================
--- tests/language/try_catch_osr_test.dart (revision 0)
+++ tests/language/try_catch_osr_test.dart (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (c) 2013, 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
+
+// Test OSR in different places of a try-catch.
+
+import "package:expect/expect.dart";
+
+maythrow(x) {
+ try {
+ if (x == null) throw 42;
+ return 99;
+ } finally { }
+}
+
+f1() {
+ var s = 0, t = "abc";
+ for (var i = 0; i < 21; ++i) {
+ s += i;
+ }
+ try {
+ maythrow(null);
+ } catch (e) {
+ Expect.equals("abc", t);
+ Expect.equals(42, e);
+ s++;
+ }
+ return s;
+}
+
+f2([x = 1]) {
+ var s = 0, t = "abc";
+ try {
+ try {
+ for (var i = 0; i < 20; ++i) {
+ if (i == 18) maythrow(null);
+ s += x;
+ }
+ } catch (e) {
+ Expect.equals(1, x);
+ Expect.equals("abc", t);
+ Expect.equals(42, e);
+ s++;
+ }
+ } catch (e) { }
+ return s;
+}
+
+f3() {
+ var s = 0, t = "abc";
+ try {
+ maythrow(null);
+ } catch (e) {
+ Expect.equals("abc", t);
+ for (var i = 0; i < 21; ++i) {
+ s += i;
+ }
+ Expect.equals("abc", t);
+ Expect.equals(42, e);
+ return s;
+ }
+}
+
+f4() {
+ var s = 0, t = "abc";
+ try {
+ for (var i = 0; i < 21; ++i) {
+ if (i == 18) maythrow(null);
+ s += i;
+ }
+ } catch (e) {
+ Expect.equals("abc", t);
+ Expect.equals(42, e);
+ s++;
+ }
+ return s;
+}
+
+f5() {
+ var s, t = "abc";
+ try {
+ maythrow(null);
+ } catch (e) {
+ Expect.equals("abc", t);
+ Expect.equals(42, e);
+ s = 0;
+ }
+ for (var i = 0; i < 21; ++i) {
+ s += i;
+ }
+ Expect.equals("abc", t);
+ return s;
+}
+
+main() {
+ Expect.equals(211, f1());
+ Expect.equals(19, f2());
+ Expect.equals(210, f3());
+ Expect.equals(9 * 17 + 1, f4());
+ Expect.equals(210, f5());
+}
« no previous file with comments | « tests/language/try_catch_optimized3_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698