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