1 /* 2 * Copyright (C) 2019 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_LIBPROFILE_PROFILE_PROFILE_BOOT_INFO_H_ 18 #define ART_LIBPROFILE_PROFILE_PROFILE_BOOT_INFO_H_ 19 20 #include <vector> 21 22 #include "base/value_object.h" 23 24 namespace art { 25 26 class DexFile; 27 28 /** 29 * Abstraction over a list of methods representing the boot profile 30 * of an application. The order in the list is the order in which the methods 31 * should be compiled. 32 * 33 * TODO: This is currently implemented as a separate profile to 34 * ProfileCompilationInfo to enable fast experiments, but we are likely to 35 * incorporate it in ProfileCompilationInfo once we settle on an automated way 36 * to generate such a boot profile. 37 */ 38 class ProfileBootInfo : public ValueObject { 39 public: 40 // Add the given method located in the given dex file in the profile. 41 void Add(const DexFile* dex_file, uint32_t method_index); 42 43 // Save this profile boot info into the `fd` file descriptor. 44 bool Save(int fd) const; 45 46 // Load the profile listing from `fd` into this profile boot info. Note that 47 // the profile boot info will store internally the dex files being passed. 48 bool Load(int fd, const std::vector<const DexFile*>& dex_files); 49 GetDexFiles()50 const std::vector<const DexFile*>& GetDexFiles() const { 51 return dex_files_; 52 } 53 GetMethods()54 const std::vector<std::pair<uint32_t, uint32_t>>& GetMethods() const { 55 return methods_; 56 } 57 IsEmpty()58 bool IsEmpty() const { return dex_files_.empty() && methods_.empty(); } 59 60 private: 61 // List of dex files this boot profile info covers. 62 std::vector<const DexFile*> dex_files_; 63 64 // List of pair of <dex file index, method_id> methods to be compiled in 65 // order. 66 std::vector<std::pair<uint32_t, uint32_t>> methods_; 67 }; 68 69 } // namespace art 70 71 #endif // ART_LIBPROFILE_PROFILE_PROFILE_BOOT_INFO_H_ 72