Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [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_OPTIMIZING_COMPILER_STATS_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_OPTIMIZING_COMPILER_STATS_H_ |
| 19 | |
| 20 | #include <sstream> |
| 21 | #include <string> |
| 22 | |
| 23 | #include "atomic.h" |
| 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | enum MethodCompilationStat { |
| 28 | kAttemptCompilation = 0, |
| 29 | kCompiledBaseline, |
| 30 | kCompiledOptimized, |
Nicolas Geoffray | 12be74e | 2015-03-30 13:29:08 +0100 | [diff] [blame] | 31 | kCompiledQuick, |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 32 | kInlinedInvoke, |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 33 | kNotCompiledUnsupportedIsa, |
| 34 | kNotCompiledPathological, |
| 35 | kNotCompiledHugeMethod, |
| 36 | kNotCompiledLargeMethodNoBranches, |
| 37 | kNotCompiledCannotBuildSSA, |
| 38 | kNotCompiledNoCodegen, |
| 39 | kNotCompiledUnresolvedMethod, |
| 40 | kNotCompiledUnresolvedField, |
| 41 | kNotCompiledNonSequentialRegPair, |
Nicolas Geoffray | 36540cb | 2015-03-23 14:45:53 +0000 | [diff] [blame] | 42 | kNotCompiledSpaceFilter, |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 43 | kNotOptimizedTryCatch, |
| 44 | kNotOptimizedDisabled, |
| 45 | kNotCompiledCantAccesType, |
| 46 | kNotOptimizedRegisterAllocator, |
| 47 | kNotCompiledUnhandledInstruction, |
Calin Juravle | f1c6d9e | 2015-04-13 18:42:21 +0100 | [diff] [blame] | 48 | kNotCompiledVerifyAtRuntime, |
| 49 | kNotCompiledClassNotVerified, |
Calin Juravle | acf735c | 2015-02-12 15:25:22 +0000 | [diff] [blame] | 50 | kRemovedCheckedCast, |
| 51 | kRemovedNullCheck, |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 52 | kInstructionSimplifications, |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 53 | kLastStat |
| 54 | }; |
| 55 | |
| 56 | class OptimizingCompilerStats { |
| 57 | public: |
| 58 | OptimizingCompilerStats() {} |
| 59 | |
| 60 | void RecordStat(MethodCompilationStat stat) { |
| 61 | compile_stats_[stat]++; |
| 62 | } |
| 63 | |
| 64 | void Log() const { |
| 65 | if (compile_stats_[kAttemptCompilation] == 0) { |
| 66 | LOG(INFO) << "Did not compile any method."; |
| 67 | } else { |
| 68 | size_t unoptimized_percent = |
| 69 | compile_stats_[kCompiledBaseline] * 100 / compile_stats_[kAttemptCompilation]; |
| 70 | size_t optimized_percent = |
| 71 | compile_stats_[kCompiledOptimized] * 100 / compile_stats_[kAttemptCompilation]; |
Nicolas Geoffray | 12be74e | 2015-03-30 13:29:08 +0100 | [diff] [blame] | 72 | size_t quick_percent = |
| 73 | compile_stats_[kCompiledQuick] * 100 / compile_stats_[kAttemptCompilation]; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 74 | std::ostringstream oss; |
Nicolas Geoffray | 12be74e | 2015-03-30 13:29:08 +0100 | [diff] [blame] | 75 | oss << "Attempted compilation of " << compile_stats_[kAttemptCompilation] << " methods: "; |
| 76 | |
| 77 | oss << unoptimized_percent << "% (" << compile_stats_[kCompiledBaseline] << ") unoptimized, "; |
| 78 | oss << optimized_percent << "% (" << compile_stats_[kCompiledOptimized] << ") optimized, "; |
| 79 | oss << quick_percent << "% (" << compile_stats_[kCompiledQuick] << ") quick."; |
| 80 | |
| 81 | LOG(INFO) << oss.str(); |
| 82 | |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 83 | for (int i = 0; i < kLastStat; i++) { |
| 84 | if (compile_stats_[i] != 0) { |
Nicolas Geoffray | 12be74e | 2015-03-30 13:29:08 +0100 | [diff] [blame] | 85 | VLOG(compiler) << PrintMethodCompilationStat(i) << ": " << compile_stats_[i]; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 86 | } |
| 87 | } |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | private: |
| 92 | std::string PrintMethodCompilationStat(int stat) const { |
| 93 | switch (stat) { |
| 94 | case kAttemptCompilation : return "kAttemptCompilation"; |
| 95 | case kCompiledBaseline : return "kCompiledBaseline"; |
| 96 | case kCompiledOptimized : return "kCompiledOptimized"; |
Nicolas Geoffray | 12be74e | 2015-03-30 13:29:08 +0100 | [diff] [blame] | 97 | case kCompiledQuick : return "kCompiledQuick"; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 98 | case kInlinedInvoke : return "kInlinedInvoke"; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 99 | case kNotCompiledUnsupportedIsa : return "kNotCompiledUnsupportedIsa"; |
| 100 | case kNotCompiledPathological : return "kNotCompiledPathological"; |
| 101 | case kNotCompiledHugeMethod : return "kNotCompiledHugeMethod"; |
| 102 | case kNotCompiledLargeMethodNoBranches : return "kNotCompiledLargeMethodNoBranches"; |
| 103 | case kNotCompiledCannotBuildSSA : return "kNotCompiledCannotBuildSSA"; |
| 104 | case kNotCompiledNoCodegen : return "kNotCompiledNoCodegen"; |
| 105 | case kNotCompiledUnresolvedMethod : return "kNotCompiledUnresolvedMethod"; |
| 106 | case kNotCompiledUnresolvedField : return "kNotCompiledUnresolvedField"; |
| 107 | case kNotCompiledNonSequentialRegPair : return "kNotCompiledNonSequentialRegPair"; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 108 | case kNotOptimizedDisabled : return "kNotOptimizedDisabled"; |
| 109 | case kNotOptimizedTryCatch : return "kNotOptimizedTryCatch"; |
| 110 | case kNotCompiledCantAccesType : return "kNotCompiledCantAccesType"; |
Nicolas Geoffray | 36540cb | 2015-03-23 14:45:53 +0000 | [diff] [blame] | 111 | case kNotCompiledSpaceFilter : return "kNotCompiledSpaceFilter"; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 112 | case kNotOptimizedRegisterAllocator : return "kNotOptimizedRegisterAllocator"; |
| 113 | case kNotCompiledUnhandledInstruction : return "kNotCompiledUnhandledInstruction"; |
Calin Juravle | f1c6d9e | 2015-04-13 18:42:21 +0100 | [diff] [blame] | 114 | case kNotCompiledVerifyAtRuntime : return "kNotCompiledVerifyAtRuntime"; |
| 115 | case kNotCompiledClassNotVerified : return "kNotCompiledClassNotVerified"; |
Calin Juravle | acf735c | 2015-02-12 15:25:22 +0000 | [diff] [blame] | 116 | case kRemovedCheckedCast: return "kRemovedCheckedCast"; |
| 117 | case kRemovedNullCheck: return "kRemovedNullCheck"; |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 118 | case kInstructionSimplifications: return "kInstructionSimplifications"; |
Calin Juravle | 48c2b03 | 2014-12-09 18:11:36 +0000 | [diff] [blame] | 119 | default: LOG(FATAL) << "invalid stat"; |
| 120 | } |
| 121 | return ""; |
| 122 | } |
| 123 | |
| 124 | AtomicInteger compile_stats_[kLastStat]; |
| 125 | |
| 126 | DISALLOW_COPY_AND_ASSIGN(OptimizingCompilerStats); |
| 127 | }; |
| 128 | |
| 129 | } // namespace art |
| 130 | |
| 131 | #endif // ART_COMPILER_OPTIMIZING_OPTIMIZING_COMPILER_STATS_H_ |