Mercurial > hg > truffle
annotate src/share/vm/shark/sharkCompiler.hpp @ 20470:bc4ce33c0985
8049529: LogCompilation: annotate make_not_compilable with compilation level
Reviewed-by: roland, iveresov
author | vlivanov |
---|---|
date | Mon, 14 Jul 2014 03:27:21 -0700 |
parents | 55fb97c4c58d |
children | 81ccf2c854c7 4ca6dc0799b6 |
rev | line source |
---|---|
1692 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12880
diff
changeset
|
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2447 | 3 * Copyright 2008, 2009, 2010, 2011 Red Hat, Inc. |
1692 | 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_SHARKCOMPILER_HPP |
27 #define SHARE_VM_SHARK_SHARKCOMPILER_HPP | |
28 | |
29 #include "ci/ciEnv.hpp" | |
30 #include "ci/ciMethod.hpp" | |
31 #include "compiler/abstractCompiler.hpp" | |
32 #include "compiler/compileBroker.hpp" | |
33 #include "shark/llvmHeaders.hpp" | |
34 #include "shark/sharkMemoryManager.hpp" | |
35 | |
1692 | 36 class SharkContext; |
37 | |
38 class SharkCompiler : public AbstractCompiler { | |
39 public: | |
40 // Creation | |
41 SharkCompiler(); | |
42 | |
43 // Name of this compiler | |
44 const char *name() { return "shark"; } | |
45 | |
46 // Missing feature tests | |
47 bool supports_native() { return true; } | |
48 bool supports_osr() { return true; } | |
7601 | 49 bool can_compile_method(methodHandle method) { |
50 return ! (method->is_method_handle_intrinsic() || method->is_compiled_lambda_form()); | |
51 } | |
1692 | 52 |
53 // Initialization | |
54 void initialize(); | |
55 | |
56 // Compile a normal (bytecode) method and install it in the VM | |
57 void compile_method(ciEnv* env, ciMethod* target, int entry_bci); | |
58 | |
59 // Generate a wrapper for a native (JNI) method | |
60 nmethod* generate_native_wrapper(MacroAssembler* masm, | |
61 methodHandle target, | |
2447 | 62 int compile_id, |
1692 | 63 BasicType* arg_types, |
64 BasicType return_type); | |
65 | |
66 // Free compiled methods (and native wrappers) | |
67 void free_compiled_method(address code); | |
68 | |
69 // Each thread generating IR needs its own context. The normal | |
70 // context is used for bytecode methods, and is protected from | |
71 // multiple simultaneous accesses by being restricted to the | |
72 // compiler thread. The native context is used for JNI methods, | |
73 // and is protected from multiple simultaneous accesses by the | |
74 // adapter handler library lock. | |
75 private: | |
76 SharkContext* _normal_context; | |
77 SharkContext* _native_context; | |
78 | |
79 public: | |
80 SharkContext* context() const { | |
81 if (JavaThread::current()->is_Compiler_thread()) { | |
82 return _normal_context; | |
83 } | |
84 else { | |
85 assert(AdapterHandlerLibrary_lock->owned_by_self(), "should be"); | |
86 return _native_context; | |
87 } | |
88 } | |
89 | |
90 // The LLVM execution engine is the JIT we use to generate native | |
91 // code. It is thread safe, but we need to protect it with a lock | |
92 // of our own because otherwise LLVM's lock and HotSpot's locks | |
93 // interleave and deadlock. The SharkMemoryManager is not thread | |
94 // safe, and is protected by the same lock as the execution engine. | |
95 private: | |
96 Monitor* _execution_engine_lock; | |
97 SharkMemoryManager* _memory_manager; | |
98 llvm::ExecutionEngine* _execution_engine; | |
99 | |
100 private: | |
101 Monitor* execution_engine_lock() const { | |
102 return _execution_engine_lock; | |
103 } | |
104 SharkMemoryManager* memory_manager() const { | |
105 assert(execution_engine_lock()->owned_by_self(), "should be"); | |
106 return _memory_manager; | |
107 } | |
108 llvm::ExecutionEngine* execution_engine() const { | |
109 assert(execution_engine_lock()->owned_by_self(), "should be"); | |
110 return _execution_engine; | |
111 } | |
112 | |
113 // Global access | |
114 public: | |
115 static SharkCompiler* compiler() { | |
2447 | 116 AbstractCompiler *compiler = |
117 CompileBroker::compiler(CompLevel_full_optimization); | |
1692 | 118 assert(compiler->is_shark() && compiler->is_initialized(), "should be"); |
119 return (SharkCompiler *) compiler; | |
120 } | |
121 | |
122 // Helpers | |
123 private: | |
124 static const char* methodname(const char* klass, const char* method); | |
125 void generate_native_code(SharkEntry* entry, | |
126 llvm::Function* function, | |
127 const char* name); | |
128 void free_queued_methods(); | |
129 }; | |
1972 | 130 |
131 #endif // SHARE_VM_SHARK_SHARKCOMPILER_HPP |