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

Unified Diff: tests/vm/dart/inline_stack_frame_test.dart

Issue 11781007: Added a test to ensure that stack frames are reported correctly when an exception is thrown in a ch… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | « no previous file | tests/vm/vm.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/vm/dart/inline_stack_frame_test.dart
===================================================================
--- tests/vm/dart/inline_stack_frame_test.dart (revision 0)
+++ tests/vm/dart/inline_stack_frame_test.dart (revision 0)
@@ -0,0 +1,74 @@
+// 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.
+
+// This test tries to verify that we produce the correct stack trace when
+// throwing exceptions even when functions are inlined.
+// The test invokes a bunch of functions and then does a throw. There is a
+// catch at the outer function which uses the stack trace produced to return
+// a string. The test then verifies that the stack trace contains each
+// method in the invocation chain. The test is run during warmup to ensure
+// unoptimized code produces the correct result and is then run
+// in a loop to ensure optimization kicks in and some inlining is done.
+// Note: it appears that functions which have a throw are not inlined (func4)
+// func2 and func1 are not getting inlined and I am not able to explain
Florian Schneider 2013/01/08 09:31:37 func1 contains try-catch which is not supported by
siva 2013/01/08 18:06:46 Thanks for the explanation. Will update the commen
+// why inlining is not attempted on those.
+
+class Test {
+ String func1(var k) {
+ try {
+ for (var i = 0; i <= 50; i++) {
+ func2(i * k);
+ }
+ return "";
+ } catch (e, stacktrace) {
+ var result = e.concat(stacktrace.toString());
+ return result;
+ }
+ }
+ int func2(var i) {
+ var result = 0;
+ for (var k = 0; k <= 10; k++) {
+ result += func2a(i + k);
+ }
+ return result;
+ }
+ int func2a(var i) {
+ var result = 0;
+ for (var l = 0; l <= 1; l++) {
+ result += func3(i + l);
+ }
+ return result;
+ }
+ int func3(var i) {
+ var result = 0;
+ for (var j = 0; j <= 10; j++) {
+ result += func4(i + j);
+ }
+ return result;
+ }
+ int func4(var i) {
+ if (i >= 1030) throw "show me inlined functions";
+ return i;
+ }
+}
+
+main() {
+ var x = new Test();
+ var result = x.func1(100000);
+ Expect.isTrue(result.contains("show me inlined functions"));
+ Expect.isTrue(result.contains("Test.func1"));
+ Expect.isTrue(result.contains("Test.func2"));
+ Expect.isTrue(result.contains("Test.func2a"));
+ Expect.isTrue(result.contains("Test.func3"));
+ Expect.isTrue(result.contains("Test.func4"));
+ for (var i = 0; i <= 200; i++) {
+ result = x.func1(i);
+ }
+ Expect.isTrue(result.contains("show me inlined functions"));
+ Expect.isTrue(result.contains("Test.func1"));
+ Expect.isTrue(result.contains("Test.func2"));
+ Expect.isTrue(result.contains("Test.func2a"));
+ Expect.isTrue(result.contains("Test.func3"));
+ Expect.isTrue(result.contains("Test.func4"));
+}
« no previous file with comments | « no previous file | tests/vm/vm.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698