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