Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 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 | namespace art { |
| 23 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 24 | inline size_t OatFile::OatMethod::GetFrameSizeInBytes() const { |
| 25 | const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode()); |
| 26 | if (code == nullptr) { |
| 27 | return 0u; |
| 28 | } |
| 29 | return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.FrameSizeInBytes(); |
| 30 | } |
| 31 | |
| 32 | inline uint32_t OatFile::OatMethod::GetCoreSpillMask() const { |
| 33 | const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode()); |
| 34 | if (code == nullptr) { |
| 35 | return 0u; |
| 36 | } |
| 37 | return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.CoreSpillMask(); |
| 38 | } |
| 39 | |
| 40 | inline uint32_t OatFile::OatMethod::GetFpSpillMask() const { |
| 41 | const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode()); |
| 42 | if (code == nullptr) { |
| 43 | return 0u; |
| 44 | } |
| 45 | return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.FpSpillMask(); |
| 46 | } |
| 47 | |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 48 | inline uint32_t OatFile::OatMethod::GetMappingTableOffset() const { |
| 49 | const uint8_t* mapping_table = GetMappingTable(); |
| 50 | return static_cast<uint32_t>(mapping_table != nullptr ? mapping_table - begin_ : 0u); |
| 51 | } |
| 52 | |
| 53 | inline uint32_t OatFile::OatMethod::GetVmapTableOffset() const { |
| 54 | const uint8_t* vmap_table = GetVmapTable(); |
| 55 | return static_cast<uint32_t>(vmap_table != nullptr ? vmap_table - begin_ : 0u); |
| 56 | } |
| 57 | |
| 58 | inline const uint8_t* OatFile::OatMethod::GetMappingTable() const { |
| 59 | const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode()); |
| 60 | if (code == nullptr) { |
| 61 | return nullptr; |
| 62 | } |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 63 | uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].mapping_table_offset_; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 64 | if (UNLIKELY(offset == 0u)) { |
| 65 | return nullptr; |
| 66 | } |
| 67 | return reinterpret_cast<const uint8_t*>(code) - offset; |
| 68 | } |
| 69 | |
| 70 | inline const uint8_t* OatFile::OatMethod::GetVmapTable() const { |
| 71 | const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode()); |
| 72 | if (code == nullptr) { |
| 73 | return nullptr; |
| 74 | } |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 75 | uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].vmap_table_offset_; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 76 | if (UNLIKELY(offset == 0u)) { |
| 77 | return nullptr; |
| 78 | } |
| 79 | return reinterpret_cast<const uint8_t*>(code) - offset; |
| 80 | } |
| 81 | |
| 82 | } // namespace art |
| 83 | |
| 84 | #endif // ART_RUNTIME_OAT_FILE_INL_H_ |