| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Dart test program testing code GC. | 5 // Dart test program testing code GC. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import "dart:async"; | 8 import "dart:async"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 bar(); | 37 bar(); |
| 38 if (i > 1) { | 38 if (i > 1) { |
| 39 timer.cancel(); | 39 timer.cancel(); |
| 40 // foo is called again to make sure we can still run it even after | 40 // foo is called again to make sure we can still run it even after |
| 41 // its code has been detached. | 41 // its code has been detached. |
| 42 var ret = foo(2); | 42 var ret = foo(2); |
| 43 } | 43 } |
| 44 }); | 44 }); |
| 45 } | 45 } |
| 46 | 46 |
| 47 List<String> packageOptions() { |
| 48 if (Platform.packageRoot != null) { |
| 49 return <String>['--package-root=${Platform.packageRoot}']; |
| 50 } else if (Platform.packageConfig != null) { |
| 51 return <String>['--packages=${Platform.packageConfig}']; |
| 52 } else { |
| 53 return <String>[]; |
| 54 } |
| 55 } |
| 47 | 56 |
| 48 main(List<String> arguments) { | 57 main(List<String> arguments) { |
| 49 if (arguments.contains("--run")) { | 58 if (arguments.contains("--run")) { |
| 50 doTest(); | 59 doTest(); |
| 51 } else { | 60 } else { |
| 52 // Run the test and capture stdout. | 61 // Run the test and capture stdout. |
| 53 var pr = Process.runSync(Platform.executable, | 62 var args = packageOptions(); |
| 54 ["--verbose-gc", | 63 args.addAll(["--verbose-gc", |
| 55 "--collect-code", | 64 "--collect-code", |
| 56 "--code-collection-interval-in-us=0", | 65 "--code-collection-interval-in-us=0", |
| 57 "--old_gen_growth_rate=10", | 66 "--old_gen_growth_rate=10", |
| 58 "--log-code-drop", | 67 "--log-code-drop", |
| 59 "--optimization-counter-threshold=-1", | 68 "--optimization-counter-threshold=-1", |
| 60 "--package-root=${Platform.packageRoot}", | |
| 61 Platform.script.toFilePath(), | 69 Platform.script.toFilePath(), |
| 62 "--run"]); | 70 "--run"]); |
| 71 var pr = Process.runSync(Platform.executable, args); |
| 63 | 72 |
| 64 Expect.equals(0, pr.exitCode); | 73 Expect.equals(0, pr.exitCode); |
| 65 | 74 |
| 66 // Code drops are logged with --log-code-drop. Look through stdout for the | 75 // Code drops are logged with --log-code-drop. Look through stdout for the |
| 67 // message that foo's code was dropped. | 76 // message that foo's code was dropped. |
| 68 print(pr.stdout); | 77 print(pr.stdout); |
| 69 var count = 0; | 78 var count = 0; |
| 70 pr.stdout.split("\n").forEach((line) { | 79 pr.stdout.split("\n").forEach((line) { |
| 71 if (line.contains("foo=2")) { | 80 if (line.contains("foo=2")) { |
| 72 Expect.equals(0, count); | 81 Expect.equals(0, count); |
| 73 count++; | 82 count++; |
| 74 } | 83 } |
| 75 if (line.contains("Detaching code") && line.contains("foo")) { | 84 if (line.contains("Detaching code") && line.contains("foo")) { |
| 76 Expect.equals(1, count); | 85 Expect.equals(1, count); |
| 77 count++; | 86 count++; |
| 78 } | 87 } |
| 79 if (line.contains("foo=3")) { | 88 if (line.contains("foo=3")) { |
| 80 Expect.equals(2, count); | 89 Expect.equals(2, count); |
| 81 count++; | 90 count++; |
| 82 } | 91 } |
| 83 }); | 92 }); |
| 84 Expect.equals(3, count); | 93 Expect.equals(3, count); |
| 85 } | 94 } |
| 86 } | 95 } |
| OLD | NEW |