blob: e3117eb5ee249f04b4b4e491bfec3d71f06d2b26 [file] [log] [blame]
Calin Juravle31f2c152015-10-23 17:56:15 +01001/*
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
26namespace art {
27
28class 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 */
36class 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
Nicolas Geoffray9fdb1292015-12-02 22:44:52 +000053 // singe thread?)
Calin Juravle31f2c152015-10-23 17:56:15 +010054 Atomic<uint64_t> last_update_time_ns_;
55};
56
Calin Juravle31f2c152015-10-23 17:56:15 +010057} // namespace art
58
59#endif // ART_RUNTIME_JIT_OFFLINE_PROFILING_INFO_H_