| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 "vdex_file.h" |
| 18 | |
| Andreas Gampe | 0dfc315 | 2017-04-24 07:58:06 -0700 | [diff] [blame] | 19 | #include <sys/mman.h> // For the PROT_* and MAP_* constants. |
| 20 | |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 21 | #include <memory> |
| Mathieu Chartier | a79efdb | 2018-01-18 16:31:01 -0800 | [diff] [blame] | 22 | #include <unordered_set> |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 23 | |
| Andreas Gampe | 5794381 | 2017-12-06 21:39:13 -0800 | [diff] [blame] | 24 | #include <android-base/logging.h> |
| 25 | |
| Nicolas Geoffray | 28453cf | 2017-08-10 15:30:26 +0100 | [diff] [blame] | 26 | #include "base/bit_utils.h" |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 27 | #include "base/stl_util.h" |
| Andreas Gampe | f7e8223 | 2016-09-12 15:55:56 -0700 | [diff] [blame] | 28 | #include "base/unix_file/fd_file.h" |
| David Sehr | 013fd80 | 2018-01-11 22:55:24 -0800 | [diff] [blame] | 29 | #include "dex/art_dex_file_loader.h" |
| David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 30 | #include "dex/dex_file.h" |
| 31 | #include "dex/dex_file_loader.h" |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 32 | #include "dex_to_dex_decompiler.h" |
| Alex Light | 1a824a5 | 2018-01-26 15:45:30 -0800 | [diff] [blame] | 33 | #include "hidden_api_access_flags.h" |
| 34 | #include "leb128.h" |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 35 | #include "quicken_info.h" |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 36 | |
| 37 | namespace art { |
| 38 | |
| Nicolas Geoffray | 36930ec | 2017-05-09 13:23:34 +0100 | [diff] [blame] | 39 | constexpr uint8_t VdexFile::Header::kVdexInvalidMagic[4]; |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 40 | constexpr uint8_t VdexFile::Header::kVdexMagic[4]; |
| 41 | constexpr uint8_t VdexFile::Header::kVdexVersion[4]; |
| 42 | |
| 43 | bool VdexFile::Header::IsMagicValid() const { |
| 44 | return (memcmp(magic_, kVdexMagic, sizeof(kVdexMagic)) == 0); |
| 45 | } |
| 46 | |
| 47 | bool VdexFile::Header::IsVersionValid() const { |
| 48 | return (memcmp(version_, kVdexVersion, sizeof(kVdexVersion)) == 0); |
| 49 | } |
| 50 | |
| Nicolas Geoffray | f54e5df | 2016-12-01 10:45:08 +0000 | [diff] [blame] | 51 | VdexFile::Header::Header(uint32_t number_of_dex_files, |
| 52 | uint32_t dex_size, |
| Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 53 | uint32_t dex_shared_data_size, |
| Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 54 | uint32_t verifier_deps_size, |
| 55 | uint32_t quickening_info_size) |
| Nicolas Geoffray | f54e5df | 2016-12-01 10:45:08 +0000 | [diff] [blame] | 56 | : number_of_dex_files_(number_of_dex_files), |
| 57 | dex_size_(dex_size), |
| Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 58 | dex_shared_data_size_(dex_shared_data_size), |
| Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 59 | verifier_deps_size_(verifier_deps_size), |
| 60 | quickening_info_size_(quickening_info_size) { |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 61 | memcpy(magic_, kVdexMagic, sizeof(kVdexMagic)); |
| 62 | memcpy(version_, kVdexVersion, sizeof(kVdexVersion)); |
| 63 | DCHECK(IsMagicValid()); |
| 64 | DCHECK(IsVersionValid()); |
| 65 | } |
| 66 | |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 67 | std::unique_ptr<VdexFile> VdexFile::OpenAtAddress(uint8_t* mmap_addr, |
| 68 | size_t mmap_size, |
| 69 | bool mmap_reuse, |
| 70 | const std::string& vdex_filename, |
| 71 | bool writable, |
| 72 | bool low_4gb, |
| 73 | bool unquicken, |
| 74 | std::string* error_msg) { |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 75 | if (!OS::FileExists(vdex_filename.c_str())) { |
| 76 | *error_msg = "File " + vdex_filename + " does not exist."; |
| 77 | return nullptr; |
| 78 | } |
| 79 | |
| 80 | std::unique_ptr<File> vdex_file; |
| 81 | if (writable) { |
| 82 | vdex_file.reset(OS::OpenFileReadWrite(vdex_filename.c_str())); |
| 83 | } else { |
| 84 | vdex_file.reset(OS::OpenFileForReading(vdex_filename.c_str())); |
| 85 | } |
| 86 | if (vdex_file == nullptr) { |
| 87 | *error_msg = "Could not open file " + vdex_filename + |
| 88 | (writable ? " for read/write" : "for reading"); |
| 89 | return nullptr; |
| 90 | } |
| 91 | |
| 92 | int64_t vdex_length = vdex_file->GetLength(); |
| 93 | if (vdex_length == -1) { |
| 94 | *error_msg = "Could not read the length of file " + vdex_filename; |
| 95 | return nullptr; |
| 96 | } |
| 97 | |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 98 | return OpenAtAddress(mmap_addr, |
| 99 | mmap_size, |
| 100 | mmap_reuse, |
| 101 | vdex_file->Fd(), |
| 102 | vdex_length, |
| 103 | vdex_filename, |
| 104 | writable, |
| 105 | low_4gb, |
| 106 | unquicken, |
| 107 | error_msg); |
| Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 110 | std::unique_ptr<VdexFile> VdexFile::OpenAtAddress(uint8_t* mmap_addr, |
| 111 | size_t mmap_size, |
| 112 | bool mmap_reuse, |
| 113 | int file_fd, |
| 114 | size_t vdex_length, |
| 115 | const std::string& vdex_filename, |
| 116 | bool writable, |
| 117 | bool low_4gb, |
| 118 | bool unquicken, |
| 119 | std::string* error_msg) { |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 120 | if (mmap_addr != nullptr && mmap_size < vdex_length) { |
| 121 | LOG(WARNING) << "Insufficient pre-allocated space to mmap vdex."; |
| 122 | mmap_addr = nullptr; |
| 123 | mmap_reuse = false; |
| 124 | } |
| Andreas Gampe | c1fc449 | 2018-01-10 14:19:36 -0800 | [diff] [blame] | 125 | CHECK(!mmap_reuse || mmap_addr != nullptr); |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 126 | std::unique_ptr<MemMap> mmap(MemMap::MapFileAtAddress( |
| 127 | mmap_addr, |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 128 | vdex_length, |
| 129 | (writable || unquicken) ? PROT_READ | PROT_WRITE : PROT_READ, |
| 130 | unquicken ? MAP_PRIVATE : MAP_SHARED, |
| 131 | file_fd, |
| 132 | 0 /* start offset */, |
| 133 | low_4gb, |
| David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 134 | mmap_reuse, |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 135 | vdex_filename.c_str(), |
| 136 | error_msg)); |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 137 | if (mmap == nullptr) { |
| 138 | *error_msg = "Failed to mmap file " + vdex_filename + " : " + *error_msg; |
| 139 | return nullptr; |
| 140 | } |
| 141 | |
| Richard Uhler | b8ab63a | 2017-01-31 11:27:37 +0000 | [diff] [blame] | 142 | std::unique_ptr<VdexFile> vdex(new VdexFile(mmap.release())); |
| 143 | if (!vdex->IsValid()) { |
| 144 | *error_msg = "Vdex file is not valid"; |
| 145 | return nullptr; |
| 146 | } |
| 147 | |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 148 | if (unquicken) { |
| 149 | std::vector<std::unique_ptr<const DexFile>> unique_ptr_dex_files; |
| 150 | if (!vdex->OpenAllDexFiles(&unique_ptr_dex_files, error_msg)) { |
| 151 | return nullptr; |
| 152 | } |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 153 | vdex->Unquicken(MakeNonOwningPointerVector(unique_ptr_dex_files), |
| 154 | /* decompile_return_instruction */ false); |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 155 | // Update the quickening info size to pretend there isn't any. |
| 156 | reinterpret_cast<Header*>(vdex->mmap_->Begin())->quickening_info_size_ = 0; |
| 157 | } |
| 158 | |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 159 | *error_msg = "Success"; |
| Richard Uhler | b8ab63a | 2017-01-31 11:27:37 +0000 | [diff] [blame] | 160 | return vdex; |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 161 | } |
| 162 | |
| Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 163 | const uint8_t* VdexFile::GetNextDexFileData(const uint8_t* cursor) const { |
| 164 | DCHECK(cursor == nullptr || (cursor > Begin() && cursor <= End())); |
| 165 | if (cursor == nullptr) { |
| 166 | // Beginning of the iteration, return the first dex file if there is one. |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 167 | return HasDexSection() ? DexBegin() + sizeof(QuickeningTableOffsetType) : nullptr; |
| Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 168 | } else { |
| 169 | // Fetch the next dex file. Return null if there is none. |
| 170 | const uint8_t* data = cursor + reinterpret_cast<const DexFile::Header*>(cursor)->file_size_; |
| Nicolas Geoffray | 28453cf | 2017-08-10 15:30:26 +0100 | [diff] [blame] | 171 | // Dex files are required to be 4 byte aligned. the OatWriter makes sure they are, see |
| 172 | // OatWriter::SeekToDexFiles. |
| 173 | data = AlignUp(data, 4); |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 174 | |
| 175 | return (data == DexEnd()) ? nullptr : data + sizeof(QuickeningTableOffsetType); |
| Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | |
| David Sehr | beca4fe | 2017-03-30 17:50:24 -0700 | [diff] [blame] | 179 | bool VdexFile::OpenAllDexFiles(std::vector<std::unique_ptr<const DexFile>>* dex_files, |
| 180 | std::string* error_msg) { |
| David Sehr | 013fd80 | 2018-01-11 22:55:24 -0800 | [diff] [blame] | 181 | const ArtDexFileLoader dex_file_loader; |
| David Sehr | beca4fe | 2017-03-30 17:50:24 -0700 | [diff] [blame] | 182 | size_t i = 0; |
| 183 | for (const uint8_t* dex_file_start = GetNextDexFileData(nullptr); |
| 184 | dex_file_start != nullptr; |
| 185 | dex_file_start = GetNextDexFileData(dex_file_start), ++i) { |
| 186 | size_t size = reinterpret_cast<const DexFile::Header*>(dex_file_start)->file_size_; |
| 187 | // TODO: Supply the location information for a vdex file. |
| 188 | static constexpr char kVdexLocation[] = ""; |
| Mathieu Chartier | 79c87da | 2017-10-10 11:54:29 -0700 | [diff] [blame] | 189 | std::string location = DexFileLoader::GetMultiDexLocation(i, kVdexLocation); |
| Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 190 | std::unique_ptr<const DexFile> dex(dex_file_loader.OpenWithDataSection( |
| 191 | dex_file_start, |
| 192 | size, |
| 193 | /*data_base*/ nullptr, |
| 194 | /*data_size*/ 0u, |
| 195 | location, |
| 196 | GetLocationChecksum(i), |
| 197 | nullptr /*oat_dex_file*/, |
| 198 | false /*verify*/, |
| 199 | false /*verify_checksum*/, |
| 200 | error_msg)); |
| David Sehr | beca4fe | 2017-03-30 17:50:24 -0700 | [diff] [blame] | 201 | if (dex == nullptr) { |
| 202 | return false; |
| 203 | } |
| 204 | dex_files->push_back(std::move(dex)); |
| 205 | } |
| 206 | return true; |
| 207 | } |
| 208 | |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 209 | void VdexFile::Unquicken(const std::vector<const DexFile*>& target_dex_files, |
| 210 | bool decompile_return_instruction) const { |
| 211 | const uint8_t* source_dex = GetNextDexFileData(nullptr); |
| 212 | for (const DexFile* target_dex : target_dex_files) { |
| 213 | UnquickenDexFile(*target_dex, source_dex, decompile_return_instruction); |
| 214 | source_dex = GetNextDexFileData(source_dex); |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 215 | } |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 216 | DCHECK(source_dex == nullptr); |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 217 | } |
| 218 | |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 219 | uint32_t VdexFile::GetQuickeningInfoTableOffset(const uint8_t* source_dex_begin) const { |
| 220 | DCHECK_GE(source_dex_begin, DexBegin()); |
| 221 | DCHECK_LT(source_dex_begin, DexEnd()); |
| 222 | return reinterpret_cast<const QuickeningTableOffsetType*>(source_dex_begin)[-1]; |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 223 | } |
| 224 | |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 225 | CompactOffsetTable::Accessor VdexFile::GetQuickenInfoOffsetTable( |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 226 | const uint8_t* source_dex_begin, |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 227 | const ArrayRef<const uint8_t>& quickening_info) const { |
| 228 | // The offset a is in preheader right before the dex file. |
| 229 | const uint32_t offset = GetQuickeningInfoTableOffset(source_dex_begin); |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 230 | return CompactOffsetTable::Accessor(quickening_info.SubArray(offset).data()); |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 231 | } |
| Nicolas Geoffray | b4c6acb | 2017-11-10 12:48:14 +0000 | [diff] [blame] | 232 | |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 233 | CompactOffsetTable::Accessor VdexFile::GetQuickenInfoOffsetTable( |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 234 | const DexFile& dex_file, |
| 235 | const ArrayRef<const uint8_t>& quickening_info) const { |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 236 | return GetQuickenInfoOffsetTable(dex_file.Begin(), quickening_info); |
| Nicolas Geoffray | b4c6acb | 2017-11-10 12:48:14 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static ArrayRef<const uint8_t> GetQuickeningInfoAt(const ArrayRef<const uint8_t>& quickening_info, |
| 240 | uint32_t quickening_offset) { |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 241 | // Subtract offset of one since 0 represents unused and cannot be in the table. |
| 242 | ArrayRef<const uint8_t> remaining = quickening_info.SubArray(quickening_offset - 1); |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 243 | return remaining.SubArray(0u, QuickenInfoTable::SizeInBytes(remaining)); |
| 244 | } |
| 245 | |
| Nicolas Geoffray | b4c6acb | 2017-11-10 12:48:14 +0000 | [diff] [blame] | 246 | void VdexFile::UnquickenDexFile(const DexFile& target_dex_file, |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 247 | const DexFile& source_dex_file, |
| 248 | bool decompile_return_instruction) const { |
| 249 | UnquickenDexFile(target_dex_file, source_dex_file.Begin(), decompile_return_instruction); |
| 250 | } |
| 251 | |
| 252 | void VdexFile::UnquickenDexFile(const DexFile& target_dex_file, |
| 253 | const uint8_t* source_dex_begin, |
| 254 | bool decompile_return_instruction) const { |
| 255 | ArrayRef<const uint8_t> quickening_info = GetQuickeningInfo(); |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 256 | if (quickening_info.empty()) { |
| 257 | // Bail early if there is no quickening info and no need to decompile. This means there is also |
| 258 | // no RETURN_VOID to decompile since the empty table takes a non zero amount of space. |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 259 | return; |
| 260 | } |
| Mathieu Chartier | a79efdb | 2018-01-18 16:31:01 -0800 | [diff] [blame] | 261 | // Make sure to not unquicken the same code item multiple times. |
| 262 | std::unordered_set<const DexFile::CodeItem*> unquickened_code_item; |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 263 | CompactOffsetTable::Accessor accessor(GetQuickenInfoOffsetTable(source_dex_begin, |
| 264 | quickening_info)); |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 265 | for (uint32_t i = 0; i < target_dex_file.NumClassDefs(); ++i) { |
| 266 | const DexFile::ClassDef& class_def = target_dex_file.GetClassDef(i); |
| 267 | const uint8_t* class_data = target_dex_file.GetClassData(class_def); |
| 268 | if (class_data != nullptr) { |
| 269 | for (ClassDataItemIterator class_it(target_dex_file, class_data); |
| 270 | class_it.HasNext(); |
| 271 | class_it.Next()) { |
| Alex Light | 1a824a5 | 2018-01-26 15:45:30 -0800 | [diff] [blame] | 272 | if (class_it.IsAtMethod()) { |
| Nicolas Geoffray | b4c6acb | 2017-11-10 12:48:14 +0000 | [diff] [blame] | 273 | const DexFile::CodeItem* code_item = class_it.GetMethodCodeItem(); |
| Alex Light | 1a824a5 | 2018-01-26 15:45:30 -0800 | [diff] [blame] | 274 | if (code_item != nullptr && unquickened_code_item.emplace(code_item).second) { |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 275 | const uint32_t offset = accessor.GetOffset(class_it.GetMemberIndex()); |
| 276 | // Offset being 0 means not quickened. |
| 277 | if (offset != 0u) { |
| 278 | ArrayRef<const uint8_t> quicken_data = GetQuickeningInfoAt(quickening_info, offset); |
| 279 | optimizer::ArtDecompileDEX( |
| 280 | target_dex_file, |
| 281 | *code_item, |
| 282 | quicken_data, |
| 283 | decompile_return_instruction); |
| Alex Light | 1a824a5 | 2018-01-26 15:45:30 -0800 | [diff] [blame] | 284 | } |
| Mathieu Chartier | a79efdb | 2018-01-18 16:31:01 -0800 | [diff] [blame] | 285 | } |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 286 | } |
| Alex Light | c88a008 | 2018-02-15 17:08:29 -0800 | [diff] [blame] | 287 | DexFile::UnHideAccessFlags(class_it); |
| Nicolas Geoffray | b02ba93 | 2017-07-13 15:53:54 +0100 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 293 | ArrayRef<const uint8_t> VdexFile::GetQuickenedInfoOf(const DexFile& dex_file, |
| 294 | uint32_t dex_method_idx) const { |
| Nicolas Geoffray | b4c6acb | 2017-11-10 12:48:14 +0000 | [diff] [blame] | 295 | ArrayRef<const uint8_t> quickening_info = GetQuickeningInfo(); |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 296 | if (quickening_info.empty()) { |
| 297 | return ArrayRef<const uint8_t>(); |
| 298 | } |
| Mathieu Chartier | 2daa134 | 2018-02-20 16:19:28 -0800 | [diff] [blame^] | 299 | const uint32_t quickening_offset = |
| 300 | GetQuickenInfoOffsetTable(dex_file, quickening_info).GetOffset(dex_method_idx); |
| 301 | if (quickening_offset == 0u) { |
| 302 | return ArrayRef<const uint8_t>(); |
| 303 | } |
| Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 304 | return GetQuickeningInfoAt(quickening_info, quickening_offset); |
| Nicolas Geoffray | 4e868fa | 2017-04-21 17:16:44 +0100 | [diff] [blame] | 305 | } |
| 306 | |
| David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 307 | } // namespace art |