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

Side by Side Diff: runtime/tests/vm/dart/inline_stack_frame_test.dart

Issue 11783035: Fix comment in test case. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 4
5 // This test tries to verify that we produce the correct stack trace when 5 // This test tries to verify that we produce the correct stack trace when
6 // throwing exceptions even when functions are inlined. 6 // throwing exceptions even when functions are inlined.
7 // The test invokes a bunch of functions and then does a throw. There is a 7 // The test invokes a bunch of functions and then does a throw. There is a
8 // catch at the outer function which uses the stack trace produced to return 8 // catch at the outer function which uses the stack trace produced to return
9 // a string. The test then verifies that the stack trace contains each 9 // a string. The test then verifies that the stack trace contains each
10 // method in the invocation chain. The test is run during warmup to ensure 10 // method in the invocation chain. The test is run during warmup to ensure
11 // unoptimized code produces the correct result and is then run 11 // unoptimized code produces the correct result and is then run
12 // in a loop to ensure optimization kicks in and some inlining is done. 12 // in a loop to ensure optimization kicks in and some inlining is done.
13 // Note: it appears that functions which have a throw are not inlined (func4) 13 // Note: it appears that functions which have a throw are not inlined (func4)
14 // func2 and func1 are not getting inlined and I am not able to explain 14 // and functions that have try/catch in them are not optimized (func1).
15 // why inlining is not attempted on those. 15 // func2 is not inlined as func1 has not been optimized.
16 16
17 class Test { 17 class Test {
18 String func1(var k) { 18 String func1(var k) {
19 try { 19 try {
20 for (var i = 0; i <= 50; i++) { 20 for (var i = 0; i <= 50; i++) {
21 func2(i * k); 21 func2(i * k);
22 } 22 }
23 return ""; 23 return "";
24 } catch (e, stacktrace) { 24 } catch (e, stacktrace) {
25 var result = e.concat(stacktrace.toString()); 25 var result = e.concat(stacktrace.toString());
26 return result; 26 return result;
27 } 27 }
28 } 28 }
29 int func2(var i) { 29 int func2(var i) {
30 var result = 0; 30 var result = 0;
31 for (var k = 0; k <= 10; k++) { 31 for (var k = 0; k <= 10; k++) {
32 result += func2a(i + k); 32 result += func3(i + k);
33 }
34 return result;
35 }
36 int func2a(var i) {
37 var result = 0;
38 for (var l = 0; l <= 1; l++) {
39 result += func3(i + l);
40 } 33 }
41 return result; 34 return result;
42 } 35 }
43 int func3(var i) { 36 int func3(var i) {
44 var result = 0; 37 var result = 0;
45 for (var j = 0; j <= 10; j++) { 38 for (var l = 0; l <= 1; l++) {
46 result += func4(i + j); 39 result += func4(i + l);
47 } 40 }
48 return result; 41 return result;
49 } 42 }
50 int func4(var i) { 43 int func4(var i) {
44 var result = 0;
45 for (var j = 0; j <= 10; j++) {
46 result += func5(i + j);
47 }
48 return result;
49 }
50 int func5(var i) {
51 if (i >= 1030) throw "show me inlined functions"; 51 if (i >= 1030) throw "show me inlined functions";
52 return i; 52 return i;
53 } 53 }
54 } 54 }
55 55
56 main() { 56 main() {
57 var x = new Test(); 57 var x = new Test();
58 var result = x.func1(100000); 58 var result = x.func1(100000);
59 Expect.isTrue(result.contains("show me inlined functions")); 59 Expect.isTrue(result.contains("show me inlined functions"));
60 Expect.isTrue(result.contains("Test.func1")); 60 Expect.isTrue(result.contains("Test.func1"));
61 Expect.isTrue(result.contains("Test.func2")); 61 Expect.isTrue(result.contains("Test.func2"));
62 Expect.isTrue(result.contains("Test.func2a"));
63 Expect.isTrue(result.contains("Test.func3")); 62 Expect.isTrue(result.contains("Test.func3"));
64 Expect.isTrue(result.contains("Test.func4")); 63 Expect.isTrue(result.contains("Test.func4"));
64 Expect.isTrue(result.contains("Test.func5"));
65 for (var i = 0; i <= 200; i++) { 65 for (var i = 0; i <= 200; i++) {
66 result = x.func1(i); 66 result = x.func1(i);
67 } 67 }
68 Expect.isTrue(result.contains("show me inlined functions")); 68 Expect.isTrue(result.contains("show me inlined functions"));
69 Expect.isTrue(result.contains("Test.func1")); 69 Expect.isTrue(result.contains("Test.func1"));
70 Expect.isTrue(result.contains("Test.func2")); 70 Expect.isTrue(result.contains("Test.func2"));
71 Expect.isTrue(result.contains("Test.func2a"));
72 Expect.isTrue(result.contains("Test.func3")); 71 Expect.isTrue(result.contains("Test.func3"));
73 Expect.isTrue(result.contains("Test.func4")); 72 Expect.isTrue(result.contains("Test.func4"));
73 Expect.isTrue(result.contains("Test.func5"));
74 } 74 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698