17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "compiler/compilationPolicy.hpp"
26 #include "compiler/compileTask.hpp"
27 #include "compiler/compileLog.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "compiler/compilerDirectives.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/klass.inline.hpp"
34 #include "runtime/handles.inline.hpp"
35 #include "runtime/jniHandles.hpp"
36 #include "runtime/mutexLocker.hpp"
37
38 CompileTask* CompileTask::_task_free_list = nullptr;
39
40 /**
41 * Allocate a CompileTask, from the free list if possible.
42 */
43 CompileTask* CompileTask::allocate() {
44 MutexLocker locker(CompileTaskAlloc_lock);
45 CompileTask* task = nullptr;
46
47 if (_task_free_list != nullptr) {
48 task = _task_free_list;
49 _task_free_list = task->next();
50 task->set_next(nullptr);
51 } else {
52 task = new CompileTask();
53 task->set_next(nullptr);
54 task->set_is_free(true);
55 }
56 assert(task->is_free(), "Task must be free.");
74 JNIHandles::destroy_global(task->_hot_method_holder);
75 }
76 if (task->_failure_reason_on_C_heap && task->_failure_reason != nullptr) {
77 os::free((void*) task->_failure_reason);
78 }
79 task->_failure_reason = nullptr;
80 task->_failure_reason_on_C_heap = false;
81
82 task->set_is_free(true);
83 task->set_next(_task_free_list);
84 _task_free_list = task;
85 }
86 }
87
88 void CompileTask::initialize(int compile_id,
89 const methodHandle& method,
90 int osr_bci,
91 int comp_level,
92 const methodHandle& hot_method,
93 int hot_count,
94 CompileTask::CompileReason compile_reason,
95 bool is_blocking) {
96 assert(!_lock->is_locked(), "bad locking");
97
98 Thread* thread = Thread::current();
99 _compile_id = compile_id;
100 _method = method();
101 _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
102 _osr_bci = osr_bci;
103 _is_blocking = is_blocking;
104 JVMCI_ONLY(_has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();)
105 JVMCI_ONLY(_blocking_jvmci_compile_state = nullptr;)
106 _comp_level = comp_level;
107 _num_inlined_bytecodes = 0;
108
109 _waiting_count = 0;
110
111 _is_complete = false;
112 _is_success = false;
113
114 _hot_method = nullptr;
115 _hot_method_holder = nullptr;
116 _hot_count = hot_count;
117 _time_queued = os::elapsed_counter();
118 _time_started = 0;
119 _compile_reason = compile_reason;
120 _nm_content_size = 0;
121 AbstractCompiler* comp = compiler();
122 _directive = DirectivesStack::getMatchingDirective(method, comp);
123 _nm_insts_size = 0;
124 _nm_total_size = 0;
125 _failure_reason = nullptr;
126 _failure_reason_on_C_heap = false;
127 _arena_bytes = 0;
128
129 if (LogCompilation) {
130 if (hot_method.not_null()) {
131 if (hot_method == method) {
132 _hot_method = _method;
133 } else {
134 _hot_method = hot_method();
135 // only add loader or mirror if different from _method_holder
136 _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
137 }
138 }
139 }
140
141 _next = nullptr;
142 }
143
144 /**
145 * Returns the compiler for this task.
146 */
147 AbstractCompiler* CompileTask::compiler() const {
148 return CompileBroker::compiler(_comp_level);
149 }
150
151 // Replace weak handles by strong handles to avoid unloading during compilation.
152 CompileTask* CompileTask::select_for_compilation() {
153 if (is_unloaded()) {
154 // Guard against concurrent class unloading
155 return nullptr;
156 }
157 Thread* thread = Thread::current();
158 assert(_method->method_holder()->is_loader_alive(), "should be alive");
159 Handle method_holder(thread, _method->method_holder()->klass_holder());
160 JNIHandles::destroy_weak_global(_method_holder);
161 JNIHandles::destroy_weak_global(_hot_method_holder);
162 _method_holder = JNIHandles::make_global(method_holder);
163 if (_hot_method != nullptr) {
164 _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
165 }
166 return this;
167 }
168
169 void CompileTask::mark_on_stack() {
170 if (is_unloaded()) {
171 return;
172 }
173 // Mark these methods as something redefine classes cannot remove.
174 _method->set_on_stack(true);
175 if (_hot_method != nullptr) {
176 _hot_method->set_on_stack(true);
177 }
178 }
179
180 bool CompileTask::is_unloaded() const {
181 return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
182 }
183
184 // RedefineClasses support
185 void CompileTask::metadata_do(MetadataClosure* f) {
186 if (is_unloaded()) {
187 return;
188 }
189 f->do_metadata(method());
190 if (hot_method() != nullptr && hot_method() != method()) {
191 f->do_metadata(hot_method());
192 }
193 }
194
195 // ------------------------------------------------------------------
196 // CompileTask::print_line_on_error
197 //
198 // This function is called by fatal error handler when the thread
199 // causing troubles is a compiler thread.
200 //
201 // Do not grab any lock, do not allocate memory.
202 //
203 // Otherwise it's the same as CompileTask::print_line()
204 //
205 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
206 // print compiler name
207 st->print("%s:", CompileBroker::compiler_name(comp_level()));
208 print(st);
209 }
210
211 // ------------------------------------------------------------------
212 // CompileTask::print_tty
213 void CompileTask::print_tty() {
214 ttyLocker ttyl; // keep the following output all in one block
215 print(tty);
216 }
217
218 // ------------------------------------------------------------------
219 // CompileTask::print_impl
220 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
221 bool is_osr_method, int osr_bci, bool is_blocking,
222 const char* msg, bool short_form, bool cr,
223 jlong time_queued, jlong time_started) {
224 if (!short_form) {
225 // Print current time
226 st->print(UINT64_FORMAT " ", (uint64_t) tty->time_stamp().milliseconds());
227 if (Verbose && time_queued != 0) {
228 // Print time in queue and time being processed by compiler thread
229 jlong now = os::elapsed_counter();
230 st->print("%.0f ", TimeHelper::counter_to_millis(now-time_queued));
231 if (time_started != 0) {
232 st->print("%.0f ", TimeHelper::counter_to_millis(now-time_started));
233 }
234 }
235 }
236 // print compiler name if requested
237 if (CIPrintCompilerName) {
238 st->print("%s:", CompileBroker::compiler_name(comp_level));
239 }
240 st->print("%4d ", compile_id); // print compilation number
241
242 bool is_synchronized = false;
243 bool has_exception_handler = false;
244 bool is_native = false;
245 if (method != nullptr) {
246 is_synchronized = method->is_synchronized();
247 has_exception_handler = method->has_exception_handler();
248 is_native = method->is_native();
249 }
250 // method attributes
251 const char compile_type = is_osr_method ? '%' : ' ';
252 const char sync_char = is_synchronized ? 's' : ' ';
253 const char exception_char = has_exception_handler ? '!' : ' ';
254 const char blocking_char = is_blocking ? 'b' : ' ';
255 const char native_char = is_native ? 'n' : ' ';
256
257 // print method attributes
258 st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char);
259
260 if (TieredCompilation) {
261 if (comp_level != -1) st->print("%d ", comp_level);
262 else st->print("- ");
263 }
264 st->print(" "); // more indent
265
266 if (method == nullptr) {
267 st->print("(method)");
268 } else {
269 method->print_short_name(st);
270 if (is_osr_method) {
271 st->print(" @ %d", osr_bci);
272 }
273 if (method->is_native())
274 st->print(" (native)");
275 else
276 st->print(" (%d bytes)", method->code_size());
277 }
278
279 if (msg != nullptr) {
280 st->print(" %s", msg);
281 }
282 if (cr) {
283 st->cr();
284 }
285 }
286
287 // ------------------------------------------------------------------
288 // CompileTask::print_compilation
289 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
290 bool is_osr_method = osr_bci() != InvocationEntryBci;
291 print_impl(st, is_unloaded() ? nullptr : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form, cr, _time_queued, _time_started);
292 }
293
294 // ------------------------------------------------------------------
295 // CompileTask::log_task
296 void CompileTask::log_task(xmlStream* log) {
297 Thread* thread = Thread::current();
298 methodHandle method(thread, this->method());
299 ResourceMark rm(thread);
300
301 // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
302 log->print(" compile_id='%d'", _compile_id);
303 if (_osr_bci != CompileBroker::standard_entry_bci) {
304 log->print(" compile_kind='osr'"); // same as nmethod::compile_kind
305 } // else compile_kind='c2c'
306 if (!method.is_null()) log->method(method());
307 if (_osr_bci != CompileBroker::standard_entry_bci) {
308 log->print(" osr_bci='%d'", _osr_bci);
309 }
310 if (_comp_level != CompilationPolicy::highest_compile_level()) {
311 log->print(" level='%d'", _comp_level);
312 }
313 if (_is_blocking) {
314 log->print(" blocking='1'");
315 }
316 log->stamp();
317 }
318
319 // ------------------------------------------------------------------
320 // CompileTask::log_task_queued
321 void CompileTask::log_task_queued() {
322 ttyLocker ttyl;
323 ResourceMark rm;
324 NoSafepointVerifier nsv;
325
326 xtty->begin_elem("task_queued");
327 log_task(xtty);
328 assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
329 xtty->print(" comment='%s'", reason_name(_compile_reason));
330
331 if (_hot_method != nullptr && _hot_method != _method) {
332 xtty->method(_hot_method);
333 }
334 if (_hot_count != 0) {
335 xtty->print(" hot_count='%d'", _hot_count);
336 }
337 xtty->end_elem();
338 }
339
340
341 // ------------------------------------------------------------------
342 // CompileTask::log_task_start
343 void CompileTask::log_task_start(CompileLog* log) {
344 log->begin_head("task");
345 log_task(log);
346 log->end_head();
347 }
348
349
350 // ------------------------------------------------------------------
351 // CompileTask::log_task_done
352 void CompileTask::log_task_done(CompileLog* log) {
353 Thread* thread = Thread::current();
354 methodHandle method(thread, this->method());
355 ResourceMark rm(thread);
356
357 if (!_is_success) {
358 assert(_failure_reason != nullptr, "missing");
359 const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
360 log->begin_elem("failure reason='");
361 log->text("%s", reason);
362 log->print("'");
363 log->end_elem();
364 }
365
467 } else if (result == InliningResult::FAILURE) {
468 st->print(" %s", "failed to inline");
469 }
470 }
471
472 void CompileTask::print_ul(const char* msg){
473 LogTarget(Debug, jit, compilation) lt;
474 if (lt.is_enabled()) {
475 LogStream ls(lt);
476 print(&ls, msg, /* short form */ true, /* cr */ true);
477 }
478 }
479
480 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
481 LogTarget(Debug, jit, compilation) lt;
482 if (lt.is_enabled()) {
483 LogStream ls(lt);
484 print_impl(&ls, nm->method(), nm->compile_id(),
485 nm->comp_level(), nm->is_osr_method(),
486 nm->is_osr_method() ? nm->osr_entry_bci() : -1,
487 /*is_blocking*/ false,
488 msg, /* short form */ true, /* cr */ true);
489 }
490 }
491
492 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
493 LogTarget(Debug, jit, inlining) lt;
494 if (lt.is_enabled()) {
495 LogStream ls(lt);
496 print_inlining_inner(&ls, method, inline_level, bci, result, msg);
497 }
498 }
499
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "compiler/compilationPolicy.hpp"
26 #include "compiler/compileTask.hpp"
27 #include "compiler/compileLog.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "compiler/compilerDirectives.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/klass.inline.hpp"
34 #include "runtime/handles.inline.hpp"
35 #include "runtime/jniHandles.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "code/SCCache.hpp"
38
39 CompileTask* CompileTask::_task_free_list = nullptr;
40
41 /**
42 * Allocate a CompileTask, from the free list if possible.
43 */
44 CompileTask* CompileTask::allocate() {
45 MutexLocker locker(CompileTaskAlloc_lock);
46 CompileTask* task = nullptr;
47
48 if (_task_free_list != nullptr) {
49 task = _task_free_list;
50 _task_free_list = task->next();
51 task->set_next(nullptr);
52 } else {
53 task = new CompileTask();
54 task->set_next(nullptr);
55 task->set_is_free(true);
56 }
57 assert(task->is_free(), "Task must be free.");
75 JNIHandles::destroy_global(task->_hot_method_holder);
76 }
77 if (task->_failure_reason_on_C_heap && task->_failure_reason != nullptr) {
78 os::free((void*) task->_failure_reason);
79 }
80 task->_failure_reason = nullptr;
81 task->_failure_reason_on_C_heap = false;
82
83 task->set_is_free(true);
84 task->set_next(_task_free_list);
85 _task_free_list = task;
86 }
87 }
88
89 void CompileTask::initialize(int compile_id,
90 const methodHandle& method,
91 int osr_bci,
92 int comp_level,
93 const methodHandle& hot_method,
94 int hot_count,
95 SCCEntry* scc_entry,
96 CompileTask::CompileReason compile_reason,
97 CompileQueue* compile_queue,
98 bool requires_online_compilation,
99 bool is_blocking) {
100 assert(!_lock->is_locked(), "bad locking");
101
102 Thread* thread = Thread::current();
103 _compile_id = compile_id;
104 _method = method();
105 _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
106 _osr_bci = osr_bci;
107 _requires_online_compilation = requires_online_compilation;
108 _is_blocking = is_blocking;
109 _comp_level = comp_level;
110 _num_inlined_bytecodes = 0;
111
112 _waiting_count = 0;
113
114 _is_complete = false;
115 _is_success = false;
116
117 _next = nullptr;
118 _prev = nullptr;
119
120 _hot_method = nullptr;
121 _hot_method_holder = nullptr;
122 _hot_count = hot_count;
123 _time_created = os::elapsed_counter();
124 _time_queued = 0;
125 _time_started = 0;
126 _time_finished = 0;
127 _compile_reason = compile_reason;
128 _nm_content_size = 0;
129 _nm_insts_size = 0;
130 _nm_total_size = 0;
131 _failure_reason = nullptr;
132 _failure_reason_on_C_heap = false;
133 _training_data = nullptr;
134 _scc_entry = scc_entry;
135 _compile_queue = compile_queue;
136
137 AbstractCompiler* comp = CompileBroker::compiler(comp_level);
138 #if INCLUDE_JVMCI
139 if (comp->is_jvmci() && CompileBroker::compiler3() != nullptr) {
140 assert(_method != nullptr, "sanity");
141 if (((JVMCICompiler*)comp)->force_comp_at_level_simple(method)) {
142 comp = CompileBroker::compiler3();
143 }
144 }
145 #endif
146 _compiler = comp;
147 _directive = DirectivesStack::getMatchingDirective(method, comp);
148
149 JVMCI_ONLY(_has_waiter = comp->is_jvmci();)
150 JVMCI_ONLY(_blocking_jvmci_compile_state = nullptr;)
151 _arena_bytes = 0;
152
153 if (LogCompilation) {
154 if (hot_method.not_null()) {
155 if (hot_method == method) {
156 _hot_method = _method;
157 } else {
158 _hot_method = hot_method();
159 // only add loader or mirror if different from _method_holder
160 _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
161 }
162 }
163 }
164
165 _next = nullptr;
166 }
167
168 /**
169 * Returns the compiler for this task.
170 */
171 AbstractCompiler* CompileTask::compiler() const {
172 assert(_compiler != nullptr, "should be set");
173 return _compiler;
174 }
175
176 // Replace weak handles by strong handles to avoid unloading during compilation.
177 CompileTask* CompileTask::select_for_compilation() {
178 if (_compile_reason == Reason_Preload) {
179 return this;
180 }
181 if (is_unloaded()) {
182 // Guard against concurrent class unloading
183 return nullptr;
184 }
185 Thread* thread = Thread::current();
186 assert(_method->method_holder()->is_loader_alive(), "should be alive");
187 Handle method_holder(thread, _method->method_holder()->klass_holder());
188 JNIHandles::destroy_weak_global(_method_holder);
189 JNIHandles::destroy_weak_global(_hot_method_holder);
190 _method_holder = JNIHandles::make_global(method_holder);
191 if (_hot_method != nullptr) {
192 _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
193 }
194 return this;
195 }
196
197 void CompileTask::mark_on_stack() {
198 if (is_unloaded()) {
199 return;
200 }
201 // Mark these methods as something redefine classes cannot remove.
202 _method->set_on_stack(true);
203 if (_hot_method != nullptr) {
204 _hot_method->set_on_stack(true);
205 }
206 }
207
208 bool CompileTask::is_unloaded() const {
209 if (preload()) return false;
210 return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
211 }
212
213 // RedefineClasses support
214 void CompileTask::metadata_do(MetadataClosure* f) {
215 if (is_unloaded()) {
216 return;
217 }
218 f->do_metadata(method());
219 if (hot_method() != nullptr && hot_method() != method()) {
220 f->do_metadata(hot_method());
221 }
222 }
223
224 // ------------------------------------------------------------------
225 // CompileTask::print_line_on_error
226 //
227 // This function is called by fatal error handler when the thread
228 // causing troubles is a compiler thread.
229 //
230 // Do not grab any lock, do not allocate memory.
231 //
232 // Otherwise it's the same as CompileTask::print_line()
233 //
234 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
235 // print compiler name
236 st->print("%s:", compiler()->name());
237 print(st);
238 }
239
240 // ------------------------------------------------------------------
241 // CompileTask::print_tty
242 void CompileTask::print_tty() {
243 ttyLocker ttyl; // keep the following output all in one block
244 print(tty);
245 }
246
247 // ------------------------------------------------------------------
248 // CompileTask::print_impl
249 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
250 bool is_osr_method, int osr_bci, bool is_blocking, bool is_scc, bool is_preload,
251 const char* compiler_name,
252 const char* msg, bool short_form, bool cr,
253 jlong time_created, jlong time_queued, jlong time_started, jlong time_finished) {
254 if (!short_form) {
255 {
256 stringStream ss;
257 ss.print(UINT64_FORMAT, (uint64_t) tty->time_stamp().milliseconds());
258 st->print("%7s ", ss.freeze());
259 }
260 { // Time waiting to be put on queue
261 stringStream ss;
262 if (time_created != 0 && time_queued != 0) {
263 ss.print("W%.1f", TimeHelper::counter_to_millis(time_queued - time_created));
264 }
265 st->print("%7s ", ss.freeze());
266 }
267 { // Time in queue
268 stringStream ss;
269 if (time_queued != 0 && time_started != 0) {
270 ss.print("Q%.1f", TimeHelper::counter_to_millis(time_started - time_queued));
271 }
272 st->print("%7s ", ss.freeze());
273 }
274 { // Time in compilation
275 stringStream ss;
276 if (time_started != 0 && time_finished != 0) {
277 ss.print("C%.1f", TimeHelper::counter_to_millis(time_finished - time_started));
278 }
279 st->print("%7s ", ss.freeze());
280 }
281 st->print(" ");
282 }
283
284 // print compiler name if requested
285 if (CIPrintCompilerName) {
286 st->print("%s:", compiler_name);
287 }
288 st->print("%4d ", compile_id); // print compilation number
289
290 bool is_synchronized = false;
291 bool has_exception_handler = false;
292 bool is_native = false;
293 if (method != nullptr) {
294 is_synchronized = method->is_synchronized();
295 has_exception_handler = method->has_exception_handler();
296 is_native = method->is_native();
297 }
298 // method attributes
299 const char compile_type = is_osr_method ? '%' : ' ';
300 const char sync_char = is_synchronized ? 's' : ' ';
301 const char exception_char = has_exception_handler ? '!' : ' ';
302 const char blocking_char = is_blocking ? 'b' : ' ';
303 const char native_char = is_native ? 'n' : ' ';
304 const char scc_char = is_scc ? 'A' : ' ';
305 const char preload_char = is_preload ? 'P' : ' ';
306
307 // print method attributes
308 st->print("%c%c%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char, scc_char, preload_char);
309
310 if (TieredCompilation) {
311 if (comp_level != -1) st->print("%d ", comp_level);
312 else st->print("- ");
313 }
314 st->print(" "); // more indent
315
316 if (method == nullptr) {
317 st->print("(method)");
318 } else {
319 method->print_short_name(st);
320 if (is_osr_method) {
321 st->print(" @ %d", osr_bci);
322 }
323 if (method->is_native())
324 st->print(" (native)");
325 else
326 st->print(" (%d bytes)", method->code_size());
327 }
328
329 if (msg != nullptr) {
330 st->print(" %s", msg);
331 }
332 if (cr) {
333 st->cr();
334 }
335 }
336
337 // ------------------------------------------------------------------
338 // CompileTask::print_compilation
339 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
340 bool is_osr_method = osr_bci() != InvocationEntryBci;
341 print_impl(st, is_unloaded() ? nullptr : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), is_scc(), preload(),
342 compiler()->name(), msg, short_form, cr, _time_created, _time_queued, _time_started, _time_finished);
343 }
344
345 // ------------------------------------------------------------------
346 // CompileTask::log_task
347 void CompileTask::log_task(xmlStream* log) {
348 Thread* thread = Thread::current();
349 methodHandle method(thread, this->method());
350 ResourceMark rm(thread);
351
352 // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
353 log->print(" compile_id='%d'", _compile_id);
354 if (_osr_bci != CompileBroker::standard_entry_bci) {
355 log->print(" compile_kind='osr'"); // same as nmethod::compile_kind
356 } // else compile_kind='c2c'
357 if (!method.is_null()) log->method(method());
358 if (_osr_bci != CompileBroker::standard_entry_bci) {
359 log->print(" osr_bci='%d'", _osr_bci);
360 }
361 if (_comp_level != CompilationPolicy::highest_compile_level()) {
362 log->print(" level='%d'", _comp_level);
363 }
364 if (_is_blocking) {
365 log->print(" blocking='1'");
366 }
367 }
368
369 // ------------------------------------------------------------------
370 // CompileTask::log_task_queued
371 void CompileTask::log_task_queued() {
372 ttyLocker ttyl;
373 ResourceMark rm;
374 NoSafepointVerifier nsv;
375
376 xtty->begin_elem("task_queued");
377 log_task(xtty);
378 assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
379 xtty->print(" comment='%s'", reason_name(_compile_reason));
380
381 if (_hot_method != nullptr && _hot_method != _method) {
382 xtty->method(_hot_method, "hot_");
383 }
384 if (_hot_count != 0) {
385 xtty->print(" hot_count='%d'", _hot_count);
386 }
387 xtty->stamp();
388 xtty->end_elem();
389 }
390
391
392 // ------------------------------------------------------------------
393 // CompileTask::log_task_start
394 void CompileTask::log_task_start(CompileLog* log) {
395 log->begin_head("task");
396 log_task(log);
397 log->stamp();
398 log->end_head();
399 }
400
401
402 // ------------------------------------------------------------------
403 // CompileTask::log_task_done
404 void CompileTask::log_task_done(CompileLog* log) {
405 Thread* thread = Thread::current();
406 methodHandle method(thread, this->method());
407 ResourceMark rm(thread);
408
409 if (!_is_success) {
410 assert(_failure_reason != nullptr, "missing");
411 const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
412 log->begin_elem("failure reason='");
413 log->text("%s", reason);
414 log->print("'");
415 log->end_elem();
416 }
417
519 } else if (result == InliningResult::FAILURE) {
520 st->print(" %s", "failed to inline");
521 }
522 }
523
524 void CompileTask::print_ul(const char* msg){
525 LogTarget(Debug, jit, compilation) lt;
526 if (lt.is_enabled()) {
527 LogStream ls(lt);
528 print(&ls, msg, /* short form */ true, /* cr */ true);
529 }
530 }
531
532 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
533 LogTarget(Debug, jit, compilation) lt;
534 if (lt.is_enabled()) {
535 LogStream ls(lt);
536 print_impl(&ls, nm->method(), nm->compile_id(),
537 nm->comp_level(), nm->is_osr_method(),
538 nm->is_osr_method() ? nm->osr_entry_bci() : -1,
539 /*is_blocking*/ false, nm->scc_entry() != nullptr,
540 nm->preloaded(), nm->compiler_name(),
541 msg, /* short form */ true, /* cr */ true);
542 }
543 }
544
545 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
546 LogTarget(Debug, jit, inlining) lt;
547 if (lt.is_enabled()) {
548 LogStream ls(lt);
549 print_inlining_inner(&ls, method, inline_level, bci, result, msg);
550 }
551 }
552
|