blob: 6237767d7991b38ddd63cdec78f07f09a70659ef [file] [log] [blame]
Vladimir Marko8a630572014-04-09 18:45:35 +01001/*
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
22namespace art {
23
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070024inline 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
33inline uint32_t OatFile::OatMethod::GetOatQuickMethodHeaderOffset() const {
34 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
35 if (method_header == nullptr) {
36 return 0u;
37 }
Ian Rogers13735952014-10-08 12:43:28 -070038 return reinterpret_cast<const uint8_t*>(method_header) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070039}
40
41inline 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
49inline uint32_t OatFile::OatMethod::GetQuickCodeSizeOffset() const {
50 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
51 if (method_header == nullptr) {
52 return 0u;
53 }
Ian Rogers13735952014-10-08 12:43:28 -070054 return reinterpret_cast<const uint8_t*>(&method_header->code_size_) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070055}
56
Vladimir Marko7624d252014-05-02 14:40:15 +010057inline 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
65inline 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
73inline 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
Vladimir Marko8a630572014-04-09 18:45:35 +010081inline 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
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070086inline uint32_t OatFile::OatMethod::GetMappingTableOffsetOffset() const {
87 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
88 if (method_header == nullptr) {
89 return 0u;
90 }
Ian Rogers13735952014-10-08 12:43:28 -070091 return reinterpret_cast<const uint8_t*>(&method_header->mapping_table_offset_) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070092}
93
Vladimir Marko8a630572014-04-09 18:45:35 +010094inline 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
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070099inline uint32_t OatFile::OatMethod::GetVmapTableOffsetOffset() const {
100 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
101 if (method_header == nullptr) {
102 return 0u;
103 }
Ian Rogers13735952014-10-08 12:43:28 -0700104 return reinterpret_cast<const uint8_t*>(&method_header->vmap_table_offset_) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700105}
106
Vladimir Marko8a630572014-04-09 18:45:35 +0100107inline const uint8_t* OatFile::OatMethod::GetMappingTable() const {
108 const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
109 if (code == nullptr) {
110 return nullptr;
111 }
Vladimir Marko7624d252014-05-02 14:40:15 +0100112 uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].mapping_table_offset_;
Vladimir Marko8a630572014-04-09 18:45:35 +0100113 if (UNLIKELY(offset == 0u)) {
114 return nullptr;
115 }
116 return reinterpret_cast<const uint8_t*>(code) - offset;
117}
118
119inline const uint8_t* OatFile::OatMethod::GetVmapTable() const {
120 const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
121 if (code == nullptr) {
122 return nullptr;
123 }
Vladimir Marko7624d252014-05-02 14:40:15 +0100124 uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].vmap_table_offset_;
Vladimir Marko8a630572014-04-09 18:45:35 +0100125 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_