Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2015 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_RUNTIME_JIT_OFFLINE_PROFILING_INFO_H_ |
| 18 | #define ART_RUNTIME_JIT_OFFLINE_PROFILING_INFO_H_ |
| 19 | |
| 20 | #include <set> |
| 21 | |
| 22 | #include "atomic.h" |
| 23 | #include "dex_file.h" |
| 24 | #include "safe_map.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | class ArtMethod; |
| 29 | |
| 30 | /** |
| 31 | * Profiling information in a format that can be serialized to disk. |
| 32 | * It is a serialize-friendly format based on information collected |
| 33 | * by the interpreter (ProfileInfo). |
| 34 | * Currently it stores only the hot compiled methods. |
| 35 | */ |
| 36 | class OfflineProfilingInfo { |
| 37 | public: |
| 38 | bool NeedsSaving(uint64_t last_update_time_ns) const; |
| 39 | void SaveProfilingInfo(const std::string& filename, |
| 40 | uint64_t last_update_time_ns, |
| 41 | const std::set<ArtMethod*>& methods); |
| 42 | |
| 43 | private: |
| 44 | // Map identifying the location of the profiled methods. |
| 45 | // dex_file_ -> [dex_method_index]+ |
| 46 | using DexFileToMethodsMap = SafeMap<const DexFile*, std::set<uint32_t>>; |
| 47 | |
| 48 | void AddMethodInfo(ArtMethod* method, DexFileToMethodsMap* info) |
| 49 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 50 | bool Serialize(const std::string& filename, const DexFileToMethodsMap& info) const; |
| 51 | |
| 52 | // TODO(calin): Verify if Atomic is really needed (are we sure to be called from a |
| 53 | // singe thread?) |
| 54 | Atomic<uint64_t> last_update_time_ns_; |
| 55 | }; |
| 56 | |
| 57 | } // namespace art |
| 58 | |
| 59 | #endif // ART_RUNTIME_JIT_OFFLINE_PROFILING_INFO_H_ |