blob: 26c31ae806aca23427011bfe7d0995b4ca6f23cb [file] [log] [blame]
Logan Chien67008a62012-06-06 18:23:12 +08001/*
2 * Copyright (C) 2012 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_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_
18#define ART_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_
19
20#include "globals.h"
21#include "instruction_set.h"
22#include "mem_map.h"
23
24#include <UniquePtr.h>
25
26#include <stddef.h>
27#include <stdint.h>
28
29namespace art {
30namespace compiler_llvm {
31
32
33class ProcedureLinkageTable {
34 public:
35 ProcedureLinkageTable(InstructionSet insn_set);
36
37 ~ProcedureLinkageTable();
38
39 bool AllocateTable();
40
41 uintptr_t GetEntryAddress(const char* func_name) const;
42
43 private:
44 static size_t GetStubCount(InstructionSet insn_set);
45 static size_t GetStubSizeInBytes(InstructionSet insn_set);
46 static void CreateStub(InstructionSet insn_set,
47 byte* stub, void* branch_dest);
48
49 int IndexOfRuntimeFunc(const char* name) const;
50 static int IndexOfArtRuntimeFunc(const char* name);
51 static int IndexOfCompilerRuntimeFunc(InstructionSet insn_set,
52 const char* name);
53
54 size_t GetStubCount() const {
55 return GetStubCount(insn_set_);
56 }
57
58 size_t GetStubSizeInBytes() const {
59 return GetStubSizeInBytes(insn_set_);
60 }
61
62 size_t GetTableSizeInBytes() const {
63 return GetStubSizeInBytes() * GetStubCount();
64 }
65
66 void CreateStub(byte* stub, void* branch_dest) {
67 return CreateStub(insn_set_, stub, branch_dest);
68 }
69
70 int IndexOfCompilerRuntimeFunc(const char* name) const {
71 return IndexOfCompilerRuntimeFunc(insn_set_, name);
72 }
73
74 InstructionSet insn_set_;
75 UniquePtr<MemMap> table_mmap_;
76
77 static const size_t kTableSizeInBytes = 1024u;
78 static const uintptr_t kTableAddress = 0x5fffc000u;
79};
80
81
82} // namespace compiler_llvm
83} // namespace art
84
85#endif // ART_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_