Mercurial > hg > truffle
annotate src/share/vm/shark/sharkContext.hpp @ 17726:085b304a1cc5
8027754: Enable loop optimizations for loops with MathExact inside
Reviewed-by: kvn, iveresov
author | rbackman |
---|---|
date | Thu, 23 Jan 2014 12:08:28 +0100 |
parents | 2cd5e15048e6 |
children |
rev | line source |
---|---|
1692 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3847
diff
changeset
|
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
1692 | 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 | |
1972 | 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 | |
1692 | 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, | |
7195 | 62 llvm::FunctionType* sig) { |
1692 | 63 return module()->getOrInsertFunction(name, sig); |
64 } | |
65 | |
66 // Basic types | |
67 private: | |
7195 | 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; | |
1692 | 76 |
77 public: | |
7195 | 78 llvm::Type* void_type() const { |
1692 | 79 return _void_type; |
80 } | |
7195 | 81 llvm::IntegerType* bit_type() const { |
1692 | 82 return _bit_type; |
83 } | |
7195 | 84 llvm::IntegerType* jbyte_type() const { |
1692 | 85 return _jbyte_type; |
86 } | |
7195 | 87 llvm::IntegerType* jshort_type() const { |
1692 | 88 return _jshort_type; |
89 } | |
7195 | 90 llvm::IntegerType* jint_type() const { |
1692 | 91 return _jint_type; |
92 } | |
7195 | 93 llvm::IntegerType* jlong_type() const { |
1692 | 94 return _jlong_type; |
95 } | |
7195 | 96 llvm::Type* jfloat_type() const { |
1692 | 97 return _jfloat_type; |
98 } | |
7195 | 99 llvm::Type* jdouble_type() const { |
1692 | 100 return _jdouble_type; |
101 } | |
7195 | 102 llvm::IntegerType* intptr_type() const { |
1692 | 103 return LP64_ONLY(jlong_type()) NOT_LP64(jint_type()); |
104 } | |
105 | |
106 // Compound types | |
107 private: | |
7195 | 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; | |
1692 | 120 |
121 public: | |
7195 | 122 llvm::PointerType* itableOffsetEntry_type() const { |
1692 | 123 return _itableOffsetEntry_type; |
124 } | |
7195 | 125 llvm::PointerType* jniEnv_type() const { |
1692 | 126 return _jniEnv_type; |
127 } | |
7195 | 128 llvm::PointerType* jniHandleBlock_type() const { |
1692 | 129 return _jniHandleBlock_type; |
130 } | |
7195 | 131 llvm::PointerType* Metadata_type() const { |
132 return _Metadata_type; | |
133 } | |
134 llvm::PointerType* klass_type() const { | |
1692 | 135 return _klass_type; |
136 } | |
7195 | 137 llvm::PointerType* Method_type() const { |
138 return _Method_type; | |
1692 | 139 } |
7195 | 140 llvm::ArrayType* monitor_type() const { |
1692 | 141 return _monitor_type; |
142 } | |
7195 | 143 llvm::PointerType* oop_type() const { |
1692 | 144 return _oop_type; |
145 } | |
7195 | 146 llvm::PointerType* thread_type() const { |
1692 | 147 return _thread_type; |
148 } | |
7195 | 149 llvm::PointerType* zeroStack_type() const { |
1692 | 150 return _zeroStack_type; |
151 } | |
7195 | 152 llvm::FunctionType* entry_point_type() const { |
1692 | 153 return _entry_point_type; |
154 } | |
7195 | 155 llvm::FunctionType* osr_entry_point_type() const { |
1692 | 156 return _osr_entry_point_type; |
157 } | |
158 | |
159 // Mappings | |
160 private: | |
7195 | 161 llvm::Type* _to_stackType[T_CONFLICT]; |
162 llvm::Type* _to_arrayType[T_CONFLICT]; | |
1692 | 163 |
164 private: | |
7195 | 165 llvm::Type* map_type(llvm::Type* const* table, |
1692 | 166 BasicType type) const { |
167 assert(type >= 0 && type < T_CONFLICT, "unhandled type"); | |
7195 | 168 llvm::Type* result = table[type]; |
3847
a3142bdb6707
7071823: Zero: zero/shark doesn't build after b147-fcs
twisti
parents:
1972
diff
changeset
|
169 assert(result != NULL, "unhandled type"); |
1692 | 170 return result; |
171 } | |
172 | |
173 public: | |
7195 | 174 llvm::Type* to_stackType(BasicType type) const { |
1692 | 175 return map_type(_to_stackType, type); |
176 } | |
7195 | 177 llvm::Type* to_arrayType(BasicType type) const { |
1692 | 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 }; | |
1972 | 189 |
190 #endif // SHARE_VM_SHARK_SHARKCONTEXT_HPP |