blob: ad5e2163cf9e9772bc3d36dec3e3789c18f6c009 [file] [log] [blame]
Calin Juravle998c2162015-12-21 15:39:33 +02001/*
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_COMPILER_PROFILE_ASSISTANT_H_
18#define ART_COMPILER_PROFILE_ASSISTANT_H_
19
20#include <string>
21#include <vector>
22
Calin Juravle877fd962016-01-05 14:29:29 +000023#include "base/scoped_flock.h"
Calin Juravle998c2162015-12-21 15:39:33 +020024#include "jit/offline_profiling_info.cc"
25
26namespace art {
27
28class ProfileAssistant {
29 public:
30 // Process the profile information present in the given files. Returns true
31 // if the analysis ended up successfully (i.e. no errors during reading,
32 // merging or writing of profile files).
33 //
34 // If the returned value is true and there is a significant difference between
35 // profile_files and reference_profile_files:
36 // - profile_compilation_info is set to a not null object that
37 // can be used to drive compilation. It will be the merge of all the data
38 // found in profile_files and reference_profile_files.
39 // - the data from profile_files[i] is merged into
40 // reference_profile_files[i] and the corresponding backing file is
41 // updated.
42 //
43 // If the returned value is false or the difference is insignificant,
44 // profile_compilation_info will be set to null.
45 //
46 // Additional notes:
47 // - as mentioned above, this function may update the content of the files
48 // passed with the reference_profile_files.
49 // - if reference_profile_files is not empty it must be the same size as
50 // profile_files.
51 static bool ProcessProfiles(
52 const std::vector<std::string>& profile_files,
53 const std::vector<std::string>& reference_profile_files,
54 /*out*/ ProfileCompilationInfo** profile_compilation_info);
55
Calin Juravle877fd962016-01-05 14:29:29 +000056 static bool ProcessProfiles(
57 const std::vector<uint32_t>& profile_files_fd_,
58 const std::vector<uint32_t>& reference_profile_files_fd_,
59 /*out*/ ProfileCompilationInfo** profile_compilation_info);
60
Calin Juravle998c2162015-12-21 15:39:33 +020061 private:
Calin Juravle877fd962016-01-05 14:29:29 +000062 static bool ProcessProfilesInternal(
63 const std::vector<ScopedFlock>& profile_files,
64 const std::vector<ScopedFlock>& reference_profile_files,
65 /*out*/ ProfileCompilationInfo** profile_compilation_info);
66
Calin Juravle998c2162015-12-21 15:39:33 +020067 DISALLOW_COPY_AND_ASSIGN(ProfileAssistant);
68};
69
70} // namespace art
71
72#endif // ART_COMPILER_PROFILE_ASSISTANT_H_