OLD | NEW |
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 // VMOptions=--optimization_counter_threshold=10 --no-background-compilation | 5 // VMOptions=--optimization_counter_threshold=10 --no-background-compilation |
6 | 6 |
7 // This test tries to verify that we produce the correct stack trace when | 7 // This test tries to verify that we produce the correct stack trace when |
8 // throwing exceptions even when functions are inlined. | 8 // throwing exceptions even when functions are inlined. |
9 // The test invokes a bunch of functions and then does a throw. There is a | 9 // The test invokes a bunch of functions and then does a throw. There is a |
10 // catch at the outer function which uses the stack trace produced to return | 10 // catch at the outer function which uses the stack trace produced to return |
(...skipping 10 matching lines...) Expand all Loading... |
21 try { | 21 try { |
22 for (var i = 0; i <= 50; i++) { | 22 for (var i = 0; i <= 50; i++) { |
23 func2(i * k); | 23 func2(i * k); |
24 } | 24 } |
25 return ""; | 25 return ""; |
26 } catch (e, stacktrace) { | 26 } catch (e, stacktrace) { |
27 var result = e + "\n" + stacktrace.toString(); | 27 var result = e + "\n" + stacktrace.toString(); |
28 return result; | 28 return result; |
29 } | 29 } |
30 } | 30 } |
31 | |
32 int func2(var i) { | 31 int func2(var i) { |
33 var result = 0; | 32 var result = 0; |
34 for (var k = 0; k <= 10; k++) { | 33 for (var k = 0; k <= 10; k++) { |
35 result += func3(i + k); | 34 result += func3(i + k); |
36 } | 35 } |
37 return result; | 36 return result; |
38 } | 37 } |
39 | |
40 int func3(var i) { | 38 int func3(var i) { |
41 var result = 0; | 39 var result = 0; |
42 for (var l = 0; l <= 1; l++) { | 40 for (var l = 0; l <= 1; l++) { |
43 result += func4(i + l); | 41 result += func4(i + l); |
44 } | 42 } |
45 return result; | 43 return result; |
46 } | 44 } |
47 | |
48 int func4(var i) { | 45 int func4(var i) { |
49 var result = 0; | 46 var result = 0; |
50 for (var j = 0; j <= 10; j++) { | 47 for (var j = 0; j <= 10; j++) { |
51 result += func5(i + j); | 48 result += func5(i + j); |
52 } | 49 } |
53 return result; | 50 return result; |
54 } | 51 } |
55 | |
56 int func5(var i) { | 52 int func5(var i) { |
57 if (i >= 520) throw "show me inlined functions"; | 53 if (i >= 520) throw "show me inlined functions"; |
58 return i; | 54 return i; |
59 } | 55 } |
60 } | 56 } |
61 | 57 |
62 expectHasSubstring(String string, String substring) { | 58 expectHasSubstring(String string, String substring) { |
63 if (!string.contains(substring)) { | 59 if (!string.contains(substring)) { |
64 var sb = new StringBuffer(); | 60 var sb = new StringBuffer(); |
65 sb.writeln("Expect string:"); | 61 sb.writeln("Expect string:"); |
(...skipping 16 matching lines...) Expand all Loading... |
82 for (var i = 0; i <= 10; i++) { | 78 for (var i = 0; i <= 10; i++) { |
83 result = x.func1(i); | 79 result = x.func1(i); |
84 } | 80 } |
85 expectHasSubstring(result, "show me inlined functions"); | 81 expectHasSubstring(result, "show me inlined functions"); |
86 expectHasSubstring(result, "Test.func1"); | 82 expectHasSubstring(result, "Test.func1"); |
87 expectHasSubstring(result, "Test.func2"); | 83 expectHasSubstring(result, "Test.func2"); |
88 expectHasSubstring(result, "Test.func3"); | 84 expectHasSubstring(result, "Test.func3"); |
89 expectHasSubstring(result, "Test.func4"); | 85 expectHasSubstring(result, "Test.func4"); |
90 expectHasSubstring(result, "Test.func5"); | 86 expectHasSubstring(result, "Test.func5"); |
91 } | 87 } |
OLD | NEW |