blob: b71c4e89d14eb4477c48739100983460784f2d5e [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"
Andreas Gampe97b28112018-12-04 09:09:12 -080021
22#include "base/utils.h"
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +010023#include "oat_quick_method_header.h"
Vladimir Marko8a630572014-04-09 18:45:35 +010024
25namespace art {
26
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070027inline const OatQuickMethodHeader* OatFile::OatMethod::GetOatQuickMethodHeader() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010028 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_));
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070029 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
36inline uint32_t OatFile::OatMethod::GetOatQuickMethodHeaderOffset() const {
37 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
38 if (method_header == nullptr) {
39 return 0u;
40 }
Ian Rogers13735952014-10-08 12:43:28 -070041 return reinterpret_cast<const uint8_t*>(method_header) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070042}
43
Nicolas Geoffray57083762019-03-05 09:24:45 +000044inline uint32_t OatFile::OatMethod::GetQuickCodeSizeOffset() const {
45 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
46 if (method_header == nullptr) {
47 return 0u;
48 }
49 return reinterpret_cast<const uint8_t*>(method_header->GetCodeSizeAddr()) - begin_;
50}
51
Vladimir Marko7624d252014-05-02 14:40:15 +010052inline size_t OatFile::OatMethod::GetFrameSizeInBytes() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010053 const void* code = EntryPointToCodePointer(GetQuickCode());
Vladimir Marko7624d252014-05-02 14:40:15 +010054 if (code == nullptr) {
55 return 0u;
56 }
Mingyao Yang063fc772016-08-02 11:02:54 -070057 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().FrameSizeInBytes();
Vladimir Marko7624d252014-05-02 14:40:15 +010058}
59
60inline uint32_t OatFile::OatMethod::GetCoreSpillMask() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010061 const void* code = EntryPointToCodePointer(GetQuickCode());
Vladimir Marko7624d252014-05-02 14:40:15 +010062 if (code == nullptr) {
63 return 0u;
64 }
Mingyao Yang063fc772016-08-02 11:02:54 -070065 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().CoreSpillMask();
Vladimir Marko7624d252014-05-02 14:40:15 +010066}
67
68inline uint32_t OatFile::OatMethod::GetFpSpillMask() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010069 const void* code = EntryPointToCodePointer(GetQuickCode());
Vladimir Marko7624d252014-05-02 14:40:15 +010070 if (code == nullptr) {
71 return 0u;
72 }
Mingyao Yang063fc772016-08-02 11:02:54 -070073 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetFrameInfo().FpSpillMask();
Vladimir Marko7624d252014-05-02 14:40:15 +010074}
75
Vladimir Marko8a630572014-04-09 18:45:35 +010076inline uint32_t OatFile::OatMethod::GetVmapTableOffset() const {
77 const uint8_t* vmap_table = GetVmapTable();
78 return static_cast<uint32_t>(vmap_table != nullptr ? vmap_table - begin_ : 0u);
79}
80
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070081inline uint32_t OatFile::OatMethod::GetVmapTableOffsetOffset() const {
82 const OatQuickMethodHeader* method_header = GetOatQuickMethodHeader();
83 if (method_header == nullptr) {
84 return 0u;
85 }
Mingyao Yang063fc772016-08-02 11:02:54 -070086 return reinterpret_cast<const uint8_t*>(method_header->GetVmapTableOffsetAddr()) - begin_;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070087}
88
Vladimir Marko8a630572014-04-09 18:45:35 +010089inline const uint8_t* OatFile::OatMethod::GetVmapTable() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010090 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_));
Vladimir Marko8a630572014-04-09 18:45:35 +010091 if (code == nullptr) {
92 return nullptr;
93 }
Mingyao Yang063fc772016-08-02 11:02:54 -070094 uint32_t offset = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetVmapTableOffset();
Vladimir Marko8a630572014-04-09 18:45:35 +010095 if (UNLIKELY(offset == 0u)) {
96 return nullptr;
97 }
98 return reinterpret_cast<const uint8_t*>(code) - offset;
99}
100
Nicolas Geoffrayc04c8002015-07-14 11:37:54 +0100101inline uint32_t OatFile::OatMethod::GetQuickCodeSize() const {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +0100102 const void* code = EntryPointToCodePointer(GetOatPointer<const void*>(code_offset_));
Nicolas Geoffrayc04c8002015-07-14 11:37:54 +0100103 if (code == nullptr) {
104 return 0u;
105 }
Mingyao Yang063fc772016-08-02 11:02:54 -0700106 return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetCodeSize();
Nicolas Geoffrayc04c8002015-07-14 11:37:54 +0100107}
108
109inline uint32_t OatFile::OatMethod::GetCodeOffset() const {
110 return (GetQuickCodeSize() == 0) ? 0 : code_offset_;
111}
112
113inline const void* OatFile::OatMethod::GetQuickCode() const {
114 return GetOatPointer<const void*>(GetCodeOffset());
115}
116
Vladimir Marko8a630572014-04-09 18:45:35 +0100117} // namespace art
118
119#endif // ART_RUNTIME_OAT_FILE_INL_H_