1 /* 2 * Copyright (C) 2014 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_OAT_FILE_INL_H_ 18 #define ART_RUNTIME_OAT_FILE_INL_H_ 19 20 #include "oat_file.h" 21 22 #include "base/utils.h" 23 #include "oat_quick_method_header.h" 24 25 namespace art { 26 GetOatQuickMethodHeader()27inline const OatQuickMethodHeader* OatFile::OatMethod::GetOatQuickMethodHeader() const { 28 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_)); 29 if (code == nullptr) { 30 return nullptr; 31 } 32 // Return a pointer to the packed struct before the code. 33 return reinterpret_cast<const OatQuickMethodHeader*>(code) - 1; 34 } 35 GetOatQuickMethodHeaderOffset()36inline uint32_t OatFile::OatMethod::GetOatQuickMethodHeaderOffset() const { 37 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader(); 38 if (method_header == nullptr) { 39 return 0u; 40 } 41 return reinterpret_cast<const uint8_t*>(method_header) - begin_; 42 } 43 GetFrameSizeInBytes()44inline size_t OatFile::OatMethod::GetFrameSizeInBytes() const { 45 const void* code = EntryPointToCodePointer(GetQuickCode()); 46 if (code == nullptr) { 47 return 0u; 48 } 49 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().FrameSizeInBytes(); 50 } 51 GetCoreSpillMask()52inline uint32_t OatFile::OatMethod::GetCoreSpillMask() const { 53 const void* code = EntryPointToCodePointer(GetQuickCode()); 54 if (code == nullptr) { 55 return 0u; 56 } 57 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().CoreSpillMask(); 58 } 59 GetFpSpillMask()60inline uint32_t OatFile::OatMethod::GetFpSpillMask() const { 61 const void* code = EntryPointToCodePointer(GetQuickCode()); 62 if (code == nullptr) { 63 return 0u; 64 } 65 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().FpSpillMask(); 66 } 67 GetVmapTableOffset()68inline uint32_t OatFile::OatMethod::GetVmapTableOffset() const { 69 const uint8_t* vmap_table = GetVmapTable(); 70 return static_cast<uint32_t>(vmap_table != nullptr ? vmap_table - begin_ : 0u); 71 } 72 GetVmapTable()73inline const uint8_t* OatFile::OatMethod::GetVmapTable() const { 74 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_)); 75 if (code == nullptr) { 76 return nullptr; 77 } 78 uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetCodeInfoOffset(); 79 if (UNLIKELY(offset == 0u)) { 80 return nullptr; 81 } 82 return reinterpret_cast<const uint8_t*>(code) - offset; 83 } 84 GetQuickCodeSize()85inline uint32_t OatFile::OatMethod::GetQuickCodeSize() const { 86 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_)); 87 if (code == nullptr) { 88 return 0u; 89 } 90 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetCodeSize(); 91 } 92 GetCodeOffset()93inline uint32_t OatFile::OatMethod::GetCodeOffset() const { 94 return (GetQuickCodeSize() == 0) ? 0 : code_offset_; 95 } 96 GetQuickCode()97inline const void* OatFile::OatMethod::GetQuickCode() const { 98 return GetOatPointer<const void*>(GetCodeOffset()); 99 } 100 101 } // namespace art 102 103 #endif // ART_RUNTIME_OAT_FILE_INL_H_ 104