Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ |
| 19 | |
| 20 | #include "utils/allocation.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame^] | 24 | class CodeGenerator; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 25 | class DexCompilationUnit; |
| 26 | class HGraph; |
| 27 | |
| 28 | /** |
| 29 | * If enabled, emits compilation information suitable for the c1visualizer tool |
| 30 | * and IRHydra. |
| 31 | * Currently only works if the compiler is single threaded. |
| 32 | */ |
| 33 | class HGraphVisualizer : public ValueObject { |
| 34 | public: |
| 35 | /** |
| 36 | * If output is not null, and the method name of the dex compilation |
| 37 | * unit contains `string_filter`, the compilation information will be |
| 38 | * emitted. |
| 39 | */ |
| 40 | HGraphVisualizer(std::ostream* output, |
| 41 | HGraph* graph, |
| 42 | const char* string_filter, |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame^] | 43 | const CodeGenerator& codegen, |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 44 | const DexCompilationUnit& cu); |
| 45 | |
| 46 | /** |
Nicolas Geoffray | 0d3f578 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 47 | * Version of `HGraphVisualizer` for unit testing, that is when a |
| 48 | * `DexCompilationUnit` is not available. |
| 49 | */ |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame^] | 50 | HGraphVisualizer(std::ostream* output, |
| 51 | HGraph* graph, |
| 52 | const CodeGenerator& codegen, |
| 53 | const char* name); |
Nicolas Geoffray | 0d3f578 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 54 | |
| 55 | /** |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 56 | * If this visualizer is enabled, emit the compilation information |
| 57 | * in `output_`. |
| 58 | */ |
| 59 | void DumpGraph(const char* pass_name); |
| 60 | |
| 61 | private: |
| 62 | std::ostream* const output_; |
| 63 | HGraph* const graph_; |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame^] | 64 | const CodeGenerator& codegen_; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 65 | |
| 66 | // Is true when `output_` is not null, and the compiled method's name |
| 67 | // contains the string_filter given in the constructor. |
| 68 | bool is_enabled_; |
| 69 | |
| 70 | DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer); |
| 71 | }; |
| 72 | |
| 73 | } // namespace art |
| 74 | |
| 75 | #endif // ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ |