diff options
Diffstat (limited to 'recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build.patch')
-rw-r--r-- | recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build.patch | 453 |
1 files changed, 453 insertions, 0 deletions
diff --git a/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build.patch b/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build.patch new file mode 100644 index 0000000..bc1abbd --- /dev/null +++ b/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build.patch | |||
@@ -0,0 +1,453 @@ | |||
1 | --- hotspot/make/Makefile.orig 2015-08-31 19:44:44.459038814 +0200 | ||
2 | +++ hotspot/make/Makefile 2015-08-31 19:44:58.511038867 +0200 | ||
3 | @@ -525,7 +525,7 @@ | ||
4 | # Unix | ||
5 | $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX) | ||
6 | $(install-file) | ||
7 | -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_BUILD_DIR)/%.debuginfo | ||
8 | +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(SHARK_BUILD_DIR)/%.debuginfo | ||
9 | $(install-file) | ||
10 | $(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(SHARK_BUILD_DIR)/%.diz | ||
11 | $(install-file) | ||
12 | --- hotspot/src/share/vm/ci/ciTypeFlow.cpp.orig 2015-08-31 19:45:28.611038980 +0200 | ||
13 | +++ hotspot/src/share/vm/ci/ciTypeFlow.cpp 2015-08-31 19:47:17.539039390 +0200 | ||
14 | @@ -35,7 +35,9 @@ | ||
15 | #include "interpreter/bytecode.hpp" | ||
16 | #include "interpreter/bytecodes.hpp" | ||
17 | #include "memory/allocation.inline.hpp" | ||
18 | -#include "opto/compile.hpp" | ||
19 | +#ifdef COMPILER2 | ||
20 | +#include "opto/compile.hpp" | ||
21 | #include "opto/node.hpp" | ||
22 | +#endif | ||
23 | #include "runtime/deoptimization.hpp" | ||
24 | #include "utilities/growableArray.hpp" | ||
25 | @@ -2647,6 +2649,7 @@ | ||
26 | assert (!blk->has_pre_order(), ""); | ||
27 | blk->set_next_pre_order(); | ||
28 | |||
29 | +#ifdef COMPILER2 | ||
30 | if (_next_pre_order >= (int)Compile::current()->max_node_limit() / 2) { | ||
31 | // Too many basic blocks. Bail out. | ||
32 | // This can happen when try/finally constructs are nested to depth N, | ||
33 | @@ -2656,6 +2659,7 @@ | ||
34 | record_failure("too many basic blocks"); | ||
35 | return; | ||
36 | } | ||
37 | +#endif | ||
38 | if (do_flow) { | ||
39 | flow_block(blk, temp_vector, temp_set); | ||
40 | if (failing()) return; // Watch for bailouts. | ||
41 | --- hotspot/src/share/vm/classfile/systemDictionary.cpp.orig 2015-08-31 19:50:00.367040003 +0200 | ||
42 | +++ hotspot/src/share/vm/classfile/systemDictionary.cpp 2015-08-31 19:51:28.323040334 +0200 | ||
43 | @@ -2276,6 +2276,7 @@ | ||
44 | spe = NULL; | ||
45 | // Must create lots of stuff here, but outside of the SystemDictionary lock. | ||
46 | m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty)); | ||
47 | +#ifndef SHARK | ||
48 | if (!Arguments::is_interpreter_only()) { | ||
49 | // Generate a compiled form of the MH intrinsic. | ||
50 | AdapterHandlerLibrary::create_native_wrapper(m); | ||
51 | @@ -2285,6 +2286,7 @@ | ||
52 | "out of space in CodeCache for method handle intrinsic", empty); | ||
53 | } | ||
54 | } | ||
55 | +#endif | ||
56 | // Now grab the lock. We might have to throw away the new method, | ||
57 | // if a racing thread has managed to install one at the same time. | ||
58 | { | ||
59 | @@ -2298,9 +2300,11 @@ | ||
60 | } | ||
61 | |||
62 | assert(spe != NULL && spe->method() != NULL, ""); | ||
63 | +#ifndef SHARK | ||
64 | assert(Arguments::is_interpreter_only() || (spe->method()->has_compiled_code() && | ||
65 | spe->method()->code()->entry_point() == spe->method()->from_compiled_entry()), | ||
66 | "MH intrinsic invariant"); | ||
67 | +#endif | ||
68 | return spe->method(); | ||
69 | } | ||
70 | |||
71 | --- hotspot/src/share/vm/runtime/handles.inline.hpp.orig 2015-08-31 20:01:39.295042634 +0200 | ||
72 | +++ hotspot/src/share/vm/runtime/handles.inline.hpp 2015-08-31 20:04:31.331043282 +0200 | ||
73 | @@ -51,6 +51,12 @@ | ||
74 | } | ||
75 | #endif // ASSERT | ||
76 | |||
77 | +#ifdef SHARK | ||
78 | +#define assert_on_stack(expr) (void)(expr) | ||
79 | +#else | ||
80 | +#define assert_on_stack(expr) assert((expr), "not on stack?") | ||
81 | +#endif | ||
82 | + | ||
83 | // Constructors for metadata handles | ||
84 | #define DEF_METADATA_HANDLE_FN(name, type) \ | ||
85 | inline name##Handle::name##Handle(type* obj) : _value(obj), _thread(NULL) { \ | ||
86 | @@ -79,7 +85,7 @@ | ||
87 | } else { \ | ||
88 | _thread = Thread::current(); \ | ||
89 | } \ | ||
90 | - assert (_thread->is_in_stack((address)this), "not on stack?"); \ | ||
91 | + assert_on_stack (_thread->is_in_stack((address)this)); \ | ||
92 | _thread->metadata_handles()->push((Metadata*)_value); \ | ||
93 | } else { \ | ||
94 | _thread = NULL; \ | ||
95 | --- hotspot/src/cpu/zero/vm/entry_zero.hpp.orig 2015-08-31 20:53:40.743054385 +0200 | ||
96 | +++ hotspot/src/cpu/zero/vm/entry_zero.hpp 2015-08-31 20:53:54.459054436 +0200 | ||
97 | @@ -26,6 +26,10 @@ | ||
98 | #ifndef CPU_ZERO_VM_ENTRY_ZERO_HPP | ||
99 | #define CPU_ZERO_VM_ENTRY_ZERO_HPP | ||
100 | |||
101 | +#include "utilities/globalDefinitions.hpp" | ||
102 | +#include "utilities/exceptions.hpp" | ||
103 | +#include "interpreter/cppInterpreter.hpp" | ||
104 | + | ||
105 | class ZeroEntry { | ||
106 | public: | ||
107 | ZeroEntry() { | ||
108 | --- hotspot/src/share/vm/shark/sharkEntry.hpp.orig 2015-08-31 20:47:13.091052925 +0200 | ||
109 | +++ hotspot/src/share/vm/shark/sharkEntry.hpp 2015-08-31 20:49:42.755053489 +0200 | ||
110 | @@ -27,6 +27,7 @@ | ||
111 | #define SHARE_VM_SHARK_SHARKENTRY_HPP | ||
112 | |||
113 | #include "shark/llvmHeaders.hpp" | ||
114 | +#include "entry_zero.hpp" | ||
115 | |||
116 | class SharkContext; | ||
117 | |||
118 | --- hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp.orig 2015-08-31 21:01:14.847056094 +0200 | ||
119 | +++ hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp 2015-08-31 21:01:24.459056130 +0200 | ||
120 | @@ -30,6 +30,10 @@ | ||
121 | |||
122 | #ifdef CC_INTERP | ||
123 | |||
124 | +#ifdef TARGET_ARCH_zero | ||
125 | +#include "entry_zero.hpp" | ||
126 | +#endif | ||
127 | + | ||
128 | class CppInterpreterGenerator: public AbstractInterpreterGenerator { | ||
129 | protected: | ||
130 | // shared code sequences | ||
131 | --- hotspot/src/cpu/zero/vm/nativeInst_zero.cpp.orig 2015-08-31 21:07:21.643057475 +0200 | ||
132 | +++ hotspot/src/cpu/zero/vm/nativeInst_zero.cpp 2015-08-31 21:14:49.019059159 +0200 | ||
133 | @@ -26,6 +26,9 @@ | ||
134 | #include "precompiled.hpp" | ||
135 | #include "assembler_zero.inline.hpp" | ||
136 | #include "memory/resourceArea.hpp" | ||
137 | +#ifdef CC_INTERP | ||
138 | +#include "entry_zero.hpp" | ||
139 | +#endif | ||
140 | #include "nativeInst_zero.hpp" | ||
141 | #include "oops/oop.inline.hpp" | ||
142 | #include "runtime/handles.hpp" | ||
143 | --- hotspot/src/share/vm/shark/llvmHeaders.hpp.orig 2015-09-01 14:17:09.793868541 +0200 | ||
144 | +++ hotspot/src/share/vm/shark/llvmHeaders.hpp 2015-09-01 16:20:25.653868618 +0200 | ||
145 | @@ -35,7 +35,11 @@ | ||
146 | #undef DEBUG | ||
147 | #endif | ||
148 | |||
149 | +#if SHARK_LLVM_VERSION <= 34 | ||
150 | #include <llvm/Analysis/Verifier.h> | ||
151 | +#else | ||
152 | +#include <llvm-c/Analysis.h> | ||
153 | +#endif | ||
154 | #include <llvm/ExecutionEngine/ExecutionEngine.h> | ||
155 | |||
156 | // includes specific to each version | ||
157 | --- common/autoconf/libraries.m4.orig 2015-09-01 16:53:51.821868486 +0200 | ||
158 | +++ common/autoconf/libraries.m4 2015-09-01 16:55:27.653868542 +0200 | ||
159 | @@ -847,8 +847,9 @@ | ||
160 | fi | ||
161 | fi | ||
162 | done | ||
163 | - llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') | ||
164 | + llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//; s/\..*$//') | ||
165 | LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" | ||
166 | + AS_IF([test $llvm_version -ge 34], [LLVM_CFLAGS="${LLVM_CFLAGS} -std=gnu++11"]) | ||
167 | |||
168 | unset LLVM_LDFLAGS | ||
169 | for flag in $("${LLVM_CONFIG}" --ldflags); do | ||
170 | @@ -862,7 +862,7 @@ | ||
171 | done | ||
172 | |||
173 | unset LLVM_LIBS | ||
174 | - for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do | ||
175 | + for flag in $("${LLVM_CONFIG}" --libs --system-libs ${llvm_components}); do | ||
176 | if echo "${flag}" | grep -q '^-l'; then | ||
177 | if test "${LLVM_LIBS}" != ""; then | ||
178 | LLVM_LIBS="${LLVM_LIBS} " | ||
179 | --- hotspot/src/share/vm/shark/sharkIntrinsics.cpp.orig 2015-09-02 16:58:17.000000000 +0200 | ||
180 | +++ hotspot/src/share/vm/shark/sharkIntrinsics.cpp 2015-09-02 17:09:26.000000000 +0200 | ||
181 | @@ -265,7 +265,11 @@ | ||
182 | "addr"); | ||
183 | |||
184 | // Perform the operation | ||
185 | +#if SHARK_LLVM_VERSION <= 34 | ||
186 | Value *result = builder()->CreateAtomicCmpXchg(addr, e, x, llvm::SequentiallyConsistent); | ||
187 | +#else | ||
188 | + Value *result = builder()->CreateAtomicCmpXchg(addr, e, x, llvm::SequentiallyConsistent, llvm::SequentiallyConsistent); | ||
189 | + #endif | ||
190 | // Push the result | ||
191 | state()->push( | ||
192 | SharkValue::create_jint( | ||
193 | --- hotspot/src/share/vm/shark/sharkRuntime.cpp.orig 2015-09-02 17:11:58.000000000 +0200 | ||
194 | +++ hotspot/src/share/vm/shark/sharkRuntime.cpp 2015-09-02 17:12:57.000000000 +0200 | ||
195 | @@ -32,6 +32,7 @@ | ||
196 | #ifdef TARGET_ARCH_zero | ||
197 | # include "stack_zero.inline.hpp" | ||
198 | #endif | ||
199 | +#include "memory/oopFactory.hpp" | ||
200 | |||
201 | using namespace llvm; | ||
202 | |||
203 | --- hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp.orig 2015-09-02 17:23:07.000000000 +0200 | ||
204 | +++ hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp 2015-09-02 17:43:20.000000000 +0200 | ||
205 | @@ -1732,7 +1732,11 @@ | ||
206 | heap_object = builder()->CreateIntToPtr( | ||
207 | old_top, SharkType::oop_type(), "heap_object"); | ||
208 | |||
209 | +#if SHARK_LLVM_VERSION <= 34 | ||
210 | Value *check = builder()->CreateAtomicCmpXchg(top_addr, old_top, new_top, llvm::SequentiallyConsistent); | ||
211 | +#else | ||
212 | + Value *check = builder()->CreateAtomicCmpXchg(top_addr, old_top, new_top, llvm::SequentiallyConsistent, llvm::SequentiallyConsistent); | ||
213 | +#endif | ||
214 | builder()->CreateCondBr( | ||
215 | builder()->CreateICmpEQ(old_top, check), | ||
216 | initialize, retry); | ||
217 | @@ -1933,7 +1937,11 @@ | ||
218 | |||
219 | Value *lock = builder()->CreatePtrToInt( | ||
220 | monitor_header_addr, SharkType::intptr_type()); | ||
221 | +#if SHARK_LLVM_VERSION <= 34 | ||
222 | Value *check = builder()->CreateAtomicCmpXchg(mark_addr, disp, lock, llvm::Acquire); | ||
223 | +#else | ||
224 | + Value *check = builder()->CreateAtomicCmpXchg(mark_addr, disp, lock, llvm::Acquire, llvm::Acquire); | ||
225 | +#endif | ||
226 | builder()->CreateCondBr( | ||
227 | builder()->CreateICmpEQ(disp, check), | ||
228 | acquired_fast, try_recursive); | ||
229 | @@ -2018,7 +2026,11 @@ | ||
230 | PointerType::getUnqual(SharkType::intptr_type()), | ||
231 | "mark_addr"); | ||
232 | |||
233 | +#if SHARK_LLVM_VERSION <= 34 | ||
234 | Value *check = builder()->CreateAtomicCmpXchg(mark_addr, lock, disp, llvm::Release); | ||
235 | +#else | ||
236 | + Value *check = builder()->CreateAtomicCmpXchg(mark_addr, lock, disp, llvm::Release, llvm::Monotonic); | ||
237 | +#endif | ||
238 | builder()->CreateCondBr( | ||
239 | builder()->CreateICmpEQ(lock, check), | ||
240 | released_fast, slow_path); | ||
241 | --- hotspot/src/cpu/zero/vm/interpreter_zero.cpp.orig 2015-09-14 20:13:25.539432044 +0200 | ||
242 | +++ hotspot/src/cpu/zero/vm/interpreter_zero.cpp 2015-09-14 20:13:46.107432122 +0200 | ||
243 | @@ -49,7 +49,7 @@ | ||
244 | #ifdef COMPILER1 | ||
245 | #include "c1/c1_Runtime1.hpp" | ||
246 | #endif | ||
247 | -#ifdef CC_INTERP | ||
248 | +#if defined(CC_INTERP) || defined(SHARK) | ||
249 | #include "interpreter/cppInterpreter.hpp" | ||
250 | #endif | ||
251 | |||
252 | --- hotspot/src/share/vm/shark/sharkCompiler.hpp.orig 2015-08-31 20:08:44.723044236 +0200 | ||
253 | +++ hotspot/src/share/vm/shark/sharkCompiler.hpp 2015-08-31 20:08:59.387044291 +0200 | ||
254 | @@ -40,6 +40,8 @@ | ||
255 | // Creation | ||
256 | SharkCompiler(); | ||
257 | |||
258 | + void init_llvm(); | ||
259 | + | ||
260 | // Name of this compiler | ||
261 | const char *name() { return "shark"; } | ||
262 | |||
263 | --- hotspot/src/share/vm/shark/sharkCompiler.cpp.orig 2015-09-19 12:19:21.000000000 +0200 | ||
264 | +++ hotspot/src/share/vm/shark/sharkCompiler.cpp 2015-09-19 12:27:17.000000000 +0200 | ||
265 | @@ -61,11 +61,25 @@ | ||
266 | : AbstractCompiler() { | ||
267 | // Create the lock to protect the memory manager and execution engine | ||
268 | _execution_engine_lock = new Monitor(Mutex::leaf, "SharkExecutionEngineLock"); | ||
269 | - MutexLocker locker(execution_engine_lock()); | ||
270 | + { | ||
271 | + MutexLocker locker(execution_engine_lock()); | ||
272 | + init_llvm(); | ||
273 | + } | ||
274 | + // All done | ||
275 | + set_state(initialized); | ||
276 | +} | ||
277 | |||
278 | +void SharkCompiler::init_llvm() { | ||
279 | + // with llvm 3.5, Multi-threading can only be enabled/disabled with the | ||
280 | + // compile time define LLVM_ENABLE_THREADS | ||
281 | +#if SHARK_LLVM_VERSION <= 34 | ||
282 | // Make LLVM safe for multithreading | ||
283 | if (!llvm_start_multithreaded()) | ||
284 | fatal("llvm_start_multithreaded() failed"); | ||
285 | +#else | ||
286 | + if (!llvm_is_multithreaded()) | ||
287 | + fatal("llvm_is_multithreaded() tells no multithreading support in llvm"); | ||
288 | +#endif | ||
289 | |||
290 | // Initialize the native target | ||
291 | InitializeNativeTarget(); | ||
292 | @@ -83,7 +97,7 @@ | ||
293 | // Finetune LLVM for the current host CPU. | ||
294 | StringMap<bool> Features; | ||
295 | bool gotCpuFeatures = llvm::sys::getHostCPUFeatures(Features); | ||
296 | - std::string cpu("-mcpu=" + llvm::sys::getHostCPUName()); | ||
297 | + std::string cpu("-mcpu=" + std::string(llvm::sys::getHostCPUName())); | ||
298 | |||
299 | std::vector<const char*> args; | ||
300 | args.push_back(""); // program name | ||
301 | @@ -112,6 +126,9 @@ | ||
302 | builder.setMAttrs(MAttrs); | ||
303 | builder.setJITMemoryManager(memory_manager()); | ||
304 | builder.setEngineKind(EngineKind::JIT); | ||
305 | +#if SHARK_LLVM_VERSION > 34 | ||
306 | + builder.setUseMCJIT(true); | ||
307 | +#endif | ||
308 | builder.setErrorStr(&ErrorMsg); | ||
309 | if (! fnmatch(SharkOptimizationLevel, "None", 0)) { | ||
310 | tty->print_cr("Shark optimization level set to: None"); | ||
311 | @@ -134,9 +151,10 @@ | ||
312 | } | ||
313 | |||
314 | +#if SHARK_LLVM_VERSION > 34 | ||
315 | + _native_context->execution_engine(_execution_engine); | ||
316 | + _normal_context->execution_engine(_execution_engine); | ||
317 | +#endif | ||
318 | execution_engine()->addModule(_native_context->module()); | ||
319 | - | ||
320 | - // All done | ||
321 | - set_state(initialized); | ||
322 | } | ||
323 | |||
324 | void SharkCompiler::initialize() { | ||
325 | @@ -165,7 +179,7 @@ | ||
326 | } | ||
327 | |||
328 | // Create the recorders | ||
329 | - Arena arena; | ||
330 | + Arena arena(mtCompiler); | ||
331 | env->set_oop_recorder(new OopRecorder(&arena)); | ||
332 | OopMapSet oopmaps; | ||
333 | env->set_debug_info(new DebugInformationRecorder(env->oop_recorder())); | ||
334 | @@ -268,7 +282,12 @@ | ||
335 | |||
336 | if (SharkVerifyFunction != NULL) { | ||
337 | if (!fnmatch(SharkVerifyFunction, name, 0)) { | ||
338 | +#if SHARK_LLVM_VERSION <= 34 | ||
339 | verifyFunction(*function); | ||
340 | +#else | ||
341 | + LLVMValueRef F = wrap(function); | ||
342 | + LLVMVerifyFunction(F, LLVMAbortProcessAction); | ||
343 | +#endif | ||
344 | } | ||
345 | } | ||
346 | |||
347 | @@ -298,7 +317,11 @@ | ||
348 | #endif | ||
349 | #endif // !NDEBUG | ||
350 | memory_manager()->set_entry_for_function(function, entry); | ||
351 | +#if SHARK_LLVM_VERSION <= 34 | ||
352 | code = (address) execution_engine()->getPointerToFunction(function); | ||
353 | +#else | ||
354 | + code = (address) execution_engine()->getFunctionAddress(name); | ||
355 | +#endif | ||
356 | } | ||
357 | assert(code != NULL, "code must be != NULL"); | ||
358 | entry->set_entry_point(code); | ||
359 | --- hotspot/src/share/vm/shark/sharkContext.cpp.orig 2015-09-21 11:22:51.707813194 +0200 | ||
360 | +++ hotspot/src/share/vm/shark/sharkContext.cpp 2015-09-21 13:47:56.243845961 +0200 | ||
361 | @@ -34,8 +34,13 @@ | ||
362 | using namespace llvm; | ||
363 | |||
364 | SharkContext::SharkContext(const char* name) | ||
365 | - : LLVMContext(), | ||
366 | - _free_queue(NULL) { | ||
367 | + : LLVMContext() | ||
368 | + , _free_queue(0) | ||
369 | +#if SHARK_LLVM_VERSION > 34 | ||
370 | + , _ee(0) | ||
371 | + , func_mod_map() | ||
372 | +#endif | ||
373 | +{ | ||
374 | // Create a module to build our functions into | ||
375 | _module = new Module(name, *this); | ||
376 | |||
377 | --- hotspot/src/share/vm/shark/sharkContext.hpp.orig 2015-09-21 10:58:37.195807719 +0200 | ||
378 | +++ hotspot/src/share/vm/shark/sharkContext.hpp 2015-09-21 13:50:48.459846609 +0200 | ||
379 | @@ -29,6 +29,8 @@ | ||
380 | #include "shark/llvmHeaders.hpp" | ||
381 | #include "shark/sharkCompiler.hpp" | ||
382 | |||
383 | +#include <map> | ||
384 | + | ||
385 | // The LLVMContext class allows multiple instances of LLVM to operate | ||
386 | // independently of each other in a multithreaded context. We extend | ||
387 | // this here to store things in Shark that are LLVMContext-specific. | ||
388 | @@ -41,12 +43,28 @@ | ||
389 | |||
390 | private: | ||
391 | llvm::Module* _module; | ||
392 | +#if SHARK_LLVM_VERSION > 34 | ||
393 | + llvm::ExecutionEngine *_ee; | ||
394 | + std::map<std::string, llvm::Module *> func_mod_map; | ||
395 | +#endif | ||
396 | |||
397 | public: | ||
398 | llvm::Module* module() const { | ||
399 | return _module; | ||
400 | } | ||
401 | |||
402 | +#if SHARK_LLVM_VERSION > 34 | ||
403 | + llvm::ExecutionEngine *execution_engine(llvm::ExecutionEngine *ee) { | ||
404 | + llvm::ExecutionEngine *oee = _ee; | ||
405 | + _ee = ee; | ||
406 | + return oee; | ||
407 | + } | ||
408 | + | ||
409 | + llvm::ExecutionEngine *execution_engine() const { | ||
410 | + return _ee; | ||
411 | + } | ||
412 | +#endif | ||
413 | + | ||
414 | // Get this thread's SharkContext | ||
415 | public: | ||
416 | static SharkContext& current() { | ||
417 | @@ -55,12 +73,35 @@ | ||
418 | |||
419 | // Module accessors | ||
420 | public: | ||
421 | - void add_function(llvm::Function* function) const { | ||
422 | + void add_function(llvm::Function* function) { | ||
423 | +#if SHARK_LLVM_VERSION <= 34 | ||
424 | module()->getFunctionList().push_back(function); | ||
425 | +#else | ||
426 | + // shark compiles modules, not functions | ||
427 | + std::map<std::string, llvm::Module *>::iterator i = func_mod_map.find(function->getName().str()); | ||
428 | + if(func_mod_map.end() == i) { | ||
429 | + llvm::Module *mod4fun = new llvm::Module(function->getName(), *this); | ||
430 | + func_mod_map.insert(std::pair<std::string, llvm::Module *>(function->getName().str(), mod4fun)); | ||
431 | + mod4fun->getFunctionList().push_back(function); | ||
432 | + _ee->addModule(mod4fun); | ||
433 | + } | ||
434 | +#endif | ||
435 | } | ||
436 | llvm::Constant* get_external(const char* name, | ||
437 | llvm::FunctionType* sig) { | ||
438 | + // XXX see whether we need additional module map, too | ||
439 | +#if SHARK_LLVM_VERSION <= 34 | ||
440 | return module()->getOrInsertFunction(name, sig); | ||
441 | +#else | ||
442 | + // shark compiles modules, not functions | ||
443 | + std::map<std::string, llvm::Module *>::iterator i = func_mod_map.find(name); | ||
444 | + if(func_mod_map.end() == i) { | ||
445 | + llvm::Module *mod4fun = new llvm::Module(name, *this); | ||
446 | + func_mod_map.insert(std::pair<std::string, llvm::Module *>(name, mod4fun)); | ||
447 | + mod4fun->getOrInsertFunction(name, sig); | ||
448 | + _ee->addModule(mod4fun); | ||
449 | + } | ||
450 | +#endif | ||
451 | } | ||
452 | |||
453 | // Basic types | ||