• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
GetOatQuickMethodHeader()24 inline const OatQuickMethodHeader* OatFile::OatMethod::GetOatQuickMethodHeader() const {
25   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
26   if (code == nullptr) {
27     return nullptr;
28   }
29   // Return a pointer to the packed struct before the code.
30   return reinterpret_cast<const OatQuickMethodHeader*>(code) - 1;
31 }
32 
GetOatQuickMethodHeaderOffset()33 inline uint32_t OatFile::OatMethod::GetOatQuickMethodHeaderOffset() const {
34   const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
35   if (method_header == nullptr) {
36     return 0u;
37   }
38   return reinterpret_cast<const byte*>(method_header) - begin_;
39 }
40 
GetQuickCodeSize()41 inline uint32_t OatFile::OatMethod::GetQuickCodeSize() const {
42   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
43   if (code == nullptr) {
44     return 0u;
45   }
46   return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].code_size_;
47 }
48 
GetQuickCodeSizeOffset()49 inline uint32_t OatFile::OatMethod::GetQuickCodeSizeOffset() const {
50   const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
51   if (method_header == nullptr) {
52     return 0u;
53   }
54   return reinterpret_cast<const byte*>(&method_header->code_size_) - begin_;
55 }
56 
GetFrameSizeInBytes()57 inline size_t OatFile::OatMethod::GetFrameSizeInBytes() const {
58   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
59   if (code == nullptr) {
60     return 0u;
61   }
62   return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.FrameSizeInBytes();
63 }
64 
GetCoreSpillMask()65 inline uint32_t OatFile::OatMethod::GetCoreSpillMask() const {
66   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
67   if (code == nullptr) {
68     return 0u;
69   }
70   return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.CoreSpillMask();
71 }
72 
GetFpSpillMask()73 inline uint32_t OatFile::OatMethod::GetFpSpillMask() const {
74   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
75   if (code == nullptr) {
76     return 0u;
77   }
78   return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].frame_info_.FpSpillMask();
79 }
80 
GetMappingTableOffset()81 inline uint32_t OatFile::OatMethod::GetMappingTableOffset() const {
82   const uint8_t* mapping_table = GetMappingTable();
83   return static_cast<uint32_t>(mapping_table != nullptr ? mapping_table - begin_ : 0u);
84 }
85 
GetMappingTableOffsetOffset()86 inline uint32_t OatFile::OatMethod::GetMappingTableOffsetOffset() const {
87   const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
88   if (method_header == nullptr) {
89     return 0u;
90   }
91   return reinterpret_cast<const byte*>(&method_header->mapping_table_offset_) - begin_;
92 }
93 
GetVmapTableOffset()94 inline uint32_t OatFile::OatMethod::GetVmapTableOffset() const {
95   const uint8_t* vmap_table = GetVmapTable();
96   return static_cast<uint32_t>(vmap_table != nullptr ? vmap_table - begin_ : 0u);
97 }
98 
GetVmapTableOffsetOffset()99 inline uint32_t OatFile::OatMethod::GetVmapTableOffsetOffset() const {
100   const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
101   if (method_header == nullptr) {
102     return 0u;
103   }
104   return reinterpret_cast<const byte*>(&method_header->vmap_table_offset_) - begin_;
105 }
106 
GetMappingTable()107 inline const uint8_t* OatFile::OatMethod::GetMappingTable() const {
108   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
109   if (code == nullptr) {
110     return nullptr;
111   }
112   uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].mapping_table_offset_;
113   if (UNLIKELY(offset == 0u)) {
114     return nullptr;
115   }
116   return reinterpret_cast<const uint8_t*>(code) - offset;
117 }
118 
GetVmapTable()119 inline const uint8_t* OatFile::OatMethod::GetVmapTable() const {
120   const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
121   if (code == nullptr) {
122     return nullptr;
123   }
124   uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].vmap_table_offset_;
125   if (UNLIKELY(offset == 0u)) {
126     return nullptr;
127   }
128   return reinterpret_cast<const uint8_t*>(code) - offset;
129 }
130 
131 }  // namespace art
132 
133 #endif  // ART_RUNTIME_OAT_FILE_INL_H_
134