author | coleenp |
Mon, 11 Mar 2013 14:00:09 -0400 | |
changeset 15932 | a27c3d066552 |
parent 14622 | 8e94e4186d35 |
permissions | -rw-r--r-- |
6187 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10260
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
6187 | 3 |
* Copyright 2009, 2010 Red Hat, Inc. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
7397 | 26 |
#ifndef SHARE_VM_SHARK_SHARKCONTEXT_HPP |
27 |
#define SHARE_VM_SHARK_SHARKCONTEXT_HPP |
|
28 |
||
29 |
#include "shark/llvmHeaders.hpp" |
|
30 |
#include "shark/sharkCompiler.hpp" |
|
31 |
||
6187 | 32 |
// The LLVMContext class allows multiple instances of LLVM to operate |
33 |
// independently of each other in a multithreaded context. We extend |
|
34 |
// this here to store things in Shark that are LLVMContext-specific. |
|
35 |
||
36 |
class SharkFreeQueueItem; |
|
37 |
||
38 |
class SharkContext : public llvm::LLVMContext { |
|
39 |
public: |
|
40 |
SharkContext(const char* name); |
|
41 |
||
42 |
private: |
|
43 |
llvm::Module* _module; |
|
44 |
||
45 |
public: |
|
46 |
llvm::Module* module() const { |
|
47 |
return _module; |
|
48 |
} |
|
49 |
||
50 |
// Get this thread's SharkContext |
|
51 |
public: |
|
52 |
static SharkContext& current() { |
|
53 |
return *SharkCompiler::compiler()->context(); |
|
54 |
} |
|
55 |
||
56 |
// Module accessors |
|
57 |
public: |
|
58 |
void add_function(llvm::Function* function) const { |
|
59 |
module()->getFunctionList().push_back(function); |
|
60 |
} |
|
61 |
llvm::Constant* get_external(const char* name, |
|
14622 | 62 |
llvm::FunctionType* sig) { |
6187 | 63 |
return module()->getOrInsertFunction(name, sig); |
64 |
} |
|
65 |
||
66 |
// Basic types |
|
67 |
private: |
|
14622 | 68 |
llvm::Type* _void_type; |
69 |
llvm::IntegerType* _bit_type; |
|
70 |
llvm::IntegerType* _jbyte_type; |
|
71 |
llvm::IntegerType* _jshort_type; |
|
72 |
llvm::IntegerType* _jint_type; |
|
73 |
llvm::IntegerType* _jlong_type; |
|
74 |
llvm::Type* _jfloat_type; |
|
75 |
llvm::Type* _jdouble_type; |
|
6187 | 76 |
|
77 |
public: |
|
14622 | 78 |
llvm::Type* void_type() const { |
6187 | 79 |
return _void_type; |
80 |
} |
|
14622 | 81 |
llvm::IntegerType* bit_type() const { |
6187 | 82 |
return _bit_type; |
83 |
} |
|
14622 | 84 |
llvm::IntegerType* jbyte_type() const { |
6187 | 85 |
return _jbyte_type; |
86 |
} |
|
14622 | 87 |
llvm::IntegerType* jshort_type() const { |
6187 | 88 |
return _jshort_type; |
89 |
} |
|
14622 | 90 |
llvm::IntegerType* jint_type() const { |
6187 | 91 |
return _jint_type; |
92 |
} |
|
14622 | 93 |
llvm::IntegerType* jlong_type() const { |
6187 | 94 |
return _jlong_type; |
95 |
} |
|
14622 | 96 |
llvm::Type* jfloat_type() const { |
6187 | 97 |
return _jfloat_type; |
98 |
} |
|
14622 | 99 |
llvm::Type* jdouble_type() const { |
6187 | 100 |
return _jdouble_type; |
101 |
} |
|
14622 | 102 |
llvm::IntegerType* intptr_type() const { |
6187 | 103 |
return LP64_ONLY(jlong_type()) NOT_LP64(jint_type()); |
104 |
} |
|
105 |
||
106 |
// Compound types |
|
107 |
private: |
|
14622 | 108 |
llvm::PointerType* _itableOffsetEntry_type; |
109 |
llvm::PointerType* _jniEnv_type; |
|
110 |
llvm::PointerType* _jniHandleBlock_type; |
|
111 |
llvm::PointerType* _Metadata_type; |
|
112 |
llvm::PointerType* _klass_type; |
|
113 |
llvm::PointerType* _Method_type; |
|
114 |
llvm::ArrayType* _monitor_type; |
|
115 |
llvm::PointerType* _oop_type; |
|
116 |
llvm::PointerType* _thread_type; |
|
117 |
llvm::PointerType* _zeroStack_type; |
|
118 |
llvm::FunctionType* _entry_point_type; |
|
119 |
llvm::FunctionType* _osr_entry_point_type; |
|
6187 | 120 |
|
121 |
public: |
|
14622 | 122 |
llvm::PointerType* itableOffsetEntry_type() const { |
6187 | 123 |
return _itableOffsetEntry_type; |
124 |
} |
|
14622 | 125 |
llvm::PointerType* jniEnv_type() const { |
6187 | 126 |
return _jniEnv_type; |
127 |
} |
|
14622 | 128 |
llvm::PointerType* jniHandleBlock_type() const { |
6187 | 129 |
return _jniHandleBlock_type; |
130 |
} |
|
14622 | 131 |
llvm::PointerType* Metadata_type() const { |
132 |
return _Metadata_type; |
|
133 |
} |
|
134 |
llvm::PointerType* klass_type() const { |
|
6187 | 135 |
return _klass_type; |
136 |
} |
|
14622 | 137 |
llvm::PointerType* Method_type() const { |
138 |
return _Method_type; |
|
6187 | 139 |
} |
14622 | 140 |
llvm::ArrayType* monitor_type() const { |
6187 | 141 |
return _monitor_type; |
142 |
} |
|
14622 | 143 |
llvm::PointerType* oop_type() const { |
6187 | 144 |
return _oop_type; |
145 |
} |
|
14622 | 146 |
llvm::PointerType* thread_type() const { |
6187 | 147 |
return _thread_type; |
148 |
} |
|
14622 | 149 |
llvm::PointerType* zeroStack_type() const { |
6187 | 150 |
return _zeroStack_type; |
151 |
} |
|
14622 | 152 |
llvm::FunctionType* entry_point_type() const { |
6187 | 153 |
return _entry_point_type; |
154 |
} |
|
14622 | 155 |
llvm::FunctionType* osr_entry_point_type() const { |
6187 | 156 |
return _osr_entry_point_type; |
157 |
} |
|
158 |
||
159 |
// Mappings |
|
160 |
private: |
|
14622 | 161 |
llvm::Type* _to_stackType[T_CONFLICT]; |
162 |
llvm::Type* _to_arrayType[T_CONFLICT]; |
|
6187 | 163 |
|
164 |
private: |
|
14622 | 165 |
llvm::Type* map_type(llvm::Type* const* table, |
6187 | 166 |
BasicType type) const { |
167 |
assert(type >= 0 && type < T_CONFLICT, "unhandled type"); |
|
14622 | 168 |
llvm::Type* result = table[type]; |
10260
b7007c4de557
7071823: Zero: zero/shark doesn't build after b147-fcs
twisti
parents:
7397
diff
changeset
|
169 |
assert(result != NULL, "unhandled type"); |
6187 | 170 |
return result; |
171 |
} |
|
172 |
||
173 |
public: |
|
14622 | 174 |
llvm::Type* to_stackType(BasicType type) const { |
6187 | 175 |
return map_type(_to_stackType, type); |
176 |
} |
|
14622 | 177 |
llvm::Type* to_arrayType(BasicType type) const { |
6187 | 178 |
return map_type(_to_arrayType, type); |
179 |
} |
|
180 |
||
181 |
// Functions queued for freeing |
|
182 |
private: |
|
183 |
SharkFreeQueueItem* _free_queue; |
|
184 |
||
185 |
public: |
|
186 |
void push_to_free_queue(llvm::Function* function); |
|
187 |
llvm::Function* pop_from_free_queue(); |
|
188 |
}; |
|
7397 | 189 |
|
190 |
#endif // SHARE_VM_SHARK_SHARKCONTEXT_HPP |