Mercurial > hg > truffle
annotate src/share/vm/compiler/compileBroker.cpp @ 7154:5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 12 Dec 2012 21:36:40 +0100 |
parents | 1baf7f1e3f23 |
children | 291ffc492eb6 |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "code/codeCache.hpp" | |
29 #include "compiler/compileBroker.hpp" | |
30 #include "compiler/compileLog.hpp" | |
31 #include "compiler/compilerOracle.hpp" | |
32 #include "interpreter/linkResolver.hpp" | |
33 #include "memory/allocation.inline.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
34 #include "oops/methodData.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
35 #include "oops/method.hpp" |
1972 | 36 #include "oops/oop.inline.hpp" |
37 #include "prims/nativeLookup.hpp" | |
38 #include "runtime/arguments.hpp" | |
39 #include "runtime/compilationPolicy.hpp" | |
40 #include "runtime/init.hpp" | |
41 #include "runtime/interfaceSupport.hpp" | |
42 #include "runtime/javaCalls.hpp" | |
43 #include "runtime/os.hpp" | |
44 #include "runtime/sharedRuntime.hpp" | |
45 #include "runtime/sweeper.hpp" | |
46 #include "utilities/dtrace.hpp" | |
4559
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4319
diff
changeset
|
47 #ifdef GRAAL |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2494
diff
changeset
|
48 #include "graal/graalCompiler.hpp" |
4559
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4319
diff
changeset
|
49 #endif |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
50 #include "utilities/events.hpp" |
1972 | 51 #ifdef COMPILER1 |
52 #include "c1/c1_Compiler.hpp" | |
53 #endif | |
7125
1baf7f1e3f23
decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents:
6948
diff
changeset
|
54 #ifdef GRAAL |
1baf7f1e3f23
decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents:
6948
diff
changeset
|
55 #include "graal/graalCompiler.hpp" |
1baf7f1e3f23
decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents:
6948
diff
changeset
|
56 #endif |
1972 | 57 #ifdef COMPILER2 |
58 #include "opto/c2compiler.hpp" | |
59 #endif | |
60 #ifdef SHARK | |
61 #include "shark/sharkCompiler.hpp" | |
62 #endif | |
0 | 63 |
64 #ifdef DTRACE_ENABLED | |
65 | |
66 // Only bother with this argument setup if dtrace is available | |
67 | |
4006 | 68 #ifndef USDT2 |
0 | 69 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, |
70 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); | |
71 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, | |
72 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); | |
73 | |
74 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) \ | |
75 { \ | |
76 char* comp_name = (char*)(compiler)->name(); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
77 Symbol* klass_name = (method)->klass_name(); \ |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
78 Symbol* name = (method)->name(); \ |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
79 Symbol* signature = (method)->signature(); \ |
0 | 80 HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ |
81 comp_name, strlen(comp_name), \ | |
82 klass_name->bytes(), klass_name->utf8_length(), \ | |
83 name->bytes(), name->utf8_length(), \ | |
84 signature->bytes(), signature->utf8_length()); \ | |
85 } | |
86 | |
87 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) \ | |
88 { \ | |
89 char* comp_name = (char*)(compiler)->name(); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
90 Symbol* klass_name = (method)->klass_name(); \ |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
91 Symbol* name = (method)->name(); \ |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
92 Symbol* signature = (method)->signature(); \ |
0 | 93 HS_DTRACE_PROBE9(hotspot, method__compile__end, \ |
94 comp_name, strlen(comp_name), \ | |
95 klass_name->bytes(), klass_name->utf8_length(), \ | |
96 name->bytes(), name->utf8_length(), \ | |
97 signature->bytes(), signature->utf8_length(), (success)); \ | |
98 } | |
99 | |
4006 | 100 #else /* USDT2 */ |
101 | |
102 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) \ | |
103 { \ | |
104 char* comp_name = (char*)(compiler)->name(); \ | |
105 Symbol* klass_name = (method)->klass_name(); \ | |
106 Symbol* name = (method)->name(); \ | |
107 Symbol* signature = (method)->signature(); \ | |
108 HOTSPOT_METHOD_COMPILE_BEGIN( \ | |
109 comp_name, strlen(comp_name), \ | |
110 (char *) klass_name->bytes(), klass_name->utf8_length(), \ | |
111 (char *) name->bytes(), name->utf8_length(), \ | |
112 (char *) signature->bytes(), signature->utf8_length()); \ | |
113 } | |
114 | |
115 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) \ | |
116 { \ | |
117 char* comp_name = (char*)(compiler)->name(); \ | |
118 Symbol* klass_name = (method)->klass_name(); \ | |
119 Symbol* name = (method)->name(); \ | |
120 Symbol* signature = (method)->signature(); \ | |
121 HOTSPOT_METHOD_COMPILE_END( \ | |
122 comp_name, strlen(comp_name), \ | |
123 (char *) klass_name->bytes(), klass_name->utf8_length(), \ | |
124 (char *) name->bytes(), name->utf8_length(), \ | |
125 (char *) signature->bytes(), signature->utf8_length(), (success)); \ | |
126 } | |
127 #endif /* USDT2 */ | |
128 | |
0 | 129 #else // ndef DTRACE_ENABLED |
130 | |
131 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) | |
132 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) | |
133 | |
134 #endif // ndef DTRACE_ENABLED | |
135 | |
136 bool CompileBroker::_initialized = false; | |
137 volatile bool CompileBroker::_should_block = false; | |
1202 | 138 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; |
0 | 139 |
140 // The installed compiler(s) | |
141 AbstractCompiler* CompileBroker::_compilers[2]; | |
142 | |
143 // These counters are used for assigning id's to each compilation | |
144 uint CompileBroker::_compilation_id = 0; | |
145 uint CompileBroker::_osr_compilation_id = 0; | |
146 | |
147 // Debugging information | |
148 int CompileBroker::_last_compile_type = no_compile; | |
149 int CompileBroker::_last_compile_level = CompLevel_none; | |
150 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; | |
151 | |
152 // Performance counters | |
153 PerfCounter* CompileBroker::_perf_total_compilation = NULL; | |
154 PerfCounter* CompileBroker::_perf_osr_compilation = NULL; | |
155 PerfCounter* CompileBroker::_perf_standard_compilation = NULL; | |
156 | |
157 PerfCounter* CompileBroker::_perf_total_bailout_count = NULL; | |
158 PerfCounter* CompileBroker::_perf_total_invalidated_count = NULL; | |
159 PerfCounter* CompileBroker::_perf_total_compile_count = NULL; | |
160 PerfCounter* CompileBroker::_perf_total_osr_compile_count = NULL; | |
161 PerfCounter* CompileBroker::_perf_total_standard_compile_count = NULL; | |
162 | |
163 PerfCounter* CompileBroker::_perf_sum_osr_bytes_compiled = NULL; | |
164 PerfCounter* CompileBroker::_perf_sum_standard_bytes_compiled = NULL; | |
165 PerfCounter* CompileBroker::_perf_sum_nmethod_size = NULL; | |
166 PerfCounter* CompileBroker::_perf_sum_nmethod_code_size = NULL; | |
167 | |
168 PerfStringVariable* CompileBroker::_perf_last_method = NULL; | |
169 PerfStringVariable* CompileBroker::_perf_last_failed_method = NULL; | |
170 PerfStringVariable* CompileBroker::_perf_last_invalidated_method = NULL; | |
171 PerfVariable* CompileBroker::_perf_last_compile_type = NULL; | |
172 PerfVariable* CompileBroker::_perf_last_compile_size = NULL; | |
173 PerfVariable* CompileBroker::_perf_last_failed_type = NULL; | |
174 PerfVariable* CompileBroker::_perf_last_invalidated_type = NULL; | |
175 | |
176 // Timers and counters for generating statistics | |
177 elapsedTimer CompileBroker::_t_total_compilation; | |
178 elapsedTimer CompileBroker::_t_osr_compilation; | |
179 elapsedTimer CompileBroker::_t_standard_compilation; | |
180 | |
181 int CompileBroker::_total_bailout_count = 0; | |
182 int CompileBroker::_total_invalidated_count = 0; | |
183 int CompileBroker::_total_compile_count = 0; | |
184 int CompileBroker::_total_osr_compile_count = 0; | |
185 int CompileBroker::_total_standard_compile_count = 0; | |
186 | |
187 int CompileBroker::_sum_osr_bytes_compiled = 0; | |
188 int CompileBroker::_sum_standard_bytes_compiled = 0; | |
189 int CompileBroker::_sum_nmethod_size = 0; | |
190 int CompileBroker::_sum_nmethod_code_size = 0; | |
191 | |
1783 | 192 CompileQueue* CompileBroker::_c2_method_queue = NULL; |
193 CompileQueue* CompileBroker::_c1_method_queue = NULL; | |
0 | 194 CompileTask* CompileBroker::_task_free_list = NULL; |
195 | |
196 GrowableArray<CompilerThread*>* CompileBroker::_method_threads = NULL; | |
197 | |
198 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
199 class CompilationLog : public StringEventLog { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
200 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
201 CompilationLog() : StringEventLog("Compilation events") { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
202 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
203 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
204 void log_compile(JavaThread* thread, CompileTask* task) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
205 StringLogMessage lm; |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
206 stringStream sstr = lm.stream(); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
207 // msg.time_stamp().update_to(tty->time_stamp().ticks()); |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
208 task->print_compilation(&sstr, NULL, true); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
209 log(thread, "%s", (const char*)lm); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
210 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
211 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
212 void log_nmethod(JavaThread* thread, nmethod* nm) { |
4944 | 213 log(thread, "nmethod %d%s " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]", |
214 nm->compile_id(), nm->is_osr_method() ? "%" : "", | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
215 nm, nm->code_begin(), nm->code_end()); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
216 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
217 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
218 void log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
219 StringLogMessage lm; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
220 lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
221 if (retry_message != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
222 lm.append(" (%s)", retry_message); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
223 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
224 lm.print("\n"); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
225 log(thread, "%s", (const char*)lm); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
226 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
227 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
228 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
229 static CompilationLog* _compilation_log = NULL; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
230 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
231 void compileBroker_init() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
232 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
233 _compilation_log = new CompilationLog(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
234 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
235 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
236 |
0 | 237 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) { |
238 CompilerThread* thread = CompilerThread::current(); | |
239 thread->set_task(task); | |
240 CompileLog* log = thread->log(); | |
241 if (log != NULL) task->log_task_start(log); | |
242 } | |
243 | |
244 CompileTaskWrapper::~CompileTaskWrapper() { | |
245 CompilerThread* thread = CompilerThread::current(); | |
246 CompileTask* task = thread->task(); | |
247 CompileLog* log = thread->log(); | |
248 if (log != NULL) task->log_task_done(log); | |
249 thread->set_task(NULL); | |
250 task->set_code_handle(NULL); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
251 thread->set_env(NULL); |
0 | 252 if (task->is_blocking()) { |
253 MutexLocker notifier(task->lock(), thread); | |
254 task->mark_complete(); | |
255 // Notify the waiting thread that the compilation has completed. | |
256 task->lock()->notify_all(); | |
257 } else { | |
258 task->mark_complete(); | |
259 | |
260 // By convention, the compiling thread is responsible for | |
261 // recycling a non-blocking CompileTask. | |
262 CompileBroker::free_task(task); | |
263 } | |
264 } | |
265 | |
266 | |
267 // ------------------------------------------------------------------ | |
268 // CompileTask::initialize | |
269 void CompileTask::initialize(int compile_id, | |
270 methodHandle method, | |
271 int osr_bci, | |
272 int comp_level, | |
273 methodHandle hot_method, | |
274 int hot_count, | |
275 const char* comment, | |
276 bool is_blocking) { | |
277 assert(!_lock->is_locked(), "bad locking"); | |
278 | |
279 _compile_id = compile_id; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
280 _method = method(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
281 _method_loader = JNIHandles::make_global(_method->method_holder()->class_loader()); |
0 | 282 _osr_bci = osr_bci; |
283 _is_blocking = is_blocking; | |
284 _comp_level = comp_level; | |
285 _num_inlined_bytecodes = 0; | |
286 | |
287 _is_complete = false; | |
288 _is_success = false; | |
289 _code_handle = NULL; | |
290 | |
291 _hot_method = NULL; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
292 _hot_method_loader = NULL; |
0 | 293 _hot_count = hot_count; |
294 _time_queued = 0; // tidy | |
295 _comment = comment; | |
296 | |
297 if (LogCompilation) { | |
298 _time_queued = os::elapsed_counter(); | |
299 if (hot_method.not_null()) { | |
300 if (hot_method == method) { | |
301 _hot_method = _method; | |
302 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
303 _hot_method = hot_method(); |
0 | 304 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
305 _hot_method_loader = JNIHandles::make_global(_hot_method->method_holder()->class_loader()); |
0 | 306 } |
307 } | |
308 | |
309 _next = NULL; | |
310 } | |
311 | |
312 // ------------------------------------------------------------------ | |
313 // CompileTask::code/set_code | |
314 nmethod* CompileTask::code() const { | |
315 if (_code_handle == NULL) return NULL; | |
316 return _code_handle->code(); | |
317 } | |
318 void CompileTask::set_code(nmethod* nm) { | |
319 if (_code_handle == NULL && nm == NULL) return; | |
320 guarantee(_code_handle != NULL, ""); | |
321 _code_handle->set_code(nm); | |
322 if (nm == NULL) _code_handle = NULL; // drop the handle also | |
323 } | |
324 | |
325 // ------------------------------------------------------------------ | |
326 // CompileTask::free | |
327 void CompileTask::free() { | |
328 set_code(NULL); | |
329 assert(!_lock->is_locked(), "Should not be locked when freed"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
330 JNIHandles::destroy_global(_method_loader); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
331 JNIHandles::destroy_global(_hot_method_loader); |
0 | 332 } |
333 | |
334 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
335 void CompileTask::mark_on_stack() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
336 // Mark these methods as something redefine classes cannot remove. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
337 _method->set_on_stack(true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
338 if (_hot_method != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
339 _hot_method->set_on_stack(true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
340 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
341 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
342 |
0 | 343 // ------------------------------------------------------------------ |
344 // CompileTask::print | |
345 void CompileTask::print() { | |
346 tty->print("<CompileTask compile_id=%d ", _compile_id); | |
347 tty->print("method="); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
348 _method->print_name(tty); |
0 | 349 tty->print_cr(" osr_bci=%d is_blocking=%s is_complete=%s is_success=%s>", |
350 _osr_bci, bool_to_str(_is_blocking), | |
351 bool_to_str(_is_complete), bool_to_str(_is_success)); | |
352 } | |
353 | |
1783 | 354 |
0 | 355 // ------------------------------------------------------------------ |
356 // CompileTask::print_line_on_error | |
357 // | |
358 // This function is called by fatal error handler when the thread | |
359 // causing troubles is a compiler thread. | |
360 // | |
361 // Do not grab any lock, do not allocate memory. | |
362 // | |
363 // Otherwise it's the same as CompileTask::print_line() | |
364 // | |
365 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) { | |
366 // print compiler name | |
367 st->print("%s:", CompileBroker::compiler(comp_level())->name()); | |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
368 print_compilation(st); |
0 | 369 } |
370 | |
371 // ------------------------------------------------------------------ | |
372 // CompileTask::print_line | |
373 void CompileTask::print_line() { | |
374 ttyLocker ttyl; // keep the following output all in one block | |
375 // print compiler name if requested | |
376 if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name()); | |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
377 print_compilation(); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
378 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
379 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
380 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
381 // ------------------------------------------------------------------ |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
382 // CompileTask::print_compilation_impl |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
383 void CompileTask::print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level, |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
384 bool is_osr_method, int osr_bci, bool is_blocking, |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
385 const char* msg, bool short_form) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
386 if (!short_form) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
387 st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
388 } |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
389 st->print("%4d ", compile_id); // print compilation number |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
390 |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
391 // For unloaded methods the transition to zombie occurs after the |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
392 // method is cleared so it's impossible to report accurate |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
393 // information for that case. |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
394 bool is_synchronized = false; |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
395 bool has_exception_handler = false; |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
396 bool is_native = false; |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
397 if (method != NULL) { |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
398 is_synchronized = method->is_synchronized(); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
399 has_exception_handler = method->has_exception_handler(); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
400 is_native = method->is_native(); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
401 } |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
402 // method attributes |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
403 const char compile_type = is_osr_method ? '%' : ' '; |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
404 const char sync_char = is_synchronized ? 's' : ' '; |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
405 const char exception_char = has_exception_handler ? '!' : ' '; |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
406 const char blocking_char = is_blocking ? 'b' : ' '; |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
407 const char native_char = is_native ? 'n' : ' '; |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
408 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
409 // print method attributes |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
410 st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
411 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
412 if (TieredCompilation) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
413 if (comp_level != -1) st->print("%d ", comp_level); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
414 else st->print("- "); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
415 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
416 st->print(" "); // more indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
417 |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
418 if (method == NULL) { |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
419 st->print("(method)"); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
420 } else { |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
421 method->print_short_name(st); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
422 if (is_osr_method) { |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
423 st->print(" @ %d", osr_bci); |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
3294
diff
changeset
|
424 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
425 if (method->is_native()) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
426 st->print(" (native)"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
427 else |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
428 st->print(" (%d bytes)", method->code_size()); |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
429 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
430 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
431 if (msg != NULL) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
432 st->print(" %s", msg); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
433 } |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
434 if (!short_form) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
435 st->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
436 } |
0 | 437 } |
438 | |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
439 // ------------------------------------------------------------------ |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
440 // CompileTask::print_inlining |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
441 void CompileTask::print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
442 // 1234567 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
443 st->print(" "); // print timestamp |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
444 // 1234 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
445 st->print(" "); // print compilation number |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
446 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
447 // method attributes |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
448 if (method->is_loaded()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
449 const char sync_char = method->is_synchronized() ? 's' : ' '; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
450 const char exception_char = method->has_exception_handlers() ? '!' : ' '; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
451 const char monitors_char = method->has_monitor_bytecodes() ? 'm' : ' '; |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
452 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
453 // print method attributes |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
454 st->print(" %c%c%c ", sync_char, exception_char, monitors_char); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
455 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
456 // %s!bn |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
457 st->print(" "); // print method attributes |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
458 } |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
459 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
460 if (TieredCompilation) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
461 st->print(" "); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
462 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
463 st->print(" "); // more indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
464 st->print(" "); // initial inlining indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
465 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
466 for (int i = 0; i < inline_level; i++) st->print(" "); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
467 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
468 st->print("@ %d ", bci); // print bci |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
469 method->print_short_name(st); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
470 if (method->is_loaded()) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
471 st->print(" (%d bytes)", method->code_size()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
472 else |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
473 st->print(" (not loaded)"); |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
474 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
475 if (msg != NULL) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
476 st->print(" %s", msg); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
477 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
478 st->cr(); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
479 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
480 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
481 // ------------------------------------------------------------------ |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
482 // CompileTask::print_inline_indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
483 void CompileTask::print_inline_indent(int inline_level, outputStream* st) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
484 // 1234567 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
485 st->print(" "); // print timestamp |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
486 // 1234 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
487 st->print(" "); // print compilation number |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
488 // %s!bn |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
489 st->print(" "); // print method attributes |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
490 if (TieredCompilation) { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
491 st->print(" "); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
492 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
493 st->print(" "); // more indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
494 st->print(" "); // initial inlining indent |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
495 for (int i = 0; i < inline_level; i++) st->print(" "); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
496 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
497 |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
498 // ------------------------------------------------------------------ |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
499 // CompileTask::print_compilation |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
500 void CompileTask::print_compilation(outputStream* st, const char* msg, bool short_form) { |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
501 bool is_osr_method = osr_bci() != InvocationEntryBci; |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
502 print_compilation_impl(st, method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form); |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
503 } |
0 | 504 |
505 // ------------------------------------------------------------------ | |
506 // CompileTask::log_task | |
507 void CompileTask::log_task(xmlStream* log) { | |
508 Thread* thread = Thread::current(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
509 methodHandle method(thread, this->method()); |
0 | 510 ResourceMark rm(thread); |
511 | |
512 // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'> | |
513 if (_compile_id != 0) log->print(" compile_id='%d'", _compile_id); | |
514 if (_osr_bci != CompileBroker::standard_entry_bci) { | |
515 log->print(" compile_kind='osr'"); // same as nmethod::compile_kind | |
516 } // else compile_kind='c2c' | |
517 if (!method.is_null()) log->method(method); | |
518 if (_osr_bci != CompileBroker::standard_entry_bci) { | |
519 log->print(" osr_bci='%d'", _osr_bci); | |
520 } | |
521 if (_comp_level != CompLevel_highest_tier) { | |
522 log->print(" level='%d'", _comp_level); | |
523 } | |
524 if (_is_blocking) { | |
525 log->print(" blocking='1'"); | |
526 } | |
527 log->stamp(); | |
528 } | |
529 | |
530 | |
531 // ------------------------------------------------------------------ | |
532 // CompileTask::log_task_queued | |
533 void CompileTask::log_task_queued() { | |
534 Thread* thread = Thread::current(); | |
535 ttyLocker ttyl; | |
536 ResourceMark rm(thread); | |
537 | |
538 xtty->begin_elem("task_queued"); | |
539 log_task(xtty); | |
540 if (_comment != NULL) { | |
541 xtty->print(" comment='%s'", _comment); | |
542 } | |
543 if (_hot_method != NULL) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
544 methodHandle hot(thread, _hot_method); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
545 methodHandle method(thread, _method); |
0 | 546 if (hot() != method()) { |
547 xtty->method(hot); | |
548 } | |
549 } | |
550 if (_hot_count != 0) { | |
551 xtty->print(" hot_count='%d'", _hot_count); | |
552 } | |
553 xtty->end_elem(); | |
554 } | |
555 | |
556 | |
557 // ------------------------------------------------------------------ | |
558 // CompileTask::log_task_start | |
559 void CompileTask::log_task_start(CompileLog* log) { | |
560 log->begin_head("task"); | |
561 log_task(log); | |
562 log->end_head(); | |
563 } | |
564 | |
565 | |
566 // ------------------------------------------------------------------ | |
567 // CompileTask::log_task_done | |
568 void CompileTask::log_task_done(CompileLog* log) { | |
569 Thread* thread = Thread::current(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
570 methodHandle method(thread, this->method()); |
0 | 571 ResourceMark rm(thread); |
572 | |
573 // <task_done ... stamp='1.234'> </task> | |
574 nmethod* nm = code(); | |
575 log->begin_elem("task_done success='%d' nmsize='%d' count='%d'", | |
1748 | 576 _is_success, nm == NULL ? 0 : nm->content_size(), |
0 | 577 method->invocation_count()); |
578 int bec = method->backedge_count(); | |
579 if (bec != 0) log->print(" backedge_count='%d'", bec); | |
580 // Note: "_is_complete" is about to be set, but is not. | |
581 if (_num_inlined_bytecodes != 0) { | |
582 log->print(" inlined_bytes='%d'", _num_inlined_bytecodes); | |
583 } | |
584 log->stamp(); | |
585 log->end_elem(); | |
586 log->tail("task"); | |
587 log->clear_identities(); // next task will have different CI | |
588 if (log->unflushed_count() > 2000) { | |
589 log->flush(); | |
590 } | |
591 log->mark_file_end(); | |
592 } | |
593 | |
594 | |
595 | |
596 // ------------------------------------------------------------------ | |
597 // CompileQueue::add | |
598 // | |
599 // Add a CompileTask to a CompileQueue | |
600 void CompileQueue::add(CompileTask* task) { | |
601 assert(lock()->owned_by_self(), "must own lock"); | |
602 | |
603 task->set_next(NULL); | |
1783 | 604 task->set_prev(NULL); |
0 | 605 |
606 if (_last == NULL) { | |
607 // The compile queue is empty. | |
608 assert(_first == NULL, "queue is empty"); | |
609 _first = task; | |
610 _last = task; | |
611 } else { | |
612 // Append the task to the queue. | |
613 assert(_last->next() == NULL, "not last"); | |
614 _last->set_next(task); | |
1783 | 615 task->set_prev(_last); |
0 | 616 _last = task; |
617 } | |
1783 | 618 ++_size; |
0 | 619 |
620 // Mark the method as being in the compile queue. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
621 task->method()->set_queued_for_compilation(); |
0 | 622 |
623 if (CIPrintCompileQueue) { | |
624 print(); | |
625 } | |
626 | |
627 if (LogCompilation && xtty != NULL) { | |
628 task->log_task_queued(); | |
629 } | |
630 | |
631 // Notify CompilerThreads that a task is available. | |
1783 | 632 lock()->notify_all(); |
0 | 633 } |
634 | |
635 // ------------------------------------------------------------------ | |
636 // CompileQueue::get | |
637 // | |
638 // Get the next CompileTask from a CompileQueue | |
639 CompileTask* CompileQueue::get() { | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
640 NMethodSweeper::possibly_sweep(); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
641 |
0 | 642 MutexLocker locker(lock()); |
643 // Wait for an available CompileTask. | |
644 while (_first == NULL) { | |
645 // There is no work to be done right now. Wait. | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
646 if (UseCodeCacheFlushing && (!CompileBroker::should_compile_new_jobs() || CodeCache::needs_flushing())) { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
647 // During the emergency sweeping periods, wake up and sweep occasionally |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
648 bool timedout = lock()->wait(!Mutex::_no_safepoint_check_flag, NmethodSweepCheckInterval*1000); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
649 if (timedout) { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
650 MutexUnlocker ul(lock()); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
651 // When otherwise not busy, run nmethod sweeping |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
652 NMethodSweeper::possibly_sweep(); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
653 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
654 } else { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
655 // During normal operation no need to wake up on timer |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
656 lock()->wait(); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1353
diff
changeset
|
657 } |
0 | 658 } |
1783 | 659 CompileTask* task = CompilationPolicy::policy()->select_task(this); |
660 remove(task); | |
661 return task; | |
662 } | |
0 | 663 |
1783 | 664 void CompileQueue::remove(CompileTask* task) |
665 { | |
666 assert(lock()->owned_by_self(), "must own lock"); | |
667 if (task->prev() != NULL) { | |
668 task->prev()->set_next(task->next()); | |
669 } else { | |
670 // max is the first element | |
671 assert(task == _first, "Sanity"); | |
672 _first = task->next(); | |
0 | 673 } |
674 | |
1783 | 675 if (task->next() != NULL) { |
676 task->next()->set_prev(task->prev()); | |
677 } else { | |
678 // max is the last element | |
679 assert(task == _last, "Sanity"); | |
680 _last = task->prev(); | |
681 } | |
682 --_size; | |
0 | 683 } |
684 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
685 // methods in the compile queue need to be marked as used on the stack |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
686 // so that they don't get reclaimed by Redefine Classes |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
687 void CompileQueue::mark_on_stack() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
688 CompileTask* task = _first; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
689 while (task != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
690 task->mark_on_stack(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
691 task = task->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
692 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
693 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
694 |
0 | 695 // ------------------------------------------------------------------ |
696 // CompileQueue::print | |
697 void CompileQueue::print() { | |
698 tty->print_cr("Contents of %s", name()); | |
699 tty->print_cr("----------------------"); | |
700 CompileTask* task = _first; | |
701 while (task != NULL) { | |
702 task->print_line(); | |
703 task = task->next(); | |
704 } | |
705 tty->print_cr("----------------------"); | |
706 } | |
707 | |
708 CompilerCounters::CompilerCounters(const char* thread_name, int instance, TRAPS) { | |
709 | |
710 _current_method[0] = '\0'; | |
711 _compile_type = CompileBroker::no_compile; | |
712 | |
713 if (UsePerfData) { | |
714 ResourceMark rm; | |
715 | |
716 // create the thread instance name space string - don't create an | |
717 // instance subspace if instance is -1 - keeps the adapterThread | |
718 // counters from having a ".0" namespace. | |
719 const char* thread_i = (instance == -1) ? thread_name : | |
720 PerfDataManager::name_space(thread_name, instance); | |
721 | |
722 | |
723 char* name = PerfDataManager::counter_name(thread_i, "method"); | |
724 _perf_current_method = | |
725 PerfDataManager::create_string_variable(SUN_CI, name, | |
726 cmname_buffer_length, | |
727 _current_method, CHECK); | |
728 | |
729 name = PerfDataManager::counter_name(thread_i, "type"); | |
730 _perf_compile_type = PerfDataManager::create_variable(SUN_CI, name, | |
731 PerfData::U_None, | |
732 (jlong)_compile_type, | |
733 CHECK); | |
734 | |
735 name = PerfDataManager::counter_name(thread_i, "time"); | |
736 _perf_time = PerfDataManager::create_counter(SUN_CI, name, | |
737 PerfData::U_Ticks, CHECK); | |
738 | |
739 name = PerfDataManager::counter_name(thread_i, "compiles"); | |
740 _perf_compiles = PerfDataManager::create_counter(SUN_CI, name, | |
741 PerfData::U_Events, CHECK); | |
742 } | |
743 } | |
744 | |
745 // ------------------------------------------------------------------ | |
746 // CompileBroker::compilation_init | |
747 // | |
748 // Initialize the Compilation object | |
749 void CompileBroker::compilation_init() { | |
750 _last_method_compiled[0] = '\0'; | |
751 | |
1970 | 752 #ifndef SHARK |
0 | 753 // Set the interface to the current compiler(s). |
1783 | 754 int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); |
755 int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); | |
7154
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
756 |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
757 #ifdef GRAAL |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
758 GraalCompiler* graal = new GraalCompiler(); |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
759 #endif |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
760 |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
761 #if defined(GRAALVM) |
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
762 _compilers[0] = graal; |
4981
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
763 c1_count = 0; |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
764 c2_count = 0; |
4977
532be189cf09
Reducing diff to hsx24
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
765 #elif defined(COMPILER1) |
1783 | 766 if (c1_count > 0) { |
767 _compilers[0] = new Compiler(); | |
768 } | |
0 | 769 #endif // COMPILER1 |
770 | |
771 #ifdef COMPILER2 | |
1783 | 772 if (c2_count > 0) { |
773 _compilers[1] = new C2Compiler(); | |
774 } | |
0 | 775 #endif // COMPILER2 |
776 | |
1970 | 777 #else // SHARK |
778 int c1_count = 0; | |
779 int c2_count = 1; | |
780 | |
781 _compilers[1] = new SharkCompiler(); | |
782 #endif // SHARK | |
1692 | 783 |
0 | 784 // Initialize the CompileTask free list |
785 _task_free_list = NULL; | |
786 | |
787 // Start the CompilerThreads | |
1783 | 788 init_compiler_threads(c1_count, c2_count); |
0 | 789 // totalTime performance counter is always created as it is required |
790 // by the implementation of java.lang.management.CompilationMBean. | |
791 { | |
792 EXCEPTION_MARK; | |
793 _perf_total_compilation = | |
794 PerfDataManager::create_counter(JAVA_CI, "totalTime", | |
795 PerfData::U_Ticks, CHECK); | |
796 } | |
797 | |
798 | |
799 if (UsePerfData) { | |
800 | |
801 EXCEPTION_MARK; | |
802 | |
803 // create the jvmstat performance counters | |
804 _perf_osr_compilation = | |
805 PerfDataManager::create_counter(SUN_CI, "osrTime", | |
806 PerfData::U_Ticks, CHECK); | |
807 | |
808 _perf_standard_compilation = | |
809 PerfDataManager::create_counter(SUN_CI, "standardTime", | |
810 PerfData::U_Ticks, CHECK); | |
811 | |
812 _perf_total_bailout_count = | |
813 PerfDataManager::create_counter(SUN_CI, "totalBailouts", | |
814 PerfData::U_Events, CHECK); | |
815 | |
816 _perf_total_invalidated_count = | |
817 PerfDataManager::create_counter(SUN_CI, "totalInvalidates", | |
818 PerfData::U_Events, CHECK); | |
819 | |
820 _perf_total_compile_count = | |
821 PerfDataManager::create_counter(SUN_CI, "totalCompiles", | |
822 PerfData::U_Events, CHECK); | |
823 _perf_total_osr_compile_count = | |
824 PerfDataManager::create_counter(SUN_CI, "osrCompiles", | |
825 PerfData::U_Events, CHECK); | |
826 | |
827 _perf_total_standard_compile_count = | |
828 PerfDataManager::create_counter(SUN_CI, "standardCompiles", | |
829 PerfData::U_Events, CHECK); | |
830 | |
831 _perf_sum_osr_bytes_compiled = | |
832 PerfDataManager::create_counter(SUN_CI, "osrBytes", | |
833 PerfData::U_Bytes, CHECK); | |
834 | |
835 _perf_sum_standard_bytes_compiled = | |
836 PerfDataManager::create_counter(SUN_CI, "standardBytes", | |
837 PerfData::U_Bytes, CHECK); | |
838 | |
839 _perf_sum_nmethod_size = | |
840 PerfDataManager::create_counter(SUN_CI, "nmethodSize", | |
841 PerfData::U_Bytes, CHECK); | |
842 | |
843 _perf_sum_nmethod_code_size = | |
844 PerfDataManager::create_counter(SUN_CI, "nmethodCodeSize", | |
845 PerfData::U_Bytes, CHECK); | |
846 | |
847 _perf_last_method = | |
848 PerfDataManager::create_string_variable(SUN_CI, "lastMethod", | |
849 CompilerCounters::cmname_buffer_length, | |
850 "", CHECK); | |
851 | |
852 _perf_last_failed_method = | |
853 PerfDataManager::create_string_variable(SUN_CI, "lastFailedMethod", | |
854 CompilerCounters::cmname_buffer_length, | |
855 "", CHECK); | |
856 | |
857 _perf_last_invalidated_method = | |
858 PerfDataManager::create_string_variable(SUN_CI, "lastInvalidatedMethod", | |
859 CompilerCounters::cmname_buffer_length, | |
860 "", CHECK); | |
861 | |
862 _perf_last_compile_type = | |
863 PerfDataManager::create_variable(SUN_CI, "lastType", | |
864 PerfData::U_None, | |
865 (jlong)CompileBroker::no_compile, | |
866 CHECK); | |
867 | |
868 _perf_last_compile_size = | |
869 PerfDataManager::create_variable(SUN_CI, "lastSize", | |
870 PerfData::U_Bytes, | |
871 (jlong)CompileBroker::no_compile, | |
872 CHECK); | |
873 | |
874 | |
875 _perf_last_failed_type = | |
876 PerfDataManager::create_variable(SUN_CI, "lastFailedType", | |
877 PerfData::U_None, | |
878 (jlong)CompileBroker::no_compile, | |
879 CHECK); | |
880 | |
881 _perf_last_invalidated_type = | |
882 PerfDataManager::create_variable(SUN_CI, "lastInvalidatedType", | |
883 PerfData::U_None, | |
884 (jlong)CompileBroker::no_compile, | |
885 CHECK); | |
886 } | |
887 | |
888 _initialized = true; | |
889 } | |
890 | |
891 | |
892 | |
893 // ------------------------------------------------------------------ | |
894 // CompileBroker::make_compiler_thread | |
895 CompilerThread* CompileBroker::make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, TRAPS) { | |
896 CompilerThread* compiler_thread = NULL; | |
897 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
898 Klass* k = |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
899 SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), |
0 | 900 true, CHECK_0); |
901 instanceKlassHandle klass (THREAD, k); | |
902 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_0); | |
903 Handle string = java_lang_String::create_from_str(name, CHECK_0); | |
904 | |
905 // Initialize thread_oop to put it into the system threadGroup | |
906 Handle thread_group (THREAD, Universe::system_thread_group()); | |
907 JavaValue result(T_VOID); | |
908 JavaCalls::call_special(&result, thread_oop, | |
909 klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
910 vmSymbols::object_initializer_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
911 vmSymbols::threadgroup_string_void_signature(), |
0 | 912 thread_group, |
913 string, | |
914 CHECK_0); | |
915 | |
916 { | |
917 MutexLocker mu(Threads_lock, THREAD); | |
918 compiler_thread = new CompilerThread(queue, counters); | |
919 // At this point the new CompilerThread data-races with this startup | |
920 // thread (which I believe is the primoridal thread and NOT the VM | |
921 // thread). This means Java bytecodes being executed at startup can | |
922 // queue compile jobs which will run at whatever default priority the | |
923 // newly created CompilerThread runs at. | |
924 | |
925 | |
926 // At this point it may be possible that no osthread was created for the | |
927 // JavaThread due to lack of memory. We would have to throw an exception | |
928 // in that case. However, since this must work and we do not allow | |
929 // exceptions anyway, check and abort if this fails. | |
930 | |
931 if (compiler_thread == NULL || compiler_thread->osthread() == NULL){ | |
932 vm_exit_during_initialization("java.lang.OutOfMemoryError", | |
933 "unable to create new native thread"); | |
934 } | |
935 | |
936 java_lang_Thread::set_thread(thread_oop(), compiler_thread); | |
937 | |
938 // Note that this only sets the JavaThread _priority field, which by | |
939 // definition is limited to Java priorities and not OS priorities. | |
940 // The os-priority is set in the CompilerThread startup code itself | |
4854
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
941 |
0 | 942 java_lang_Thread::set_priority(thread_oop(), NearMaxPriority); |
4854
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
943 |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
944 // Note that we cannot call os::set_priority because it expects Java |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
945 // priorities and we are *explicitly* using OS priorities so that it's |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
946 // possible to set the compiler thread priority higher than any Java |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
947 // thread. |
0 | 948 |
4854
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
949 int native_prio = CompilerThreadPriority; |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
950 if (native_prio == -1) { |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
951 if (UseCriticalCompilerThreadPriority) { |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
952 native_prio = os::java_to_os_priority[CriticalPriority]; |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
953 } else { |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
954 native_prio = os::java_to_os_priority[NearMaxPriority]; |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
955 } |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
956 } |
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
957 os::set_native_priority(compiler_thread, native_prio); |
0 | 958 |
959 java_lang_Thread::set_daemon(thread_oop()); | |
960 | |
961 compiler_thread->set_threadObj(thread_oop()); | |
962 Threads::add(compiler_thread); | |
963 Thread::start(compiler_thread); | |
964 } | |
4854
de268c8a8075
7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents:
4122
diff
changeset
|
965 |
0 | 966 // Let go of Threads_lock before yielding |
967 os::yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS) | |
968 | |
969 return compiler_thread; | |
970 } | |
971 | |
972 | |
973 // ------------------------------------------------------------------ | |
974 // CompileBroker::init_compiler_threads | |
975 // | |
976 // Initialize the compilation queue | |
1783 | 977 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) { |
0 | 978 EXCEPTION_MARK; |
7154
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
979 #if !defined(ZERO) && !defined(SHARK) && !defined(GRAALVM) |
1783 | 980 assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?"); |
7154
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
981 #endif // !ZERO && !SHARK && !GRAALVM |
1783 | 982 if (c2_compiler_count > 0) { |
983 _c2_method_queue = new CompileQueue("C2MethodQueue", MethodCompileQueue_lock); | |
984 } | |
985 if (c1_compiler_count > 0) { | |
986 _c1_method_queue = new CompileQueue("C1MethodQueue", MethodCompileQueue_lock); | |
987 } | |
0 | 988 |
1783 | 989 int compiler_count = c1_compiler_count + c2_compiler_count; |
990 | |
0 | 991 _method_threads = |
6197 | 992 new (ResourceObj::C_HEAP, mtCompiler) GrowableArray<CompilerThread*>(compiler_count, true); |
0 | 993 |
994 char name_buffer[256]; | |
1783 | 995 for (int i = 0; i < c2_compiler_count; i++) { |
0 | 996 // Create a name for our thread. |
1783 | 997 sprintf(name_buffer, "C2 CompilerThread%d", i); |
0 | 998 CompilerCounters* counters = new CompilerCounters("compilerThread", i, CHECK); |
1783 | 999 CompilerThread* new_thread = make_compiler_thread(name_buffer, _c2_method_queue, counters, CHECK); |
0 | 1000 _method_threads->append(new_thread); |
1001 } | |
1783 | 1002 |
1003 for (int i = c2_compiler_count; i < compiler_count; i++) { | |
1004 // Create a name for our thread. | |
1005 sprintf(name_buffer, "C1 CompilerThread%d", i); | |
1006 CompilerCounters* counters = new CompilerCounters("compilerThread", i, CHECK); | |
1007 CompilerThread* new_thread = make_compiler_thread(name_buffer, _c1_method_queue, counters, CHECK); | |
1008 _method_threads->append(new_thread); | |
1009 } | |
1010 | |
0 | 1011 if (UsePerfData) { |
1012 PerfDataManager::create_constant(SUN_CI, "threads", PerfData::U_Bytes, | |
1013 compiler_count, CHECK); | |
1014 } | |
1015 } | |
1016 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1017 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1018 // Set the methods on the stack as on_stack so that redefine classes doesn't |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1019 // reclaim them |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1020 void CompileBroker::mark_on_stack() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1021 if (_c2_method_queue != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1022 _c2_method_queue->mark_on_stack(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1023 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1024 if (_c1_method_queue != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1025 _c1_method_queue->mark_on_stack(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1026 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1027 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1028 |
0 | 1029 // ------------------------------------------------------------------ |
1030 // CompileBroker::is_idle | |
1031 bool CompileBroker::is_idle() { | |
1783 | 1032 if (_c2_method_queue != NULL && !_c2_method_queue->is_empty()) { |
1033 return false; | |
1034 } else if (_c1_method_queue != NULL && !_c1_method_queue->is_empty()) { | |
0 | 1035 return false; |
1036 } else { | |
1037 int num_threads = _method_threads->length(); | |
1038 for (int i=0; i<num_threads; i++) { | |
1039 if (_method_threads->at(i)->task() != NULL) { | |
1040 return false; | |
1041 } | |
1042 } | |
1043 } | |
4559
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4319
diff
changeset
|
1044 // No pending or active compilations. |
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4319
diff
changeset
|
1045 return true; |
0 | 1046 } |
1047 | |
1048 | |
1049 // ------------------------------------------------------------------ | |
1050 // CompileBroker::compile_method | |
1051 // | |
1052 // Request compilation of a method. | |
1053 void CompileBroker::compile_method_base(methodHandle method, | |
1054 int osr_bci, | |
1055 int comp_level, | |
1056 methodHandle hot_method, | |
1057 int hot_count, | |
1058 const char* comment, | |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
4122
diff
changeset
|
1059 Thread* thread) { |
0 | 1060 // do nothing if compiler thread(s) is not available |
1061 if (!_initialized ) { | |
1062 return; | |
1063 } | |
1064 | |
1065 guarantee(!method->is_abstract(), "cannot compile abstract methods"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1066 assert(method->method_holder()->oop_is_instance(), |
0 | 1067 "sanity check"); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6843
diff
changeset
|
1068 assert(!method->method_holder()->is_not_initialized(), |
0 | 1069 "method holder must be initialized"); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
1070 assert(!method->is_method_handle_intrinsic(), "do not enqueue these guys"); |
0 | 1071 |
1072 if (CIPrintRequests) { | |
1073 tty->print("request: "); | |
1074 method->print_short_name(tty); | |
1075 if (osr_bci != InvocationEntryBci) { | |
1076 tty->print(" osr_bci: %d", osr_bci); | |
1077 } | |
1078 tty->print(" comment: %s count: %d", comment, hot_count); | |
1079 if (!hot_method.is_null()) { | |
1080 tty->print(" hot: "); | |
1081 if (hot_method() != method()) { | |
1082 hot_method->print_short_name(tty); | |
1083 } else { | |
1084 tty->print("yes"); | |
1085 } | |
1086 } | |
1087 tty->cr(); | |
1088 } | |
1089 | |
1090 // A request has been made for compilation. Before we do any | |
1091 // real work, check to see if the method has been compiled | |
1092 // in the meantime with a definitive result. | |
1093 if (compilation_is_complete(method, osr_bci, comp_level)) { | |
1094 return; | |
1095 } | |
1096 | |
2403 | 1097 #ifndef PRODUCT |
1098 if (osr_bci != -1 && !FLAG_IS_DEFAULT(OSROnlyBCI)) { | |
1099 if ((OSROnlyBCI > 0) ? (OSROnlyBCI != osr_bci) : (-OSROnlyBCI == osr_bci)) { | |
1100 // Positive OSROnlyBCI means only compile that bci. Negative means don't compile that BCI. | |
1101 return; | |
1102 } | |
1103 } | |
1104 #endif | |
1783 | 1105 |
0 | 1106 // If this method is already in the compile queue, then |
1107 // we do not block the current thread. | |
1108 if (compilation_is_in_queue(method, osr_bci)) { | |
1109 // We may want to decay our counter a bit here to prevent | |
1110 // multiple denied requests for compilation. This is an | |
1111 // open compilation policy issue. Note: The other possibility, | |
1112 // in the case that this is a blocking compile request, is to have | |
1113 // all subsequent blocking requesters wait for completion of | |
1114 // ongoing compiles. Note that in this case we'll need a protocol | |
1115 // for freeing the associated compile tasks. [Or we could have | |
1116 // a single static monitor on which all these waiters sleep.] | |
1117 return; | |
1118 } | |
1119 | |
3294
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1120 // If the requesting thread is holding the pending list lock |
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1121 // then we just return. We can't risk blocking while holding |
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1122 // the pending list lock or a 3-way deadlock may occur |
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1123 // between the reference handler thread, a GC (instigated |
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1124 // by a compiler thread), and compiled method registration. |
6735
aed758eda82a
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
6725
diff
changeset
|
1125 if (InstanceRefKlass::owns_pending_list_lock(JavaThread::current())) { |
3294
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1126 return; |
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1127 } |
7154
5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents:
7125
diff
changeset
|
1128 #ifdef GRAALVM |
4981
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1129 if (!JavaThread::current()->is_compiling()) { |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1130 method->set_queued_for_compilation(); |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1131 GraalCompiler::instance()->compile_method(method, osr_bci, is_compile_blocking(method, osr_bci)); |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1132 } else { |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1133 // Recursive compile request => ignore. |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1134 } |
1b8d02e10ee8
Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4977
diff
changeset
|
1135 #else |
3294
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1136 |
0 | 1137 // Outputs from the following MutexLocker block: |
1138 CompileTask* task = NULL; | |
1139 bool blocking = false; | |
1783 | 1140 CompileQueue* queue = compile_queue(comp_level); |
0 | 1141 |
1142 // Acquire our lock. | |
1143 { | |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
4122
diff
changeset
|
1144 MutexLocker locker(queue->lock(), thread); |
0 | 1145 |
1146 // Make sure the method has not slipped into the queues since | |
1147 // last we checked; note that those checks were "fast bail-outs". | |
1148 // Here we need to be more careful, see 14012000 below. | |
1149 if (compilation_is_in_queue(method, osr_bci)) { | |
1150 return; | |
1151 } | |
1152 | |
1153 // We need to check again to see if the compilation has | |
1154 // completed. A previous compilation may have registered | |
1155 // some result. | |
1156 if (compilation_is_complete(method, osr_bci, comp_level)) { | |
1157 return; | |
1158 } | |
1159 | |
1160 // We now know that this compilation is not pending, complete, | |
1161 // or prohibited. Assign a compile_id to this compilation | |
1162 // and check to see if it is in our [Start..Stop) range. | |
1163 uint compile_id = assign_compile_id(method, osr_bci); | |
1164 if (compile_id == 0) { | |
1165 // The compilation falls outside the allowed range. | |
1166 return; | |
1167 } | |
1168 | |
1169 // Should this thread wait for completion of the compile? | |
1170 blocking = is_compile_blocking(method, osr_bci); | |
1171 | |
1172 // We will enter the compilation in the queue. | |
1173 // 14012000: Note that this sets the queued_for_compile bits in | |
1174 // the target method. We can now reason that a method cannot be | |
1175 // queued for compilation more than once, as follows: | |
1176 // Before a thread queues a task for compilation, it first acquires | |
1177 // the compile queue lock, then checks if the method's queued bits | |
1178 // are set or it has already been compiled. Thus there can not be two | |
1179 // instances of a compilation task for the same method on the | |
1180 // compilation queue. Consider now the case where the compilation | |
1181 // thread has already removed a task for that method from the queue | |
1182 // and is in the midst of compiling it. In this case, the | |
1183 // queued_for_compile bits must be set in the method (and these | |
1184 // will be visible to the current thread, since the bits were set | |
1185 // under protection of the compile queue lock, which we hold now. | |
1186 // When the compilation completes, the compiler thread first sets | |
1187 // the compilation result and then clears the queued_for_compile | |
1188 // bits. Neither of these actions are protected by a barrier (or done | |
1189 // under the protection of a lock), so the only guarantee we have | |
1190 // (on machines with TSO (Total Store Order)) is that these values | |
1191 // will update in that order. As a result, the only combinations of | |
1192 // these bits that the current thread will see are, in temporal order: | |
1193 // <RESULT, QUEUE> : | |
1194 // <0, 1> : in compile queue, but not yet compiled | |
1195 // <1, 1> : compiled but queue bit not cleared | |
1196 // <1, 0> : compiled and queue bit cleared | |
1197 // Because we first check the queue bits then check the result bits, | |
1198 // we are assured that we cannot introduce a duplicate task. | |
1199 // Note that if we did the tests in the reverse order (i.e. check | |
1200 // result then check queued bit), we could get the result bit before | |
1201 // the compilation completed, and the queue bit after the compilation | |
1202 // completed, and end up introducing a "duplicate" (redundant) task. | |
1203 // In that case, the compiler thread should first check if a method | |
1204 // has already been compiled before trying to compile it. | |
1205 // NOTE: in the event that there are multiple compiler threads and | |
1206 // there is de-optimization/recompilation, things will get hairy, | |
1207 // and in that case it's best to protect both the testing (here) of | |
1208 // these bits, and their updating (here and elsewhere) under a | |
1209 // common lock. | |
1783 | 1210 task = create_compile_task(queue, |
0 | 1211 compile_id, method, |
1212 osr_bci, comp_level, | |
1213 hot_method, hot_count, comment, | |
1214 blocking); | |
1215 } | |
1216 | |
1217 if (blocking) { | |
1218 wait_for_completion(task); | |
1219 } | |
4559
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4319
diff
changeset
|
1220 #endif |
0 | 1221 } |
1222 | |
1223 | |
1224 nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, | |
1783 | 1225 int comp_level, |
0 | 1226 methodHandle hot_method, int hot_count, |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
4122
diff
changeset
|
1227 const char* comment, Thread* THREAD) { |
0 | 1228 // make sure arguments make sense |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1229 assert(method->method_holder()->oop_is_instance(), "not an instance method"); |
0 | 1230 assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range"); |
1231 assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods"); | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6843
diff
changeset
|
1232 assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized"); |
0 | 1233 |
1783 | 1234 if (!TieredCompilation) { |
1235 comp_level = CompLevel_highest_tier; | |
0 | 1236 } |
1237 | |
1238 // return quickly if possible | |
1239 | |
1240 // lock, make sure that the compilation | |
1241 // isn't prohibited in a straightforward way. | |
1242 | |
1243 if (compiler(comp_level) == NULL || compilation_is_prohibited(method, osr_bci, comp_level)) { | |
1244 return NULL; | |
1245 } | |
1246 | |
1247 if (osr_bci == InvocationEntryBci) { | |
1248 // standard compilation | |
1249 nmethod* method_code = method->code(); | |
1783 | 1250 if (method_code != NULL) { |
1251 if (compilation_is_complete(method, osr_bci, comp_level)) { | |
1252 return method_code; | |
1253 } | |
0 | 1254 } |
1255 if (method->is_not_compilable(comp_level)) return NULL; | |
1202 | 1256 |
1300
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1257 if (UseCodeCacheFlushing) { |
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1258 nmethod* saved = CodeCache::find_and_remove_saved_code(method()); |
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1259 if (saved != NULL) { |
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1260 method->set_code(method, saved); |
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1261 return saved; |
428a9c451986
6935466: new CodeCache flushing code is not guarded by the flag
kvn
parents:
1208
diff
changeset
|
1262 } |
1202 | 1263 } |
1264 | |
0 | 1265 } else { |
1266 // osr compilation | |
1267 #ifndef TIERED | |
1268 // seems like an assert of dubious value | |
1783 | 1269 assert(comp_level == CompLevel_highest_tier, |
0 | 1270 "all OSR compiles are assumed to be at a single compilation lavel"); |
1271 #endif // TIERED | |
1783 | 1272 // We accept a higher level osr method |
1273 nmethod* nm = method->lookup_osr_nmethod_for(osr_bci, comp_level, false); | |
0 | 1274 if (nm != NULL) return nm; |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1275 if (method->is_not_osr_compilable(comp_level)) return NULL; |
0 | 1276 } |
1277 | |
1278 assert(!HAS_PENDING_EXCEPTION, "No exception should be present"); | |
1279 // some prerequisites that are compiler specific | |
2447 | 1280 if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) { |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
4122
diff
changeset
|
1281 method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NULL); |
0 | 1282 // Resolve all classes seen in the signature of the method |
1283 // we are compiling. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1284 Method::load_signature_classes(method, CHECK_AND_CLEAR_NULL); |
0 | 1285 } |
1286 | |
1287 // If the method is native, do the lookup in the thread requesting | |
1288 // the compilation. Native lookups can load code, which is not | |
1289 // permitted during compilation. | |
1290 // | |
1291 // Note: A native method implies non-osr compilation which is | |
1292 // checked with an assertion at the entry of this method. | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
1293 if (method->is_native() && !method->is_method_handle_intrinsic()) { |
0 | 1294 bool in_base_library; |
1295 address adr = NativeLookup::lookup(method, in_base_library, THREAD); | |
1296 if (HAS_PENDING_EXCEPTION) { | |
1297 // In case of an exception looking up the method, we just forget | |
1298 // about it. The interpreter will kick-in and throw the exception. | |
1299 method->set_not_compilable(); // implies is_not_osr_compilable() | |
1300 CLEAR_PENDING_EXCEPTION; | |
1301 return NULL; | |
1302 } | |
1303 assert(method->has_native_function(), "must have native code by now"); | |
1304 } | |
1305 | |
1306 // RedefineClasses() has replaced this method; just return | |
1307 if (method->is_old()) { | |
1308 return NULL; | |
1309 } | |
1310 | |
1311 // JVMTI -- post_compile_event requires jmethod_id() that may require | |
1312 // a lock the compiling thread can not acquire. Prefetch it here. | |
1313 if (JvmtiExport::should_post_compiled_method_load()) { | |
1314 method->jmethod_id(); | |
1315 } | |
1316 | |
1202 | 1317 // If the compiler is shut off due to code cache flushing or otherwise, |
1318 // fail out now so blocking compiles dont hang the java thread | |
1319 if (!should_compile_new_jobs() || (UseCodeCacheFlushing && CodeCache::needs_flushing())) { | |
1783 | 1320 CompilationPolicy::policy()->delay_compilation(method()); |
1202 | 1321 return NULL; |
1322 } | |
1323 | |
0 | 1324 // do the compilation |
1325 if (method->is_native()) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6197
diff
changeset
|
1326 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { |
2405
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1327 // Acquire our lock. |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1328 int compile_id; |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1329 { |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1330 MutexLocker locker(MethodCompileQueue_lock, THREAD); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1331 compile_id = assign_compile_id(method, standard_entry_bci); |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1332 } |
3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
2403
diff
changeset
|
1333 (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); |
0 | 1334 } else { |
1335 return NULL; | |
1336 } | |
1337 } else { | |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
4122
diff
changeset
|
1338 compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, THREAD); |
0 | 1339 } |
1340 | |
1341 // return requested nmethod | |
1783 | 1342 // We accept a higher level osr method |
1343 return osr_bci == InvocationEntryBci ? method->code() : method->lookup_osr_nmethod_for(osr_bci, comp_level, false); | |
0 | 1344 } |
1345 | |
1346 | |
1347 // ------------------------------------------------------------------ | |
1348 // CompileBroker::compilation_is_complete | |
1349 // | |
1350 // See if compilation of this method is already complete. | |
1351 bool CompileBroker::compilation_is_complete(methodHandle method, | |
1352 int osr_bci, | |
1353 int comp_level) { | |
1354 bool is_osr = (osr_bci != standard_entry_bci); | |
1355 if (is_osr) { | |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1356 if (method->is_not_osr_compilable(comp_level)) { |
0 | 1357 return true; |
1358 } else { | |
1783 | 1359 nmethod* result = method->lookup_osr_nmethod_for(osr_bci, comp_level, true); |
0 | 1360 return (result != NULL); |
1361 } | |
1362 } else { | |
1363 if (method->is_not_compilable(comp_level)) { | |
1364 return true; | |
1365 } else { | |
1366 nmethod* result = method->code(); | |
1367 if (result == NULL) return false; | |
1783 | 1368 return comp_level == result->comp_level(); |
0 | 1369 } |
1370 } | |
1371 } | |
1372 | |
1373 | |
1374 // ------------------------------------------------------------------ | |
1375 // CompileBroker::compilation_is_in_queue | |
1376 // | |
1377 // See if this compilation is already requested. | |
1378 // | |
1379 // Implementation note: there is only a single "is in queue" bit | |
1380 // for each method. This means that the check below is overly | |
1381 // conservative in the sense that an osr compilation in the queue | |
1382 // will block a normal compilation from entering the queue (and vice | |
1383 // versa). This can be remedied by a full queue search to disambiguate | |
1384 // cases. If it is deemed profitible, this may be done. | |
1385 bool CompileBroker::compilation_is_in_queue(methodHandle method, | |
1783 | 1386 int osr_bci) { |
0 | 1387 return method->queued_for_compilation(); |
1388 } | |
1389 | |
1390 // ------------------------------------------------------------------ | |
1391 // CompileBroker::compilation_is_prohibited | |
1392 // | |
1393 // See if this compilation is not allowed. | |
1394 bool CompileBroker::compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level) { | |
1395 bool is_native = method->is_native(); | |
1396 // Some compilers may not support the compilation of natives. | |
1397 if (is_native && | |
1398 (!CICompileNatives || !compiler(comp_level)->supports_native())) { | |
1783 | 1399 method->set_not_compilable_quietly(comp_level); |
0 | 1400 return true; |
1401 } | |
1402 | |
1403 bool is_osr = (osr_bci != standard_entry_bci); | |
1404 // Some compilers may not support on stack replacement. | |
1405 if (is_osr && | |
1406 (!CICompileOSR || !compiler(comp_level)->supports_osr())) { | |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1407 method->set_not_osr_compilable(comp_level); |
0 | 1408 return true; |
1409 } | |
1410 | |
1411 // The method may be explicitly excluded by the user. | |
1412 bool quietly; | |
1413 if (CompilerOracle::should_exclude(method, quietly)) { | |
1414 if (!quietly) { | |
1415 // This does not happen quietly... | |
1416 ResourceMark rm; | |
1417 tty->print("### Excluding %s:%s", | |
1418 method->is_native() ? "generation of native wrapper" : "compile", | |
1419 (method->is_static() ? " static" : "")); | |
1420 method->print_short_name(tty); | |
1421 tty->cr(); | |
1422 } | |
1208
cef333a48af6
6923043: failed nightly tests which use -XX:+PrintCompilation -Xcomp -XX:CompileOnly
kvn
parents:
1202
diff
changeset
|
1423 method->set_not_compilable_quietly(); |
0 | 1424 } |
1425 | |
1426 return false; | |
1427 } | |
1428 | |
1429 | |
1430 // ------------------------------------------------------------------ | |
1431 // CompileBroker::assign_compile_id | |
1432 // | |
1433 // Assign a serialized id number to this compilation request. If the | |
1434 // number falls out of the allowed range, return a 0. OSR | |
1435 // compilations may be numbered separately from regular compilations | |
1436 // if certain debugging flags are used. | |
1437 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { | |
1783 | 1438 assert(MethodCompileQueue_lock->owner() == Thread::current(), |
0 | 1439 "must hold the compilation queue lock"); |
1440 bool is_osr = (osr_bci != standard_entry_bci); | |
1441 uint id; | |
1442 if (CICountOSR && is_osr) { | |
1443 id = ++_osr_compilation_id; | |
1444 if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { | |
1445 return id; | |
1446 } | |
1447 } else { | |
1448 id = ++_compilation_id; | |
1449 if ((uint)CIStart <= id && id < (uint)CIStop) { | |
1450 return id; | |
1451 } | |
1452 } | |
1453 | |
1454 // Method was not in the appropriate compilation range. | |
1208
cef333a48af6
6923043: failed nightly tests which use -XX:+PrintCompilation -Xcomp -XX:CompileOnly
kvn
parents:
1202
diff
changeset
|
1455 method->set_not_compilable_quietly(); |
0 | 1456 return 0; |
1457 } | |
1458 | |
1459 | |
1460 // ------------------------------------------------------------------ | |
1461 // CompileBroker::is_compile_blocking | |
1462 // | |
1463 // Should the current thread be blocked until this compilation request | |
1464 // has been fulfilled? | |
1465 bool CompileBroker::is_compile_blocking(methodHandle method, int osr_bci) { | |
6735
aed758eda82a
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
6725
diff
changeset
|
1466 assert(!InstanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock"); |
3294
86ebb26bcdeb
7037756: Deadlock in compiler thread similiar to 6789220
johnc
parents:
2482
diff
changeset
|
1467 return !BackgroundCompilation; |
0 | 1468 } |
1469 | |
1470 | |
1471 // ------------------------------------------------------------------ | |
1472 // CompileBroker::preload_classes | |
1473 void CompileBroker::preload_classes(methodHandle method, TRAPS) { | |
1474 // Move this code over from c1_Compiler.cpp | |
1475 ShouldNotReachHere(); | |
1476 } | |
1477 | |
1478 | |
1479 // ------------------------------------------------------------------ | |
1480 // CompileBroker::create_compile_task | |
1481 // | |
1482 // Create a CompileTask object representing the current request for | |
1483 // compilation. Add this task to the queue. | |
1484 CompileTask* CompileBroker::create_compile_task(CompileQueue* queue, | |
1485 int compile_id, | |
1486 methodHandle method, | |
1487 int osr_bci, | |
1488 int comp_level, | |
1489 methodHandle hot_method, | |
1490 int hot_count, | |
1491 const char* comment, | |
1492 bool blocking) { | |
1493 CompileTask* new_task = allocate_task(); | |
1494 new_task->initialize(compile_id, method, osr_bci, comp_level, | |
1495 hot_method, hot_count, comment, | |
1496 blocking); | |
1497 queue->add(new_task); | |
1498 return new_task; | |
1499 } | |
1500 | |
1501 | |
1502 // ------------------------------------------------------------------ | |
1503 // CompileBroker::allocate_task | |
1504 // | |
1505 // Allocate a CompileTask, from the free list if possible. | |
1506 CompileTask* CompileBroker::allocate_task() { | |
1507 MutexLocker locker(CompileTaskAlloc_lock); | |
1508 CompileTask* task = NULL; | |
1509 if (_task_free_list != NULL) { | |
1510 task = _task_free_list; | |
1511 _task_free_list = task->next(); | |
1512 task->set_next(NULL); | |
1513 } else { | |
1514 task = new CompileTask(); | |
1515 task->set_next(NULL); | |
1516 } | |
1517 return task; | |
1518 } | |
1519 | |
1520 | |
1521 // ------------------------------------------------------------------ | |
1522 // CompileBroker::free_task | |
1523 // | |
1524 // Add a task to the free list. | |
1525 void CompileBroker::free_task(CompileTask* task) { | |
1526 MutexLocker locker(CompileTaskAlloc_lock); | |
1527 task->free(); | |
1528 task->set_next(_task_free_list); | |
1529 _task_free_list = task; | |
1530 } | |
1531 | |
1532 | |
1533 // ------------------------------------------------------------------ | |
1534 // CompileBroker::wait_for_completion | |
1535 // | |
1536 // Wait for the given method CompileTask to complete. | |
1537 void CompileBroker::wait_for_completion(CompileTask* task) { | |
1538 if (CIPrintCompileQueue) { | |
1539 tty->print_cr("BLOCKING FOR COMPILE"); | |
1540 } | |
1541 | |
1542 assert(task->is_blocking(), "can only wait on blocking task"); | |
1543 | |
1544 JavaThread *thread = JavaThread::current(); | |
1545 thread->set_blocked_on_compilation(true); | |
1546 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1547 methodHandle method(thread, task->method()); |
0 | 1548 { |
1549 MutexLocker waiter(task->lock(), thread); | |
1550 | |
1551 while (!task->is_complete()) | |
1552 task->lock()->wait(); | |
1553 } | |
1554 // It is harmless to check this status without the lock, because | |
1555 // completion is a stable property (until the task object is recycled). | |
1556 assert(task->is_complete(), "Compilation should have completed"); | |
1557 assert(task->code_handle() == NULL, "must be reset"); | |
1558 | |
1559 thread->set_blocked_on_compilation(false); | |
1560 | |
1561 // By convention, the waiter is responsible for recycling a | |
1562 // blocking CompileTask. Since there is only one waiter ever | |
1563 // waiting on a CompileTask, we know that no one else will | |
1564 // be using this CompileTask; we can free it. | |
1565 free_task(task); | |
1566 } | |
1567 | |
1568 // ------------------------------------------------------------------ | |
1569 // CompileBroker::compiler_thread_loop | |
1570 // | |
1571 // The main loop run by a CompilerThread. | |
1572 void CompileBroker::compiler_thread_loop() { | |
1573 CompilerThread* thread = CompilerThread::current(); | |
1574 CompileQueue* queue = thread->queue(); | |
1575 | |
1576 // For the thread that initializes the ciObjectFactory | |
1577 // this resource mark holds all the shared objects | |
1578 ResourceMark rm; | |
1579 | |
1580 // First thread to get here will initialize the compiler interface | |
1581 | |
1582 if (!ciObjectFactory::is_initialized()) { | |
1583 ASSERT_IN_VM; | |
1584 MutexLocker only_one (CompileThread_lock, thread); | |
1585 if (!ciObjectFactory::is_initialized()) { | |
1586 ciObjectFactory::initialize(); | |
1587 } | |
1588 } | |
1589 | |
1590 // Open a log. | |
1591 if (LogCompilation) { | |
1592 init_compiler_thread_log(); | |
1593 } | |
1594 CompileLog* log = thread->log(); | |
1595 if (log != NULL) { | |
6843 | 1596 log->begin_elem("start_compile_thread name='%s' thread='" UINTX_FORMAT "' process='%d'", |
1597 thread->name(), | |
0 | 1598 os::current_thread_id(), |
1599 os::current_process_id()); | |
1600 log->stamp(); | |
1601 log->end_elem(); | |
1602 } | |
1603 | |
1604 while (true) { | |
1605 { | |
1606 // We need this HandleMark to avoid leaking VM handles. | |
1607 HandleMark hm(thread); | |
1202 | 1608 |
2353
1c0cf339481b
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
2260
diff
changeset
|
1609 if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) { |
1202 | 1610 // the code cache is really full |
1611 handle_full_code_cache(); | |
1612 } else if (UseCodeCacheFlushing && CodeCache::needs_flushing()) { | |
1613 // Attempt to start cleaning the code cache while there is still a little headroom | |
1614 NMethodSweeper::handle_full_code_cache(false); | |
0 | 1615 } |
1616 | |
1617 CompileTask* task = queue->get(); | |
1618 | |
1619 // Give compiler threads an extra quanta. They tend to be bursty and | |
1620 // this helps the compiler to finish up the job. | |
1621 if( CompilerThreadHintNoPreempt ) | |
1622 os::hint_no_preempt(); | |
1623 | |
1624 // trace per thread time and compile statistics | |
1625 CompilerCounters* counters = ((CompilerThread*)thread)->counters(); | |
1626 PerfTraceTimedEvent(counters->time_counter(), counters->compile_counter()); | |
1627 | |
1628 // Assign the task to the current thread. Mark this compilation | |
1629 // thread as active for the profiler. | |
1630 CompileTaskWrapper ctw(task); | |
1631 nmethodLocker result_handle; // (handle for the nmethod produced by this task) | |
1632 task->set_code_handle(&result_handle); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1633 methodHandle method(thread, task->method()); |
0 | 1634 |
1635 // Never compile a method if breakpoints are present in it | |
1636 if (method()->number_of_breakpoints() == 0) { | |
1637 // Compile the method. | |
1202 | 1638 if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) { |
0 | 1639 #ifdef COMPILER1 |
1640 // Allow repeating compilations for the purpose of benchmarking | |
1641 // compile speed. This is not useful for customers. | |
1642 if (CompilationRepeat != 0) { | |
1643 int compile_count = CompilationRepeat; | |
1644 while (compile_count > 0) { | |
1645 invoke_compiler_on_method(task); | |
1646 nmethod* nm = method->code(); | |
1647 if (nm != NULL) { | |
1648 nm->make_zombie(); | |
1649 method->clear_code(); | |
1650 } | |
1651 compile_count--; | |
1652 } | |
1653 } | |
1654 #endif /* COMPILER1 */ | |
1655 invoke_compiler_on_method(task); | |
1656 } else { | |
1657 // After compilation is disabled, remove remaining methods from queue | |
1658 method->clear_queued_for_compilation(); | |
1659 } | |
1660 } | |
1661 } | |
1662 } | |
1663 } | |
1664 | |
1665 | |
1666 // ------------------------------------------------------------------ | |
1667 // CompileBroker::init_compiler_thread_log | |
1668 // | |
1669 // Set up state required by +LogCompilation. | |
1670 void CompileBroker::init_compiler_thread_log() { | |
1671 CompilerThread* thread = CompilerThread::current(); | |
1672 char fileBuf[4*K]; | |
1673 FILE* fp = NULL; | |
1674 char* file = NULL; | |
1675 intx thread_id = os::current_thread_id(); | |
1676 for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) { | |
1677 const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL); | |
1353
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1678 if (dir == NULL) { |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1679 jio_snprintf(fileBuf, sizeof(fileBuf), "hs_c" UINTX_FORMAT "_pid%u.log", |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1680 thread_id, os::current_process_id()); |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1681 } else { |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1682 jio_snprintf(fileBuf, sizeof(fileBuf), |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1683 "%s%shs_c" UINTX_FORMAT "_pid%u.log", dir, |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1684 os::file_separator(), thread_id, os::current_process_id()); |
a2ea687fdc7c
6938627: Make temporary directory use property java.io.tmpdir when specified
coleenp
parents:
1300
diff
changeset
|
1685 } |
0 | 1686 fp = fopen(fileBuf, "at"); |
1687 if (fp != NULL) { | |
6197 | 1688 file = NEW_C_HEAP_ARRAY(char, strlen(fileBuf)+1, mtCompiler); |
0 | 1689 strcpy(file, fileBuf); |
1690 break; | |
1691 } | |
1692 } | |
1693 if (fp == NULL) { | |
1694 warning("Cannot open log file: %s", fileBuf); | |
1695 } else { | |
1696 if (LogCompilation && Verbose) | |
1697 tty->print_cr("Opening compilation log %s", file); | |
6197 | 1698 CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file, fp, thread_id); |
0 | 1699 thread->init_log(log); |
1700 | |
1701 if (xtty != NULL) { | |
1702 ttyLocker ttyl; | |
1703 | |
1704 // Record any per thread log files | |
1705 xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file); | |
1706 } | |
1707 } | |
1708 } | |
1709 | |
1710 // ------------------------------------------------------------------ | |
1711 // CompileBroker::set_should_block | |
1712 // | |
1713 // Set _should_block. | |
1714 // Call this from the VM, with Threads_lock held and a safepoint requested. | |
1715 void CompileBroker::set_should_block() { | |
1716 assert(Threads_lock->owner() == Thread::current(), "must have threads lock"); | |
1717 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint already"); | |
1718 #ifndef PRODUCT | |
1719 if (PrintCompilation && (Verbose || WizardMode)) | |
1720 tty->print_cr("notifying compiler thread pool to block"); | |
1721 #endif | |
1722 _should_block = true; | |
1723 } | |
1724 | |
1725 // ------------------------------------------------------------------ | |
1726 // CompileBroker::maybe_block | |
1727 // | |
1728 // Call this from the compiler at convenient points, to poll for _should_block. | |
1729 void CompileBroker::maybe_block() { | |
1730 if (_should_block) { | |
1731 #ifndef PRODUCT | |
1732 if (PrintCompilation && (Verbose || WizardMode)) | |
1733 tty->print_cr("compiler thread " INTPTR_FORMAT " poll detects block request", Thread::current()); | |
1734 #endif | |
1735 ThreadInVMfromNative tivfn(JavaThread::current()); | |
1736 } | |
1737 } | |
1738 | |
1739 // ------------------------------------------------------------------ | |
1740 // CompileBroker::invoke_compiler_on_method | |
1741 // | |
1742 // Compile a method. | |
1743 // | |
1744 void CompileBroker::invoke_compiler_on_method(CompileTask* task) { | |
1745 if (PrintCompilation) { | |
1746 ResourceMark rm; | |
1747 task->print_line(); | |
1748 } | |
1749 elapsedTimer time; | |
1750 | |
1751 CompilerThread* thread = CompilerThread::current(); | |
1752 ResourceMark rm(thread); | |
1753 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1754 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1755 _compilation_log->log_compile(thread, task); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1756 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1757 |
0 | 1758 // Common flags. |
1759 uint compile_id = task->compile_id(); | |
1760 int osr_bci = task->osr_bci(); | |
1761 bool is_osr = (osr_bci != standard_entry_bci); | |
1762 bool should_log = (thread->log() != NULL); | |
1763 bool should_break = false; | |
1764 { | |
1765 // create the handle inside it's own block so it can't | |
1766 // accidentally be referenced once the thread transitions to | |
1767 // native. The NoHandleMark before the transition should catch | |
1768 // any cases where this occurs in the future. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1769 methodHandle method(thread, task->method()); |
0 | 1770 should_break = check_break_at(method, compile_id, is_osr); |
1771 if (should_log && !CompilerOracle::should_log(method)) { | |
1772 should_log = false; | |
1773 } | |
1774 assert(!method->is_native(), "no longer compile natives"); | |
1775 | |
1776 // Save information about this method in case of failure. | |
1777 set_last_compile(thread, method, is_osr, task->comp_level()); | |
1778 | |
1779 DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler(task->comp_level()), method); | |
1780 } | |
1781 | |
1782 // Allocate a new set of JNI handles. | |
1783 push_jni_handle_block(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1784 Method* target_handle = task->method(); |
0 | 1785 int compilable = ciEnv::MethodCompilable; |
1786 { | |
1787 int system_dictionary_modification_counter; | |
1788 { | |
1789 MutexLocker locker(Compile_lock, thread); | |
1790 system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); | |
1791 } | |
1792 | |
1793 NoHandleMark nhm; | |
1794 ThreadToNativeFromVM ttn(thread); | |
1795 | |
1796 ciEnv ci_env(task, system_dictionary_modification_counter); | |
1797 if (should_break) { | |
1798 ci_env.set_break_at_compile(true); | |
1799 } | |
1800 if (should_log) { | |
1801 ci_env.set_log(thread->log()); | |
1802 } | |
1803 assert(thread->env() == &ci_env, "set by ci_env"); | |
1804 // The thread-env() field is cleared in ~CompileTaskWrapper. | |
1805 | |
780
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1806 // Cache Jvmti state |
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1807 ci_env.cache_jvmti_state(); |
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1808 |
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1809 // Cache DTrace flags |
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1810 ci_env.cache_dtrace_flags(); |
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
1811 |
0 | 1812 ciMethod* target = ci_env.get_method_from_handle(target_handle); |
1813 | |
1814 TraceTime t1("compilation", &time); | |
1815 | |
1816 compiler(task->comp_level())->compile_method(&ci_env, target, osr_bci); | |
1817 | |
1818 if (!ci_env.failing() && task->code() == NULL) { | |
1819 //assert(false, "compiler should always document failure"); | |
1820 // The compiler elected, without comment, not to register a result. | |
1821 // Do not attempt further compilations of this method. | |
1964
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
1822 ci_env.record_method_not_compilable("compile failed", !TieredCompilation); |
0 | 1823 } |
1824 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1825 // Copy this bit to the enclosing block: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1826 compilable = ci_env.compilable(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1827 |
0 | 1828 if (ci_env.failing()) { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1829 const char* retry_message = ci_env.retry_message(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1830 if (_compilation_log != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1831 _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1832 } |
0 | 1833 if (PrintCompilation) { |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1834 FormatBufferResource msg = retry_message != NULL ? |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1835 err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) : |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1836 err_msg_res("COMPILE SKIPPED: %s", ci_env.failure_reason()); |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1837 task->print_compilation(tty, msg); |
0 | 1838 } |
1839 } else { | |
1840 task->mark_success(); | |
1841 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes()); | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1842 if (_compilation_log != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1843 nmethod* code = task->code(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1844 if (code != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1845 _compilation_log->log_nmethod(thread, code); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1846 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4825
diff
changeset
|
1847 } |
0 | 1848 } |
1849 } | |
1850 pop_jni_handle_block(); | |
1851 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1852 methodHandle method(thread, task->method()); |
0 | 1853 |
1854 DTRACE_METHOD_COMPILE_END_PROBE(compiler(task->comp_level()), method, task->is_success()); | |
1855 | |
1856 collect_statistics(thread, time, task); | |
1857 | |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
4047
diff
changeset
|
1858 if (PrintCompilation && PrintCompilation2) { |
4047 | 1859 tty->print("%7d ", (int) tty->time_stamp().milliseconds()); // print timestamp |
1860 tty->print("%4d ", compile_id); // print compilation number | |
1861 tty->print("%s ", (is_osr ? "%" : " ")); | |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
4047
diff
changeset
|
1862 int code_size = (task->code() == NULL) ? 0 : task->code()->total_size(); |
4122
cc81b9c09bbb
7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents:
4064
diff
changeset
|
1863 tty->print_cr("size: %d time: %d inlined: %d bytes", code_size, (int)time.milliseconds(), task->num_inlined_bytecodes()); |
4047 | 1864 } |
1865 | |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1866 // Disable compilation, if required. |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1867 switch (compilable) { |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1868 case ciEnv::MethodCompilable_never: |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1869 if (is_osr) |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1870 method->set_not_osr_compilable_quietly(); |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1871 else |
1208
cef333a48af6
6923043: failed nightly tests which use -XX:+PrintCompilation -Xcomp -XX:CompileOnly
kvn
parents:
1202
diff
changeset
|
1872 method->set_not_compilable_quietly(); |
6800
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1873 break; |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1874 case ciEnv::MethodCompilable_not_at_tier: |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1875 if (is_osr) |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1876 method->set_not_osr_compilable_quietly(task->comp_level()); |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1877 else |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1878 method->set_not_compilable_quietly(task->comp_level()); |
9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
6735
diff
changeset
|
1879 break; |
0 | 1880 } |
1881 | |
1882 // Note that the queued_for_compilation bits are cleared without | |
1883 // protection of a mutex. [They were set by the requester thread, | |
1884 // when adding the task to the complie queue -- at which time the | |
1885 // compile queue lock was held. Subsequently, we acquired the compile | |
1886 // queue lock to get this task off the compile queue; thus (to belabour | |
1887 // the point somewhat) our clearing of the bits must be occurring | |
1888 // only after the setting of the bits. See also 14012000 above. | |
1889 method->clear_queued_for_compilation(); | |
1890 | |
1891 #ifdef ASSERT | |
1892 if (CollectedHeap::fired_fake_oom()) { | |
1893 // The current compile received a fake OOM during compilation so | |
1894 // go ahead and exit the VM since the test apparently succeeded | |
1895 tty->print_cr("*** Shutting down VM after successful fake OOM"); | |
1896 vm_exit(0); | |
1897 } | |
1898 #endif | |
1899 } | |
1900 | |
1901 // ------------------------------------------------------------------ | |
1202 | 1902 // CompileBroker::handle_full_code_cache |
1903 // | |
1904 // The CodeCache is full. Print out warning and disable compilation or | |
1905 // try code cache cleaning so compilation can continue later. | |
1906 void CompileBroker::handle_full_code_cache() { | |
1907 UseInterpreter = true; | |
1908 if (UseCompiler || AlwaysCompileLoopMethods ) { | |
1728
a62d332029cf
6976372: # assert(_owner == Thread::current()) failed: invariant
never
parents:
1692
diff
changeset
|
1909 if (xtty != NULL) { |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1910 stringStream s; |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1911 // Dump code cache state into a buffer before locking the tty, |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1912 // because log_state() will use locks causing lock conflicts. |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1913 CodeCache::log_state(&s); |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1914 // Lock to prevent tearing |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1915 ttyLocker ttyl; |
1728
a62d332029cf
6976372: # assert(_owner == Thread::current()) failed: invariant
never
parents:
1692
diff
changeset
|
1916 xtty->begin_elem("code_cache_full"); |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2447
diff
changeset
|
1917 xtty->print(s.as_string()); |
1728
a62d332029cf
6976372: # assert(_owner == Thread::current()) failed: invariant
never
parents:
1692
diff
changeset
|
1918 xtty->stamp(); |
a62d332029cf
6976372: # assert(_owner == Thread::current()) failed: invariant
never
parents:
1692
diff
changeset
|
1919 xtty->end_elem(); |
1202 | 1920 } |
1578
ca3dceda776c
6930994: Code cache is full warning should be visible in product
never
parents:
1538
diff
changeset
|
1921 warning("CodeCache is full. Compiler has been disabled."); |
ca3dceda776c
6930994: Code cache is full warning should be visible in product
never
parents:
1538
diff
changeset
|
1922 warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); |
2353
1c0cf339481b
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
2260
diff
changeset
|
1923 CodeCache::print_bounds(tty); |
1578
ca3dceda776c
6930994: Code cache is full warning should be visible in product
never
parents:
1538
diff
changeset
|
1924 #ifndef PRODUCT |
1202 | 1925 if (CompileTheWorld || ExitOnFullCodeCache) { |
1926 before_exit(JavaThread::current()); | |
1927 exit_globals(); // will delete tty | |
1928 vm_direct_exit(CompileTheWorld ? 0 : 1); | |
1929 } | |
1578
ca3dceda776c
6930994: Code cache is full warning should be visible in product
never
parents:
1538
diff
changeset
|
1930 #endif |
1202 | 1931 if (UseCodeCacheFlushing) { |
1932 NMethodSweeper::handle_full_code_cache(true); | |
1933 } else { | |
1934 UseCompiler = false; | |
1935 AlwaysCompileLoopMethods = false; | |
1936 } | |
1937 } | |
1938 } | |
1939 | |
1940 // ------------------------------------------------------------------ | |
0 | 1941 // CompileBroker::set_last_compile |
1942 // | |
1943 // Record this compilation for debugging purposes. | |
1944 void CompileBroker::set_last_compile(CompilerThread* thread, methodHandle method, bool is_osr, int comp_level) { | |
1945 ResourceMark rm; | |
1946 char* method_name = method->name()->as_C_string(); | |
1947 strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length); | |
1948 char current_method[CompilerCounters::cmname_buffer_length]; | |
1949 size_t maxLen = CompilerCounters::cmname_buffer_length; | |
1950 | |
1951 if (UsePerfData) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1952 const char* class_name = method->method_holder()->name()->as_C_string(); |
0 | 1953 |
1954 size_t s1len = strlen(class_name); | |
1955 size_t s2len = strlen(method_name); | |
1956 | |
1957 // check if we need to truncate the string | |
1958 if (s1len + s2len + 2 > maxLen) { | |
1959 | |
1960 // the strategy is to lop off the leading characters of the | |
1961 // class name and the trailing characters of the method name. | |
1962 | |
1963 if (s2len + 2 > maxLen) { | |
1964 // lop of the entire class name string, let snprintf handle | |
1965 // truncation of the method name. | |
1966 class_name += s1len; // null string | |
1967 } | |
1968 else { | |
1969 // lop off the extra characters from the front of the class name | |
1970 class_name += ((s1len + s2len + 2) - maxLen); | |
1971 } | |
1972 } | |
1973 | |
1974 jio_snprintf(current_method, maxLen, "%s %s", class_name, method_name); | |
1975 } | |
1976 | |
1977 if (CICountOSR && is_osr) { | |
1978 _last_compile_type = osr_compile; | |
1979 } else { | |
1980 _last_compile_type = normal_compile; | |
1981 } | |
1982 _last_compile_level = comp_level; | |
1983 | |
1984 if (UsePerfData) { | |
1985 CompilerCounters* counters = thread->counters(); | |
1986 counters->set_current_method(current_method); | |
1987 counters->set_compile_type((jlong)_last_compile_type); | |
1988 } | |
1989 } | |
1990 | |
1991 | |
1992 // ------------------------------------------------------------------ | |
1993 // CompileBroker::push_jni_handle_block | |
1994 // | |
1995 // Push on a new block of JNI handles. | |
1996 void CompileBroker::push_jni_handle_block() { | |
1997 JavaThread* thread = JavaThread::current(); | |
1998 | |
1999 // Allocate a new block for JNI handles. | |
2000 // Inlined code from jni_PushLocalFrame() | |
2001 JNIHandleBlock* java_handles = thread->active_handles(); | |
2002 JNIHandleBlock* compile_handles = JNIHandleBlock::allocate_block(thread); | |
2003 assert(compile_handles != NULL && java_handles != NULL, "should not be NULL"); | |
2004 compile_handles->set_pop_frame_link(java_handles); // make sure java handles get gc'd. | |
2005 thread->set_active_handles(compile_handles); | |
2006 } | |
2007 | |
2008 | |
2009 // ------------------------------------------------------------------ | |
2010 // CompileBroker::pop_jni_handle_block | |
2011 // | |
2012 // Pop off the current block of JNI handles. | |
2013 void CompileBroker::pop_jni_handle_block() { | |
2014 JavaThread* thread = JavaThread::current(); | |
2015 | |
2016 // Release our JNI handle block | |
2017 JNIHandleBlock* compile_handles = thread->active_handles(); | |
2018 JNIHandleBlock* java_handles = compile_handles->pop_frame_link(); | |
2019 thread->set_active_handles(java_handles); | |
2020 compile_handles->set_pop_frame_link(NULL); | |
2021 JNIHandleBlock::release_block(compile_handles, thread); // may block | |
2022 } | |
2023 | |
2024 | |
2025 // ------------------------------------------------------------------ | |
2026 // CompileBroker::check_break_at | |
2027 // | |
2028 // Should the compilation break at the current compilation. | |
2029 bool CompileBroker::check_break_at(methodHandle method, int compile_id, bool is_osr) { | |
2030 if (CICountOSR && is_osr && (compile_id == CIBreakAtOSR)) { | |
2031 return true; | |
2032 } else if( CompilerOracle::should_break_at(method) ) { // break when compiling | |
2033 return true; | |
2034 } else { | |
2035 return (compile_id == CIBreakAt); | |
2036 } | |
2037 } | |
2038 | |
2039 // ------------------------------------------------------------------ | |
2040 // CompileBroker::collect_statistics | |
2041 // | |
2042 // Collect statistics about the compilation. | |
2043 | |
2044 void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task) { | |
2045 bool success = task->is_success(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2046 methodHandle method (thread, task->method()); |
0 | 2047 uint compile_id = task->compile_id(); |
2048 bool is_osr = (task->osr_bci() != standard_entry_bci); | |
2049 nmethod* code = task->code(); | |
2050 CompilerCounters* counters = thread->counters(); | |
2051 | |
2052 assert(code == NULL || code->is_locked_by_vm(), "will survive the MutexLocker"); | |
2053 MutexLocker locker(CompileStatistics_lock); | |
2054 | |
2055 // _perf variables are production performance counters which are | |
2056 // updated regardless of the setting of the CITime and CITimeEach flags | |
2057 // | |
2058 if (!success) { | |
2059 _total_bailout_count++; | |
2060 if (UsePerfData) { | |
2061 _perf_last_failed_method->set_value(counters->current_method()); | |
2062 _perf_last_failed_type->set_value(counters->compile_type()); | |
2063 _perf_total_bailout_count->inc(); | |
2064 } | |
2065 } else if (code == NULL) { | |
2066 if (UsePerfData) { | |
2067 _perf_last_invalidated_method->set_value(counters->current_method()); | |
2068 _perf_last_invalidated_type->set_value(counters->compile_type()); | |
2069 _perf_total_invalidated_count->inc(); | |
2070 } | |
2071 _total_invalidated_count++; | |
2072 } else { | |
2073 // Compilation succeeded | |
2074 | |
2075 // update compilation ticks - used by the implementation of | |
2076 // java.lang.management.CompilationMBean | |
2077 _perf_total_compilation->inc(time.ticks()); | |
2078 | |
2079 if (CITime) { | |
2080 _t_total_compilation.add(time); | |
2081 if (is_osr) { | |
2082 _t_osr_compilation.add(time); | |
2083 _sum_osr_bytes_compiled += method->code_size() + task->num_inlined_bytecodes(); | |
2084 } else { | |
2085 _t_standard_compilation.add(time); | |
2086 _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes(); | |
2087 } | |
2088 } | |
2089 | |
2090 if (UsePerfData) { | |
2091 // save the name of the last method compiled | |
2092 _perf_last_method->set_value(counters->current_method()); | |
2093 _perf_last_compile_type->set_value(counters->compile_type()); | |
2094 _perf_last_compile_size->set_value(method->code_size() + | |
2095 task->num_inlined_bytecodes()); | |
2096 if (is_osr) { | |
2097 _perf_osr_compilation->inc(time.ticks()); | |
2098 _perf_sum_osr_bytes_compiled->inc(method->code_size() + task->num_inlined_bytecodes()); | |
2099 } else { | |
2100 _perf_standard_compilation->inc(time.ticks()); | |
2101 _perf_sum_standard_bytes_compiled->inc(method->code_size() + task->num_inlined_bytecodes()); | |
2102 } | |
2103 } | |
2104 | |
2105 if (CITimeEach) { | |
2106 float bytes_per_sec = 1.0 * (method->code_size() + task->num_inlined_bytecodes()) / time.seconds(); | |
2107 tty->print_cr("%3d seconds: %f bytes/sec : %f (bytes %d + %d inlined)", | |
2108 compile_id, time.seconds(), bytes_per_sec, method->code_size(), task->num_inlined_bytecodes()); | |
2109 } | |
2110 | |
2111 // Collect counts of successful compilations | |
1748 | 2112 _sum_nmethod_size += code->total_size(); |
2113 _sum_nmethod_code_size += code->insts_size(); | |
0 | 2114 _total_compile_count++; |
2115 | |
2116 if (UsePerfData) { | |
1748 | 2117 _perf_sum_nmethod_size->inc( code->total_size()); |
2118 _perf_sum_nmethod_code_size->inc(code->insts_size()); | |
0 | 2119 _perf_total_compile_count->inc(); |
2120 } | |
2121 | |
2122 if (is_osr) { | |
2123 if (UsePerfData) _perf_total_osr_compile_count->inc(); | |
2124 _total_osr_compile_count++; | |
2125 } else { | |
2126 if (UsePerfData) _perf_total_standard_compile_count->inc(); | |
2127 _total_standard_compile_count++; | |
2128 } | |
2129 } | |
2130 // set the current method for the thread to null | |
2131 if (UsePerfData) counters->set_current_method(""); | |
2132 } | |
2133 | |
2134 | |
2135 | |
2136 void CompileBroker::print_times() { | |
2137 tty->cr(); | |
2138 tty->print_cr("Accumulated compiler times (for compiled methods only)"); | |
2139 tty->print_cr("------------------------------------------------"); | |
2140 //0000000000111111111122222222223333333333444444444455555555556666666666 | |
2141 //0123456789012345678901234567890123456789012345678901234567890123456789 | |
2142 tty->print_cr(" Total compilation time : %6.3f s", CompileBroker::_t_total_compilation.seconds()); | |
2143 tty->print_cr(" Standard compilation : %6.3f s, Average : %2.3f", | |
2144 CompileBroker::_t_standard_compilation.seconds(), | |
2145 CompileBroker::_t_standard_compilation.seconds() / CompileBroker::_total_standard_compile_count); | |
2146 tty->print_cr(" On stack replacement : %6.3f s, Average : %2.3f", CompileBroker::_t_osr_compilation.seconds(), CompileBroker::_t_osr_compilation.seconds() / CompileBroker::_total_osr_compile_count); | |
1131 | 2147 |
1783 | 2148 if (compiler(CompLevel_simple) != NULL) { |
2149 compiler(CompLevel_simple)->print_timers(); | |
0 | 2150 } |
1783 | 2151 if (compiler(CompLevel_full_optimization) != NULL) { |
2152 compiler(CompLevel_full_optimization)->print_timers(); | |
2153 } | |
0 | 2154 tty->cr(); |
2155 int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled; | |
2156 tty->print_cr(" Total compiled bytecodes : %6d bytes", tcb); | |
2157 tty->print_cr(" Standard compilation : %6d bytes", CompileBroker::_sum_standard_bytes_compiled); | |
2158 tty->print_cr(" On stack replacement : %6d bytes", CompileBroker::_sum_osr_bytes_compiled); | |
2159 int bps = (int)(tcb / CompileBroker::_t_total_compilation.seconds()); | |
2160 tty->print_cr(" Average compilation speed: %6d bytes/s", bps); | |
2161 tty->cr(); | |
2162 tty->print_cr(" nmethod code size : %6d bytes", CompileBroker::_sum_nmethod_code_size); | |
2163 tty->print_cr(" nmethod total size : %6d bytes", CompileBroker::_sum_nmethod_size); | |
2164 } | |
2165 | |
2166 | |
2167 // Debugging output for failure | |
2168 void CompileBroker::print_last_compile() { | |
2169 if ( _last_compile_level != CompLevel_none && | |
2170 compiler(_last_compile_level) != NULL && | |
2171 _last_method_compiled != NULL && | |
2172 _last_compile_type != no_compile) { | |
2173 if (_last_compile_type == osr_compile) { | |
2174 tty->print_cr("Last parse: [osr]%d+++(%d) %s", | |
2175 _osr_compilation_id, _last_compile_level, _last_method_compiled); | |
2176 } else { | |
2177 tty->print_cr("Last parse: %d+++(%d) %s", | |
2178 _compilation_id, _last_compile_level, _last_method_compiled); | |
2179 } | |
2180 } | |
2181 } | |
2182 | |
2183 | |
2184 void CompileBroker::print_compiler_threads_on(outputStream* st) { | |
2185 #ifndef PRODUCT | |
2186 st->print_cr("Compiler thread printing unimplemented."); | |
2187 st->cr(); | |
2188 #endif | |
2189 } |