blob: 00ae7977b9c418269008ca273528e467b928b488 [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
24inline uint32_t OatFile::OatMethod::GetMappingTableOffset() const {
25 const uint8_t* mapping_table = GetMappingTable();
26 return static_cast<uint32_t>(mapping_table != nullptr ? mapping_table - begin_ : 0u);
27}
28
29inline uint32_t OatFile::OatMethod::GetVmapTableOffset() const {
30 const uint8_t* vmap_table = GetVmapTable();
31 return static_cast<uint32_t>(vmap_table != nullptr ? vmap_table - begin_ : 0u);
32}
33
34inline const uint8_t* OatFile::OatMethod::GetMappingTable() const {
35 const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
36 if (code == nullptr) {
37 return nullptr;
38 }
39 uint32_t offset = reinterpret_cast<const OatMethodHeader*>(code)[-1].mapping_table_offset_;
40 if (UNLIKELY(offset == 0u)) {
41 return nullptr;
42 }
43 return reinterpret_cast<const uint8_t*>(code) - offset;
44}
45
46inline const uint8_t* OatFile::OatMethod::GetVmapTable() const {
47 const void* code = mirror::ArtMethod::EntryPointToCodePointer(GetQuickCode());
48 if (code == nullptr) {
49 return nullptr;
50 }
51 uint32_t offset = reinterpret_cast<const OatMethodHeader*>(code)[-1].vmap_table_offset_;
52 if (UNLIKELY(offset == 0u)) {
53 return nullptr;
54 }
55 return reinterpret_cast<const uint8_t*>(code) - offset;
56}
57
58} // namespace art
59
60#endif // ART_RUNTIME_OAT_FILE_INL_H_