| 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 |
| 6 |
| 5 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 6 | 8 |
| 7 // This test tries to verify that we produce the correct stack trace when | 9 // This test tries to verify that we produce the correct stack trace when |
| 8 // throwing exceptions even when functions are inlined. | 10 // throwing exceptions even when functions are inlined. |
| 9 // The test invokes a bunch of functions and then does a throw. There is a | 11 // 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 | 12 // catch at the outer function which uses the stack trace produced to return |
| 11 // a string. The test then verifies that the stack trace contains each | 13 // a string. The test then verifies that the stack trace contains each |
| 12 // method in the invocation chain. The test is run during warmup to ensure | 14 // method in the invocation chain. The test is run during warmup to ensure |
| 13 // unoptimized code produces the correct result and is then run | 15 // unoptimized code produces the correct result and is then run |
| 14 // in a loop to ensure optimization kicks in and some inlining is done. | 16 // in a loop to ensure optimization kicks in and some inlining is done. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 43 return result; | 45 return result; |
| 44 } | 46 } |
| 45 int func4(var i) { | 47 int func4(var i) { |
| 46 var result = 0; | 48 var result = 0; |
| 47 for (var j = 0; j <= 10; j++) { | 49 for (var j = 0; j <= 10; j++) { |
| 48 result += func5(i + j); | 50 result += func5(i + j); |
| 49 } | 51 } |
| 50 return result; | 52 return result; |
| 51 } | 53 } |
| 52 int func5(var i) { | 54 int func5(var i) { |
| 53 if (i >= 1030) throw "show me inlined functions"; | 55 if (i >= 520) throw "show me inlined functions"; |
| 54 return i; | 56 return i; |
| 55 } | 57 } |
| 56 } | 58 } |
| 57 | 59 |
| 58 main() { | 60 main() { |
| 59 var x = new Test(); | 61 var x = new Test(); |
| 60 var result = x.func1(100000); | 62 var result = x.func1(100000); |
| 61 Expect.isTrue(result.contains("show me inlined functions")); | 63 Expect.isTrue(result.contains("show me inlined functions")); |
| 62 Expect.isTrue(result.contains("Test.func1")); | 64 Expect.isTrue(result.contains("Test.func1")); |
| 63 Expect.isTrue(result.contains("Test.func2")); | 65 Expect.isTrue(result.contains("Test.func2")); |
| 64 Expect.isTrue(result.contains("Test.func3")); | 66 Expect.isTrue(result.contains("Test.func3")); |
| 65 Expect.isTrue(result.contains("Test.func4")); | 67 Expect.isTrue(result.contains("Test.func4")); |
| 66 Expect.isTrue(result.contains("Test.func")); | 68 Expect.isTrue(result.contains("Test.func")); |
| 67 for (var i = 0; i <= 200; i++) { | 69 for (var i = 0; i <= 10; i++) { |
| 68 result = x.func1(i); | 70 result = x.func1(i); |
| 69 } | 71 } |
| 70 Expect.isTrue(result.contains("show me inlined functions")); | 72 Expect.isTrue(result.contains("show me inlined functions")); |
| 71 Expect.isTrue(result.contains("Test.func1")); | 73 Expect.isTrue(result.contains("Test.func1")); |
| 72 Expect.isTrue(result.contains("Test.func2")); | 74 Expect.isTrue(result.contains("Test.func2")); |
| 73 Expect.isTrue(result.contains("Test.func3")); | 75 Expect.isTrue(result.contains("Test.func3")); |
| 74 Expect.isTrue(result.contains("Test.func4")); | 76 Expect.isTrue(result.contains("Test.func4")); |
| 75 Expect.isTrue(result.contains("Test.func5")); | 77 Expect.isTrue(result.contains("Test.func5")); |
| 76 } | 78 } |
| OLD | NEW |