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