blob: e864d879339f1fa92df427f94ab694b88961fb76 [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#include "offline_profiling_info.h"
18
19#include <fstream>
Calin Juravle4d77b6a2015-12-01 18:38:09 +000020#include <vector>
Calin Juravle31f2c152015-10-23 17:56:15 +010021#include <sys/file.h>
22#include <sys/stat.h>
23#include <sys/uio.h>
24
25#include "art_method-inl.h"
26#include "base/mutex.h"
Calin Juravle877fd962016-01-05 14:29:29 +000027#include "base/scoped_flock.h"
Calin Juravle66f55232015-12-08 15:09:10 +000028#include "base/stl_util.h"
Mathieu Chartier32ce2ad2016-03-04 14:58:03 -080029#include "base/systrace.h"
Calin Juravle877fd962016-01-05 14:29:29 +000030#include "base/unix_file/fd_file.h"
Calin Juravle31f2c152015-10-23 17:56:15 +010031#include "jit/profiling_info.h"
Calin Juravle877fd962016-01-05 14:29:29 +000032#include "os.h"
Calin Juravle31f2c152015-10-23 17:56:15 +010033#include "safe_map.h"
Calin Juravle31f2c152015-10-23 17:56:15 +010034
35namespace art {
36
Calin Juravle34900cc2016-02-05 16:19:19 +000037// Transform the actual dex location into relative paths.
38// Note: this is OK because we don't store profiles of different apps into the same file.
39// Apps with split apks don't cause trouble because each split has a different name and will not
40// collide with other entries.
Calin Juravle31708b72016-02-05 19:44:05 +000041std::string ProfileCompilationInfo::GetProfileDexFileKey(const std::string& dex_location) {
Calin Juravle34900cc2016-02-05 16:19:19 +000042 DCHECK(!dex_location.empty());
43 size_t last_sep_index = dex_location.find_last_of('/');
44 if (last_sep_index == std::string::npos) {
45 return dex_location;
46 } else {
Calin Juravle31708b72016-02-05 19:44:05 +000047 DCHECK(last_sep_index < dex_location.size());
48 return dex_location.substr(last_sep_index + 1);
Calin Juravle34900cc2016-02-05 16:19:19 +000049 }
50}
51
Calin Juravle67265462016-03-18 16:23:40 +000052bool ProfileCompilationInfo::AddMethodsAndClasses(
53 const std::vector<ArtMethod*>& methods,
54 const std::set<DexCacheResolvedClasses>& resolved_classes) {
55 ScopedObjectAccess soa(Thread::Current());
56 for (ArtMethod* method : methods) {
57 const DexFile* dex_file = method->GetDexFile();
58 if (!AddMethodIndex(GetProfileDexFileKey(dex_file->GetLocation()),
59 dex_file->GetLocationChecksum(),
60 method->GetDexMethodIndex())) {
61 return false;
62 }
63 }
64 for (const DexCacheResolvedClasses& dex_cache : resolved_classes) {
65 if (!AddResolvedClasses(dex_cache)) {
66 return false;
67 }
68 }
69 return true;
70}
71
72bool ProfileCompilationInfo::MergeAndSave(const std::string& filename, uint64_t* bytes_written) {
73 ScopedTrace trace(__PRETTY_FUNCTION__);
74 ScopedFlock flock;
75 std::string error;
76 if (!flock.Init(filename.c_str(), O_RDWR | O_NOFOLLOW | O_CLOEXEC, /* block */ false, &error)) {
77 LOG(WARNING) << "Couldn't lock the profile file " << filename << ": " << error;
78 return false;
79 }
80
81 int fd = flock.GetFile()->Fd();
82
83 // Load the file but keep a copy around to be able to infer if the content has changed.
84 ProfileCompilationInfo fileInfo;
85 if (!fileInfo.Load(fd)) {
86 LOG(WARNING) << "Could not load previous profile data from file " << filename;
87 return false;
88 }
89
90 // Merge the content of file into the current object.
91 if (!MergeWith(fileInfo)) {
92 LOG(WARNING) << "Could not merge previous profile data from file " << filename;
93 }
94
95 // If after the merge we have the same data as what is the file there's no point
96 // in actually doing the write. The file will be exactly the same as before.
97 if (Equals(fileInfo)) {
98 if (bytes_written != nullptr) {
99 *bytes_written = 0;
100 }
101 return true;
102 }
103
104 // We need to clear the data because we don't support append to the profiles yet.
105 if (!flock.GetFile()->ClearContent()) {
106 PLOG(WARNING) << "Could not clear profile file: " << filename;
107 return false;
108 }
109
110 // This doesn't need locking because we are trying to lock the file for exclusive
111 // access and fail immediately if we can't.
112 bool result = Save(fd);
113 if (result) {
114 VLOG(profiler) << "Successfully saved profile info to " << filename
115 << " Size: " << GetFileSizeBytes(filename);
116 if (bytes_written != nullptr) {
117 *bytes_written = GetFileSizeBytes(filename);
118 }
119 } else {
120 VLOG(profiler) << "Failed to save profile info to " << filename;
121 }
122 return result;
123}
124
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800125bool ProfileCompilationInfo::SaveProfilingInfo(
126 const std::string& filename,
127 const std::vector<ArtMethod*>& methods,
Calin Juravleb8e69992016-03-09 15:37:48 +0000128 const std::set<DexCacheResolvedClasses>& resolved_classes,
129 uint64_t* bytes_written) {
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800130 if (methods.empty() && resolved_classes.empty()) {
Calin Juravle31f2c152015-10-23 17:56:15 +0100131 VLOG(profiler) << "No info to save to " << filename;
Calin Juravleb8e69992016-03-09 15:37:48 +0000132 if (bytes_written != nullptr) {
133 *bytes_written = 0;
134 }
Calin Juravle998c2162015-12-21 15:39:33 +0200135 return true;
Calin Juravle31f2c152015-10-23 17:56:15 +0100136 }
137
Calin Juravle998c2162015-12-21 15:39:33 +0200138 ProfileCompilationInfo info;
Calin Juravle67265462016-03-18 16:23:40 +0000139 if (!info.AddMethodsAndClasses(methods, resolved_classes)) {
140 LOG(WARNING) << "Checksum mismatch when processing methods and resolved classes for "
141 << filename;
Calin Juravleb8e69992016-03-09 15:37:48 +0000142 if (bytes_written != nullptr) {
Calin Juravle67265462016-03-18 16:23:40 +0000143 *bytes_written = 0;
Calin Juravleb8e69992016-03-09 15:37:48 +0000144 }
Calin Juravle67265462016-03-18 16:23:40 +0000145 return false;
Calin Juravle31f2c152015-10-23 17:56:15 +0100146 }
Calin Juravle67265462016-03-18 16:23:40 +0000147 return info.MergeAndSave(filename, bytes_written);
Calin Juravle31f2c152015-10-23 17:56:15 +0100148}
149
Calin Juravle877fd962016-01-05 14:29:29 +0000150static bool WriteToFile(int fd, const std::ostringstream& os) {
Calin Juravle31f2c152015-10-23 17:56:15 +0100151 std::string data(os.str());
152 const char *p = data.c_str();
153 size_t length = data.length();
154 do {
Calin Juravle877fd962016-01-05 14:29:29 +0000155 int n = TEMP_FAILURE_RETRY(write(fd, p, length));
156 if (n < 0) {
157 PLOG(WARNING) << "Failed to write to descriptor: " << fd;
158 return false;
159 }
Calin Juravle31f2c152015-10-23 17:56:15 +0100160 p += n;
161 length -= n;
162 } while (length > 0);
Calin Juravle877fd962016-01-05 14:29:29 +0000163 return true;
Calin Juravle31f2c152015-10-23 17:56:15 +0100164}
165
Calin Juravle226501b2015-12-11 14:41:31 +0000166static constexpr const char kFieldSeparator = ',';
167static constexpr const char kLineSeparator = '\n';
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800168static constexpr const char* kClassesMarker = "classes";
Calin Juravle31f2c152015-10-23 17:56:15 +0100169
170/**
171 * Serialization format:
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800172 * dex_location1,dex_location_checksum1,method_id11,method_id12...,classes,class_id1,class_id2...
173 * dex_location2,dex_location_checksum2,method_id21,method_id22...,classes,class_id1,class_id2...
Calin Juravle31f2c152015-10-23 17:56:15 +0100174 * e.g.
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800175 * app.apk,131232145,11,23,454,54,classes,1,2,4,1234
Calin Juravle34900cc2016-02-05 16:19:19 +0000176 * app.apk:classes5.dex,218490184,39,13,49,1
Calin Juravle31f2c152015-10-23 17:56:15 +0100177 **/
Calin Juravle2e2db782016-02-23 12:00:03 +0000178bool ProfileCompilationInfo::Save(int fd) {
Mathieu Chartier32ce2ad2016-03-04 14:58:03 -0800179 ScopedTrace trace(__PRETTY_FUNCTION__);
Calin Juravle2e2db782016-02-23 12:00:03 +0000180 DCHECK_GE(fd, 0);
Calin Juravle31f2c152015-10-23 17:56:15 +0100181 // TODO(calin): Profile this and see how much memory it takes. If too much,
182 // write to file directly.
183 std::ostringstream os;
Calin Juravle998c2162015-12-21 15:39:33 +0200184 for (const auto& it : info_) {
185 const std::string& dex_location = it.first;
186 const DexFileData& dex_data = it.second;
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800187 if (dex_data.method_set.empty() && dex_data.class_set.empty()) {
188 continue;
189 }
Calin Juravle31f2c152015-10-23 17:56:15 +0100190
Calin Juravle998c2162015-12-21 15:39:33 +0200191 os << dex_location << kFieldSeparator << dex_data.checksum;
192 for (auto method_it : dex_data.method_set) {
Calin Juravle31f2c152015-10-23 17:56:15 +0100193 os << kFieldSeparator << method_it;
194 }
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800195 if (!dex_data.class_set.empty()) {
196 os << kFieldSeparator << kClassesMarker;
197 for (auto class_id : dex_data.class_set) {
198 os << kFieldSeparator << class_id;
199 }
200 }
Calin Juravle31f2c152015-10-23 17:56:15 +0100201 os << kLineSeparator;
202 }
203
Calin Juravle877fd962016-01-05 14:29:29 +0000204 return WriteToFile(fd, os);
Calin Juravle31f2c152015-10-23 17:56:15 +0100205}
Calin Juravle226501b2015-12-11 14:41:31 +0000206
207// TODO(calin): This a duplicate of Utils::Split fixing the case where the first character
208// is the separator. Merge the fix into Utils::Split once verified that it doesn't break its users.
209static void SplitString(const std::string& s, char separator, std::vector<std::string>* result) {
210 const char* p = s.data();
211 const char* end = p + s.size();
212 // Check if the first character is the separator.
213 if (p != end && *p ==separator) {
214 result->push_back("");
215 ++p;
216 }
217 // Process the rest of the characters.
218 while (p != end) {
219 if (*p == separator) {
220 ++p;
221 } else {
222 const char* start = p;
223 while (++p != end && *p != separator) {
224 // Skip to the next occurrence of the separator.
225 }
226 result->push_back(std::string(start, p - start));
227 }
228 }
229}
230
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800231ProfileCompilationInfo::DexFileData* ProfileCompilationInfo::GetOrAddDexFileData(
232 const std::string& dex_location,
233 uint32_t checksum) {
Calin Juravle998c2162015-12-21 15:39:33 +0200234 auto info_it = info_.find(dex_location);
235 if (info_it == info_.end()) {
236 info_it = info_.Put(dex_location, DexFileData(checksum));
237 }
238 if (info_it->second.checksum != checksum) {
239 LOG(WARNING) << "Checksum mismatch for dex " << dex_location;
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800240 return nullptr;
241 }
242 return &info_it->second;
243}
244
245bool ProfileCompilationInfo::AddResolvedClasses(const DexCacheResolvedClasses& classes) {
246 const std::string dex_location = GetProfileDexFileKey(classes.GetDexLocation());
247 const uint32_t checksum = classes.GetLocationChecksum();
248 DexFileData* const data = GetOrAddDexFileData(dex_location, checksum);
249 if (data == nullptr) {
Calin Juravle998c2162015-12-21 15:39:33 +0200250 return false;
251 }
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800252 data->class_set.insert(classes.GetClasses().begin(), classes.GetClasses().end());
253 return true;
254}
255
256bool ProfileCompilationInfo::AddMethodIndex(const std::string& dex_location,
257 uint32_t checksum,
258 uint16_t method_idx) {
259 DexFileData* const data = GetOrAddDexFileData(dex_location, checksum);
260 if (data == nullptr) {
261 return false;
262 }
263 data->method_set.insert(method_idx);
264 return true;
265}
266
267bool ProfileCompilationInfo::AddClassIndex(const std::string& dex_location,
268 uint32_t checksum,
269 uint16_t class_idx) {
270 DexFileData* const data = GetOrAddDexFileData(dex_location, checksum);
271 if (data == nullptr) {
272 return false;
273 }
274 data->class_set.insert(class_idx);
Calin Juravle998c2162015-12-21 15:39:33 +0200275 return true;
276}
277
278bool ProfileCompilationInfo::ProcessLine(const std::string& line) {
Calin Juravle226501b2015-12-11 14:41:31 +0000279 std::vector<std::string> parts;
280 SplitString(line, kFieldSeparator, &parts);
281 if (parts.size() < 3) {
282 LOG(WARNING) << "Invalid line: " << line;
283 return false;
284 }
285
Calin Juravle66f55232015-12-08 15:09:10 +0000286 const std::string& dex_location = parts[0];
Calin Juravle226501b2015-12-11 14:41:31 +0000287 uint32_t checksum;
288 if (!ParseInt(parts[1].c_str(), &checksum)) {
289 return false;
290 }
291
Calin Juravle226501b2015-12-11 14:41:31 +0000292 for (size_t i = 2; i < parts.size(); i++) {
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800293 if (parts[i] == kClassesMarker) {
294 ++i;
295 // All of the remaining idx are class def indexes.
296 for (++i; i < parts.size(); ++i) {
297 uint32_t class_def_idx;
298 if (!ParseInt(parts[i].c_str(), &class_def_idx)) {
299 LOG(WARNING) << "Cannot parse class_def_idx " << parts[i];
300 return false;
301 } else if (class_def_idx >= std::numeric_limits<uint16_t>::max()) {
302 LOG(WARNING) << "Class def idx " << class_def_idx << " is larger than uint16_t max";
303 return false;
304 }
305 if (!AddClassIndex(dex_location, checksum, class_def_idx)) {
306 return false;
307 }
308 }
309 break;
310 }
Calin Juravle226501b2015-12-11 14:41:31 +0000311 uint32_t method_idx;
312 if (!ParseInt(parts[i].c_str(), &method_idx)) {
313 LOG(WARNING) << "Cannot parse method_idx " << parts[i];
314 return false;
315 }
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800316 if (!AddMethodIndex(dex_location, checksum, method_idx)) {
Calin Juravle877fd962016-01-05 14:29:29 +0000317 return false;
318 }
Calin Juravle226501b2015-12-11 14:41:31 +0000319 }
320 return true;
321}
322
323// Parses the buffer (of length n) starting from start_from and identify new lines
324// based on kLineSeparator marker.
325// Returns the first position after kLineSeparator in the buffer (starting from start_from),
326// or -1 if the marker doesn't appear.
327// The processed characters are appended to the given line.
328static int GetLineFromBuffer(char* buffer, int n, int start_from, std::string& line) {
329 if (start_from >= n) {
330 return -1;
331 }
332 int new_line_pos = -1;
333 for (int i = start_from; i < n; i++) {
334 if (buffer[i] == kLineSeparator) {
335 new_line_pos = i;
336 break;
337 }
338 }
339 int append_limit = new_line_pos == -1 ? n : new_line_pos;
340 line.append(buffer + start_from, append_limit - start_from);
341 // Jump over kLineSeparator and return the position of the next character.
342 return new_line_pos == -1 ? new_line_pos : new_line_pos + 1;
343}
344
Calin Juravle2e2db782016-02-23 12:00:03 +0000345bool ProfileCompilationInfo::Load(int fd) {
Mathieu Chartier32ce2ad2016-03-04 14:58:03 -0800346 ScopedTrace trace(__PRETTY_FUNCTION__);
Calin Juravle2e2db782016-02-23 12:00:03 +0000347 DCHECK_GE(fd, 0);
Calin Juravle226501b2015-12-11 14:41:31 +0000348
349 std::string current_line;
350 const int kBufferSize = 1024;
351 char buffer[kBufferSize];
Calin Juravle226501b2015-12-11 14:41:31 +0000352
Calin Juravle877fd962016-01-05 14:29:29 +0000353 while (true) {
354 int n = TEMP_FAILURE_RETRY(read(fd, buffer, kBufferSize));
Calin Juravle226501b2015-12-11 14:41:31 +0000355 if (n < 0) {
Calin Juravle877fd962016-01-05 14:29:29 +0000356 PLOG(WARNING) << "Error when reading profile file";
357 return false;
Calin Juravle226501b2015-12-11 14:41:31 +0000358 } else if (n == 0) {
359 break;
360 }
361 // Detect the new lines from the buffer. If we manage to complete a line,
362 // process it. Otherwise append to the current line.
363 int current_start_pos = 0;
364 while (current_start_pos < n) {
365 current_start_pos = GetLineFromBuffer(buffer, n, current_start_pos, current_line);
366 if (current_start_pos == -1) {
367 break;
368 }
Calin Juravle998c2162015-12-21 15:39:33 +0200369 if (!ProcessLine(current_line)) {
Calin Juravle877fd962016-01-05 14:29:29 +0000370 return false;
Calin Juravle226501b2015-12-11 14:41:31 +0000371 }
372 // Reset the current line (we just processed it).
373 current_line.clear();
374 }
375 }
Calin Juravle877fd962016-01-05 14:29:29 +0000376 return true;
Calin Juravle998c2162015-12-21 15:39:33 +0200377}
378
Calin Juravle67265462016-03-18 16:23:40 +0000379bool ProfileCompilationInfo::MergeWith(const ProfileCompilationInfo& other) {
Calin Juravle998c2162015-12-21 15:39:33 +0200380 for (const auto& other_it : other.info_) {
381 const std::string& other_dex_location = other_it.first;
382 const DexFileData& other_dex_data = other_it.second;
383
384 auto info_it = info_.find(other_dex_location);
385 if (info_it == info_.end()) {
386 info_it = info_.Put(other_dex_location, DexFileData(other_dex_data.checksum));
387 }
388 if (info_it->second.checksum != other_dex_data.checksum) {
389 LOG(WARNING) << "Checksum mismatch for dex " << other_dex_location;
390 return false;
391 }
392 info_it->second.method_set.insert(other_dex_data.method_set.begin(),
393 other_dex_data.method_set.end());
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800394 info_it->second.class_set.insert(other_dex_data.class_set.begin(),
395 other_dex_data.class_set.end());
Calin Juravle998c2162015-12-21 15:39:33 +0200396 }
397 return true;
Calin Juravle226501b2015-12-11 14:41:31 +0000398}
399
400bool ProfileCompilationInfo::ContainsMethod(const MethodReference& method_ref) const {
Calin Juravle34900cc2016-02-05 16:19:19 +0000401 auto info_it = info_.find(GetProfileDexFileKey(method_ref.dex_file->GetLocation()));
Calin Juravle226501b2015-12-11 14:41:31 +0000402 if (info_it != info_.end()) {
Calin Juravle998c2162015-12-21 15:39:33 +0200403 if (method_ref.dex_file->GetLocationChecksum() != info_it->second.checksum) {
404 return false;
Calin Juravle226501b2015-12-11 14:41:31 +0000405 }
Calin Juravle998c2162015-12-21 15:39:33 +0200406 const std::set<uint16_t>& methods = info_it->second.method_set;
407 return methods.find(method_ref.dex_method_index) != methods.end();
Calin Juravle226501b2015-12-11 14:41:31 +0000408 }
409 return false;
410}
411
Mathieu Chartiera8077802016-03-16 19:08:31 -0700412bool ProfileCompilationInfo::ContainsClass(const DexFile& dex_file, uint16_t class_def_idx) const {
413 auto info_it = info_.find(GetProfileDexFileKey(dex_file.GetLocation()));
414 if (info_it != info_.end()) {
415 if (dex_file.GetLocationChecksum() != info_it->second.checksum) {
416 return false;
417 }
418 const std::set<uint16_t>& classes = info_it->second.class_set;
419 return classes.find(class_def_idx) != classes.end();
420 }
421 return false;
422}
423
Calin Juravle998c2162015-12-21 15:39:33 +0200424uint32_t ProfileCompilationInfo::GetNumberOfMethods() const {
425 uint32_t total = 0;
426 for (const auto& it : info_) {
427 total += it.second.method_set.size();
428 }
429 return total;
430}
431
Calin Juravle67265462016-03-18 16:23:40 +0000432uint32_t ProfileCompilationInfo::GetNumberOfResolvedClasses() const {
433 uint32_t total = 0;
434 for (const auto& it : info_) {
435 total += it.second.class_set.size();
436 }
437 return total;
438}
439
Calin Juravle998c2162015-12-21 15:39:33 +0200440std::string ProfileCompilationInfo::DumpInfo(const std::vector<const DexFile*>* dex_files,
441 bool print_full_dex_location) const {
Calin Juravle226501b2015-12-11 14:41:31 +0000442 std::ostringstream os;
443 if (info_.empty()) {
444 return "ProfileInfo: empty";
445 }
446
447 os << "ProfileInfo:";
448
Calin Juravle226501b2015-12-11 14:41:31 +0000449 const std::string kFirstDexFileKeySubstitute = ":classes.dex";
Calin Juravle998c2162015-12-21 15:39:33 +0200450 for (const auto& it : info_) {
Calin Juravle226501b2015-12-11 14:41:31 +0000451 os << "\n";
Calin Juravle998c2162015-12-21 15:39:33 +0200452 const std::string& location = it.first;
453 const DexFileData& dex_data = it.second;
Calin Juravle226501b2015-12-11 14:41:31 +0000454 if (print_full_dex_location) {
455 os << location;
456 } else {
457 // Replace the (empty) multidex suffix of the first key with a substitute for easier reading.
458 std::string multidex_suffix = DexFile::GetMultiDexSuffix(location);
459 os << (multidex_suffix.empty() ? kFirstDexFileKeySubstitute : multidex_suffix);
460 }
Calin Juravle998c2162015-12-21 15:39:33 +0200461 for (const auto method_it : dex_data.method_set) {
462 if (dex_files != nullptr) {
463 const DexFile* dex_file = nullptr;
464 for (size_t i = 0; i < dex_files->size(); i++) {
465 if (location == (*dex_files)[i]->GetLocation()) {
466 dex_file = (*dex_files)[i];
467 }
468 }
469 if (dex_file != nullptr) {
470 os << "\n " << PrettyMethod(method_it, *dex_file, true);
471 }
Calin Juravle226501b2015-12-11 14:41:31 +0000472 }
Calin Juravle998c2162015-12-21 15:39:33 +0200473 os << "\n " << method_it;
Calin Juravle226501b2015-12-11 14:41:31 +0000474 }
475 }
476 return os.str();
477}
478
Calin Juravle2e2db782016-02-23 12:00:03 +0000479bool ProfileCompilationInfo::Equals(const ProfileCompilationInfo& other) {
Calin Juravle877fd962016-01-05 14:29:29 +0000480 return info_.Equals(other.info_);
481}
482
Mathieu Chartierc5dd3192015-12-09 16:38:30 -0800483std::set<DexCacheResolvedClasses> ProfileCompilationInfo::GetResolvedClasses() const {
484 std::set<DexCacheResolvedClasses> ret;
485 for (auto&& pair : info_) {
486 const std::string& profile_key = pair.first;
487 const DexFileData& data = pair.second;
488 DexCacheResolvedClasses classes(profile_key, data.checksum);
489 classes.AddClasses(data.class_set.begin(), data.class_set.end());
490 ret.insert(classes);
491 }
492 return ret;
493}
494
Calin Juravle67265462016-03-18 16:23:40 +0000495void ProfileCompilationInfo::ClearResolvedClasses() {
496 for (auto& pair : info_) {
497 pair.second.class_set.clear();
498 }
499}
500
Calin Juravle31f2c152015-10-23 17:56:15 +0100501} // namespace art