summaryrefslogtreecommitdiffstats
path: root/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch')
-rw-r--r--recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch416
1 files changed, 416 insertions, 0 deletions
diff --git a/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch b/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch
new file mode 100644
index 0000000..ece7f14
--- /dev/null
+++ b/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-shark-build-common.patch
@@ -0,0 +1,416 @@
1--- hotspot/make/Makefile.orig
2+++ hotspot/make/Makefile
3@@ -525,7 +525,7 @@ $(EXPORT_INCLUDE_DIR)/%: $(SHARK_BUILD
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
13+++ hotspot/src/share/vm/ci/ciTypeFlow.cpp
14@@ -35,8 +35,10 @@
15 #include "interpreter/bytecode.hpp"
16 #include "interpreter/bytecodes.hpp"
17 #include "memory/allocation.inline.hpp"
18+#ifdef COMPILER2
19 #include "opto/compile.hpp"
20 #include "opto/node.hpp"
21+#endif
22 #include "runtime/deoptimization.hpp"
23 #include "utilities/growableArray.hpp"
24
25@@ -2648,6 +2650,7 @@ void ciTypeFlow::df_flow_types(Block* st
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@@ -2657,6 +2660,7 @@ void ciTypeFlow::df_flow_types(Block* st
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
42+++ hotspot/src/share/vm/classfile/systemDictionary.cpp
43@@ -2289,6 +2289,7 @@ methodHandle SystemDictionary::find_meth
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@@ -2298,6 +2299,7 @@ methodHandle SystemDictionary::find_meth
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@@ -2311,9 +2313,11 @@ methodHandle SystemDictionary::find_meth
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
72+++ hotspot/src/share/vm/runtime/handles.inline.hpp
73@@ -51,6 +51,12 @@ inline Handle::Handle(Thread* thread, oo
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 @@ inline name##Handle::name##Handle(const
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/share/vm/shark/sharkEntry.hpp.orig
96+++ hotspot/src/share/vm/shark/sharkEntry.hpp
97@@ -27,6 +27,7 @@
98 #define SHARE_VM_SHARK_SHARKENTRY_HPP
99
100 #include "shark/llvmHeaders.hpp"
101+#include "entry_zero.hpp"
102
103 class SharkContext;
104
105--- hotspot/src/share/vm/shark/llvmHeaders.hpp.orig
106+++ hotspot/src/share/vm/shark/llvmHeaders.hpp
107@@ -35,7 +35,11 @@
108 #undef DEBUG
109 #endif
110
111+#if SHARK_LLVM_VERSION <= 34
112 #include <llvm/Analysis/Verifier.h>
113+#else
114+#include <llvm-c/Analysis.h>
115+#endif
116 #include <llvm/ExecutionEngine/ExecutionEngine.h>
117
118 // includes specific to each version
119--- common/autoconf/libraries.m4.orig
120+++ common/autoconf/libraries.m4
121@@ -834,8 +834,9 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIB
122 fi
123 fi
124 done
125- llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
126+ llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//; s/\..*$//')
127 LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
128+ AS_IF([test $llvm_version -ge 34], [LLVM_CFLAGS="${LLVM_CFLAGS} -std=gnu++11"])
129
130 unset LLVM_LDFLAGS
131 for flag in $("${LLVM_CONFIG}" --ldflags); do
132@@ -848,7 +849,7 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIB
133 done
134
135 unset LLVM_LIBS
136- for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
137+ for flag in $("${LLVM_CONFIG}" --libs --system-libs ${llvm_components}); do
138 if echo "${flag}" | grep -q '^-l'; then
139 if test "${LLVM_LIBS}" != ""; then
140 LLVM_LIBS="${LLVM_LIBS} "
141--- hotspot/src/share/vm/shark/sharkIntrinsics.cpp.orig
142+++ hotspot/src/share/vm/shark/sharkIntrinsics.cpp
143@@ -265,7 +265,11 @@ void SharkIntrinsics::do_Unsafe_compareA
144 "addr");
145
146 // Perform the operation
147+#if SHARK_LLVM_VERSION <= 34
148 Value *result = builder()->CreateAtomicCmpXchg(addr, e, x, llvm::SequentiallyConsistent);
149+#else
150+ Value *result = builder()->CreateAtomicCmpXchg(addr, e, x, llvm::SequentiallyConsistent, llvm::SequentiallyConsistent);
151+ #endif
152 // Push the result
153 state()->push(
154 SharkValue::create_jint(
155--- hotspot/src/share/vm/shark/sharkRuntime.cpp.orig
156+++ hotspot/src/share/vm/shark/sharkRuntime.cpp
157@@ -32,6 +32,7 @@
158 #ifdef TARGET_ARCH_zero
159 # include "stack_zero.inline.hpp"
160 #endif
161+#include "memory/oopFactory.hpp"
162
163 using namespace llvm;
164
165--- hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp.orig
166+++ hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
167@@ -1732,7 +1732,11 @@ void SharkTopLevelBlock::do_new() {
168 heap_object = builder()->CreateIntToPtr(
169 old_top, SharkType::oop_type(), "heap_object");
170
171+#if SHARK_LLVM_VERSION <= 34
172 Value *check = builder()->CreateAtomicCmpXchg(top_addr, old_top, new_top, llvm::SequentiallyConsistent);
173+#else
174+ Value *check = builder()->CreateAtomicCmpXchg(top_addr, old_top, new_top, llvm::SequentiallyConsistent, llvm::SequentiallyConsistent);
175+#endif
176 builder()->CreateCondBr(
177 builder()->CreateICmpEQ(old_top, check),
178 initialize, retry);
179@@ -1933,7 +1937,11 @@ void SharkTopLevelBlock::acquire_lock(Va
180
181 Value *lock = builder()->CreatePtrToInt(
182 monitor_header_addr, SharkType::intptr_type());
183+#if SHARK_LLVM_VERSION <= 34
184 Value *check = builder()->CreateAtomicCmpXchg(mark_addr, disp, lock, llvm::Acquire);
185+#else
186+ Value *check = builder()->CreateAtomicCmpXchg(mark_addr, disp, lock, llvm::Acquire, llvm::Acquire);
187+#endif
188 builder()->CreateCondBr(
189 builder()->CreateICmpEQ(disp, check),
190 acquired_fast, try_recursive);
191@@ -2018,7 +2026,11 @@ void SharkTopLevelBlock::release_lock(in
192 PointerType::getUnqual(SharkType::intptr_type()),
193 "mark_addr");
194
195+#if SHARK_LLVM_VERSION <= 34
196 Value *check = builder()->CreateAtomicCmpXchg(mark_addr, lock, disp, llvm::Release);
197+#else
198+ Value *check = builder()->CreateAtomicCmpXchg(mark_addr, lock, disp, llvm::Release, llvm::Monotonic);
199+#endif
200 builder()->CreateCondBr(
201 builder()->CreateICmpEQ(lock, check),
202 released_fast, slow_path);
203--- hotspot/src/cpu/zero/vm/interpreter_zero.cpp.orig
204+++ hotspot/src/cpu/zero/vm/interpreter_zero.cpp
205@@ -49,7 +49,7 @@
206 #ifdef COMPILER1
207 #include "c1/c1_Runtime1.hpp"
208 #endif
209-#ifdef CC_INTERP
210+#if defined(CC_INTERP) || defined(SHARK)
211 #include "interpreter/cppInterpreter.hpp"
212 #endif
213
214--- hotspot/src/share/vm/shark/sharkCompiler.hpp.orig
215+++ hotspot/src/share/vm/shark/sharkCompiler.hpp
216@@ -40,6 +40,8 @@ class SharkCompiler : public AbstractCom
217 // Creation
218 SharkCompiler();
219
220+ void init_llvm();
221+
222 // Name of this compiler
223 const char *name() { return "shark"; }
224
225--- hotspot/src/share/vm/shark/sharkCompiler.cpp.orig
226+++ hotspot/src/share/vm/shark/sharkCompiler.cpp
227@@ -61,11 +61,25 @@ SharkCompiler::SharkCompiler()
228 : AbstractCompiler() {
229 // Create the lock to protect the memory manager and execution engine
230 _execution_engine_lock = new Monitor(Mutex::leaf, "SharkExecutionEngineLock");
231- MutexLocker locker(execution_engine_lock());
232+ {
233+ MutexLocker locker(execution_engine_lock());
234+ init_llvm();
235+ }
236+ // All done
237+ set_state(initialized);
238+}
239
240+void SharkCompiler::init_llvm() {
241+ // with llvm 3.5, Multi-threading can only be enabled/disabled with the
242+ // compile time define LLVM_ENABLE_THREADS
243+#if SHARK_LLVM_VERSION <= 34
244 // Make LLVM safe for multithreading
245 if (!llvm_start_multithreaded())
246 fatal("llvm_start_multithreaded() failed");
247+#else
248+ if (!llvm_is_multithreaded())
249+ fatal("llvm_is_multithreaded() tells no multithreading support in llvm");
250+#endif
251
252 // Initialize the native target
253 InitializeNativeTarget();
254@@ -83,7 +97,7 @@ SharkCompiler::SharkCompiler()
255 // Finetune LLVM for the current host CPU.
256 StringMap<bool> Features;
257 bool gotCpuFeatures = llvm::sys::getHostCPUFeatures(Features);
258- std::string cpu("-mcpu=" + llvm::sys::getHostCPUName());
259+ std::string cpu("-mcpu=" + std::string(llvm::sys::getHostCPUName()));
260
261 std::vector<const char*> args;
262 args.push_back(""); // program name
263@@ -112,6 +126,9 @@ SharkCompiler::SharkCompiler()
264 builder.setMAttrs(MAttrs);
265 builder.setJITMemoryManager(memory_manager());
266 builder.setEngineKind(EngineKind::JIT);
267+#if SHARK_LLVM_VERSION > 34
268+ builder.setUseMCJIT(true);
269+#endif
270 builder.setErrorStr(&ErrorMsg);
271 if (! fnmatch(SharkOptimizationLevel, "None", 0)) {
272 tty->print_cr("Shark optimization level set to: None");
273@@ -133,10 +150,11 @@ SharkCompiler::SharkCompiler()
274 exit(1);
275 }
276
277+#if SHARK_LLVM_VERSION > 34
278+ _native_context->execution_engine(_execution_engine);
279+ _normal_context->execution_engine(_execution_engine);
280+#endif
281 execution_engine()->addModule(_native_context->module());
282-
283- // All done
284- set_state(initialized);
285 }
286
287 void SharkCompiler::initialize() {
288@@ -165,7 +183,7 @@ void SharkCompiler::compile_method(ciEnv
289 }
290
291 // Create the recorders
292- Arena arena;
293+ Arena arena(mtCompiler);
294 env->set_oop_recorder(new OopRecorder(&arena));
295 OopMapSet oopmaps;
296 env->set_debug_info(new DebugInformationRecorder(env->oop_recorder()));
297@@ -268,7 +286,12 @@ void SharkCompiler::generate_native_code
298
299 if (SharkVerifyFunction != NULL) {
300 if (!fnmatch(SharkVerifyFunction, name, 0)) {
301+#if SHARK_LLVM_VERSION <= 34
302 verifyFunction(*function);
303+#else
304+ LLVMValueRef F = wrap(function);
305+ LLVMVerifyFunction(F, LLVMAbortProcessAction);
306+#endif
307 }
308 }
309
310@@ -298,7 +321,11 @@ void SharkCompiler::generate_native_code
311 #endif
312 #endif // !NDEBUG
313 memory_manager()->set_entry_for_function(function, entry);
314+#if SHARK_LLVM_VERSION <= 34
315 code = (address) execution_engine()->getPointerToFunction(function);
316+#else
317+ code = (address) execution_engine()->getFunctionAddress(name);
318+#endif
319 }
320 assert(code != NULL, "code must be != NULL");
321 entry->set_entry_point(code);
322--- hotspot/src/share/vm/shark/sharkContext.cpp.orig
323+++ hotspot/src/share/vm/shark/sharkContext.cpp
324@@ -34,8 +34,13 @@
325 using namespace llvm;
326
327 SharkContext::SharkContext(const char* name)
328- : LLVMContext(),
329- _free_queue(NULL) {
330+ : LLVMContext()
331+ , _free_queue(0)
332+#if SHARK_LLVM_VERSION > 34
333+ , _ee(0)
334+ , func_mod_map()
335+#endif
336+{
337 // Create a module to build our functions into
338 _module = new Module(name, *this);
339
340--- hotspot/src/share/vm/shark/sharkContext.hpp.orig
341+++ hotspot/src/share/vm/shark/sharkContext.hpp
342@@ -29,6 +29,8 @@
343 #include "shark/llvmHeaders.hpp"
344 #include "shark/sharkCompiler.hpp"
345
346+#include <map>
347+
348 // The LLVMContext class allows multiple instances of LLVM to operate
349 // independently of each other in a multithreaded context. We extend
350 // this here to store things in Shark that are LLVMContext-specific.
351@@ -41,12 +43,28 @@ class SharkContext : public llvm::LLVMCo
352
353 private:
354 llvm::Module* _module;
355+#if SHARK_LLVM_VERSION > 34
356+ llvm::ExecutionEngine *_ee;
357+ std::map<std::string, llvm::Module *> func_mod_map;
358+#endif
359
360 public:
361 llvm::Module* module() const {
362 return _module;
363 }
364
365+#if SHARK_LLVM_VERSION > 34
366+ llvm::ExecutionEngine *execution_engine(llvm::ExecutionEngine *ee) {
367+ llvm::ExecutionEngine *oee = _ee;
368+ _ee = ee;
369+ return oee;
370+ }
371+
372+ llvm::ExecutionEngine *execution_engine() const {
373+ return _ee;
374+ }
375+#endif
376+
377 // Get this thread's SharkContext
378 public:
379 static SharkContext& current() {
380@@ -55,12 +73,35 @@ class SharkContext : public llvm::LLVMCo
381
382 // Module accessors
383 public:
384- void add_function(llvm::Function* function) const {
385+ void add_function(llvm::Function* function) {
386+#if SHARK_LLVM_VERSION <= 34
387 module()->getFunctionList().push_back(function);
388+#else
389+ // shark compiles modules, not functions
390+ std::map<std::string, llvm::Module *>::iterator i = func_mod_map.find(function->getName().str());
391+ if(func_mod_map.end() == i) {
392+ llvm::Module *mod4fun = new llvm::Module(function->getName(), *this);
393+ func_mod_map.insert(std::pair<std::string, llvm::Module *>(function->getName().str(), mod4fun));
394+ mod4fun->getFunctionList().push_back(function);
395+ _ee->addModule(mod4fun);
396+ }
397+#endif
398 }
399 llvm::Constant* get_external(const char* name,
400 llvm::FunctionType* sig) {
401+ // XXX see whether we need additional module map, too
402+#if SHARK_LLVM_VERSION <= 34
403 return module()->getOrInsertFunction(name, sig);
404+#else
405+ // shark compiles modules, not functions
406+ std::map<std::string, llvm::Module *>::iterator i = func_mod_map.find(name);
407+ if(func_mod_map.end() == i) {
408+ llvm::Module *mod4fun = new llvm::Module(name, *this);
409+ func_mod_map.insert(std::pair<std::string, llvm::Module *>(name, mod4fun));
410+ mod4fun->getOrInsertFunction(name, sig);
411+ _ee->addModule(mod4fun);
412+ }
413+#endif
414 }
415
416 // Basic types