| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library tracer; | 5 library tracer; |
| 6 | 6 |
| 7 import '../compiler_new.dart' as api; | 7 import '../compiler_new.dart' as api; |
| 8 import 'compiler.dart' show Compiler; | |
| 9 import 'js_backend/namer.dart' show Namer; | 8 import 'js_backend/namer.dart' show Namer; |
| 10 import 'ssa/nodes.dart' as ssa show HGraph; | 9 import 'ssa/nodes.dart' as ssa show HGraph; |
| 11 import 'ssa/ssa_tracer.dart' show HTracer; | 10 import 'ssa/ssa_tracer.dart' show HTracer; |
| 12 import 'util/util.dart' show Indentation; | 11 import 'util/util.dart' show Indentation; |
| 13 import 'world.dart' show ClosedWorld; | 12 import 'world.dart' show ClosedWorld; |
| 14 | 13 |
| 15 /** | 14 /** |
| 16 * If non-null, we only trace methods whose name match the regexp defined by the | 15 * If non-null, we only trace methods whose name match the regexp defined by the |
| 17 * given pattern. | 16 * given pattern. |
| 18 */ | 17 */ |
| 19 String get TRACE_FILTER_PATTERN => | 18 String get TRACE_FILTER_PATTERN => |
| 20 TRACE_FILTER_PATTERN_FROM_ENVIRONMENT ?? TRACE_FILTER_PATTERN_FOR_TEST; | 19 TRACE_FILTER_PATTERN_FROM_ENVIRONMENT ?? TRACE_FILTER_PATTERN_FOR_TEST; |
| 21 | 20 |
| 22 const String TRACE_FILTER_PATTERN_FROM_ENVIRONMENT = | 21 const String TRACE_FILTER_PATTERN_FROM_ENVIRONMENT = |
| 23 const String.fromEnvironment("DUMP_IR"); | 22 const String.fromEnvironment("DUMP_IR"); |
| 24 String TRACE_FILTER_PATTERN_FOR_TEST; | 23 String TRACE_FILTER_PATTERN_FOR_TEST; |
| 25 | 24 |
| 26 /** | 25 /** |
| 27 * Dumps the intermediate representation after each phase in a format | 26 * Dumps the intermediate representation after each phase in a format |
| 28 * readable by IR Hydra. | 27 * readable by IR Hydra. |
| 29 */ | 28 */ |
| 30 class Tracer extends TracerUtil { | 29 class Tracer extends TracerUtil { |
| 31 final ClosedWorld closedWorld; | 30 final ClosedWorld closedWorld; |
| 32 final Namer namer; | 31 final Namer namer; |
| 33 bool traceActive = false; | 32 bool traceActive = false; |
| 34 final api.OutputSink output; | 33 final api.OutputSink output; |
| 35 final RegExp traceFilter; | 34 final RegExp traceFilter; |
| 36 | 35 |
| 37 Tracer(this.closedWorld, this.namer, Compiler compiler) | 36 Tracer(this.closedWorld, this.namer, api.CompilerOutput compilerOutput) |
| 38 : traceFilter = TRACE_FILTER_PATTERN == null | 37 : traceFilter = TRACE_FILTER_PATTERN == null |
| 39 ? null | 38 ? null |
| 40 : new RegExp(TRACE_FILTER_PATTERN), | 39 : new RegExp(TRACE_FILTER_PATTERN), |
| 41 output = TRACE_FILTER_PATTERN != null | 40 output = TRACE_FILTER_PATTERN != null |
| 42 ? compiler.outputProvider('dart', 'cfg', api.OutputType.debug) | 41 ? compilerOutput.createOutputSink( |
| 42 'dart', 'cfg', api.OutputType.debug) |
| 43 : null; | 43 : null; |
| 44 | 44 |
| 45 bool get isEnabled => traceFilter != null; | 45 bool get isEnabled => traceFilter != null; |
| 46 | 46 |
| 47 void traceCompilation(String methodName) { | 47 void traceCompilation(String methodName) { |
| 48 if (!isEnabled) return; | 48 if (!isEnabled) return; |
| 49 traceActive = traceFilter.hasMatch(methodName); | 49 traceActive = traceFilter.hasMatch(methodName); |
| 50 if (!traceActive) return; | 50 if (!traceActive) return; |
| 51 tag("compilation", () { | 51 tag("compilation", () { |
| 52 printProperty("name", methodName); | 52 printProperty("name", methodName); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 void add(String string) { | 108 void add(String string) { |
| 109 output.add(string); | 109 output.add(string); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void addIndent() { | 112 void addIndent() { |
| 113 add(_ind.indentation); | 113 add(_ind.indentation); |
| 114 } | 114 } |
| 115 } | 115 } |
| OLD | NEW |