< prev index next >

src/hotspot/share/compiler/compileTask.cpp

Print this page

 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 
127   if (LogCompilation) {
128     if (hot_method.not_null()) {
129       if (hot_method == method) {
130         _hot_method = _method;
131       } else {
132         _hot_method = hot_method();
133         // only add loader or mirror if different from _method_holder
134         _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
135       }
136     }
137   }
138 
139   _next = nullptr;
140 }
141 
142 /**
143  * Returns the compiler for this task.
144  */
145 AbstractCompiler* CompileTask::compiler() const {
146   return CompileBroker::compiler(_comp_level);

147 }
148 
149 // Replace weak handles by strong handles to avoid unloading during compilation.
150 CompileTask* CompileTask::select_for_compilation() {



151   if (is_unloaded()) {
152     // Guard against concurrent class unloading
153     return nullptr;
154   }
155   Thread* thread = Thread::current();
156   assert(_method->method_holder()->is_loader_alive(), "should be alive");
157   Handle method_holder(thread, _method->method_holder()->klass_holder());
158   JNIHandles::destroy_weak_global(_method_holder);
159   JNIHandles::destroy_weak_global(_hot_method_holder);
160   _method_holder = JNIHandles::make_global(method_holder);
161   if (_hot_method != nullptr) {
162     _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
163   }
164   return this;
165 }
166 
167 void CompileTask::mark_on_stack() {
168   if (is_unloaded()) {
169     return;
170   }
171   // Mark these methods as something redefine classes cannot remove.
172   _method->set_on_stack(true);
173   if (_hot_method != nullptr) {
174     _hot_method->set_on_stack(true);
175   }
176 }
177 
178 bool CompileTask::is_unloaded() const {

179   return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
180 }
181 
182 // RedefineClasses support
183 void CompileTask::metadata_do(MetadataClosure* f) {
184   if (is_unloaded()) {
185     return;
186   }
187   f->do_metadata(method());
188   if (hot_method() != nullptr && hot_method() != method()) {
189     f->do_metadata(hot_method());
190   }
191 }
192 
193 // ------------------------------------------------------------------
194 // CompileTask::print_line_on_error
195 //
196 // This function is called by fatal error handler when the thread
197 // causing troubles is a compiler thread.
198 //
199 // Do not grab any lock, do not allocate memory.
200 //
201 // Otherwise it's the same as CompileTask::print_line()
202 //
203 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
204   // print compiler name
205   st->print("%s:", CompileBroker::compiler_name(comp_level()));
206   print(st);
207 }
208 
209 // ------------------------------------------------------------------
210 // CompileTask::print_tty
211 void CompileTask::print_tty() {
212   ttyLocker ttyl;  // keep the following output all in one block
213   print(tty);
214 }
215 
216 // ------------------------------------------------------------------
217 // CompileTask::print_impl
218 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
219                              bool is_osr_method, int osr_bci, bool is_blocking,

220                              const char* msg, bool short_form, bool cr,
221                              jlong time_queued, jlong time_started) {
222   if (!short_form) {
223     // Print current time
224     st->print(UINT64_FORMAT " ", (uint64_t) tty->time_stamp().milliseconds());
225     if (Verbose && time_queued != 0) {


226       // Print time in queue and time being processed by compiler thread
227       jlong now = os::elapsed_counter();
228       st->print("%.0f ", TimeHelper::counter_to_millis(now-time_queued));
229       if (time_started != 0) {
230         st->print("%.0f ", TimeHelper::counter_to_millis(now-time_started));



231       }
232     }
233   }
234   // print compiler name if requested
235   if (CIPrintCompilerName) {
236     st->print("%s:", CompileBroker::compiler_name(comp_level));
237   }
238   st->print("%4d ", compile_id);    // print compilation number
239 
240   bool is_synchronized = false;
241   bool has_exception_handler = false;
242   bool is_native = false;
243   if (method != nullptr) {
244     is_synchronized       = method->is_synchronized();
245     has_exception_handler = method->has_exception_handler();
246     is_native             = method->is_native();
247   }
248   // method attributes
249   const char compile_type   = is_osr_method                   ? '%' : ' ';
250   const char sync_char      = is_synchronized                 ? 's' : ' ';
251   const char exception_char = has_exception_handler           ? '!' : ' ';
252   const char blocking_char  = is_blocking                     ? 'b' : ' ';
253   const char native_char    = is_native                       ? 'n' : ' ';


254 
255   // print method attributes
256   st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char);
257 
258   if (TieredCompilation) {
259     if (comp_level != -1)  st->print("%d ", comp_level);
260     else                   st->print("- ");
261   }
262   st->print("     ");  // more indent
263 
264   if (method == nullptr) {
265     st->print("(method)");
266   } else {
267     method->print_short_name(st);
268     if (is_osr_method) {
269       st->print(" @ %d", osr_bci);
270     }
271     if (method->is_native())
272       st->print(" (native)");
273     else
274       st->print(" (%d bytes)", method->code_size());
275   }
276 

284 
285 void CompileTask::print_inline_indent(int inline_level, outputStream* st) {
286   //         1234567
287   st->print("        ");     // print timestamp
288   //         1234
289   st->print("     ");        // print compilation number
290   //         %s!bn
291   st->print("      ");       // print method attributes
292   if (TieredCompilation) {
293     st->print("  ");
294   }
295   st->print("     ");        // more indent
296   st->print("    ");         // initial inlining indent
297   for (int i = 0; i < inline_level; i++)  st->print("  ");
298 }
299 
300 // ------------------------------------------------------------------
301 // CompileTask::print_compilation
302 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
303   bool is_osr_method = osr_bci() != InvocationEntryBci;
304   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);

305 }
306 
307 // ------------------------------------------------------------------
308 // CompileTask::log_task
309 void CompileTask::log_task(xmlStream* log) {
310   Thread* thread = Thread::current();
311   methodHandle method(thread, this->method());
312   ResourceMark rm(thread);
313 
314   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
315   log->print(" compile_id='%d'", _compile_id);
316   if (_osr_bci != CompileBroker::standard_entry_bci) {
317     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
318   } // else compile_kind='c2c'
319   if (!method.is_null())  log->method(method());
320   if (_osr_bci != CompileBroker::standard_entry_bci) {
321     log->print(" osr_bci='%d'", _osr_bci);
322   }
323   if (_comp_level != CompilationPolicy::highest_compile_level()) {
324     log->print(" level='%d'", _comp_level);
325   }
326   if (_is_blocking) {
327     log->print(" blocking='1'");
328   }
329   log->stamp();
330 }
331 
332 // ------------------------------------------------------------------
333 // CompileTask::log_task_queued
334 void CompileTask::log_task_queued() {
335   ttyLocker ttyl;
336   ResourceMark rm;
337   NoSafepointVerifier nsv;
338 
339   xtty->begin_elem("task_queued");
340   log_task(xtty);
341   assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
342   xtty->print(" comment='%s'", reason_name(_compile_reason));
343 
344   if (_hot_method != nullptr && _hot_method != _method) {
345     xtty->method(_hot_method);
346   }
347   if (_hot_count != 0) {
348     xtty->print(" hot_count='%d'", _hot_count);
349   }

350   xtty->end_elem();
351 }
352 
353 
354 // ------------------------------------------------------------------
355 // CompileTask::log_task_start
356 void CompileTask::log_task_start(CompileLog* log)   {
357   log->begin_head("task");
358   log_task(log);

359   log->end_head();
360 }
361 
362 
363 // ------------------------------------------------------------------
364 // CompileTask::log_task_done
365 void CompileTask::log_task_done(CompileLog* log) {
366   Thread* thread = Thread::current();
367   methodHandle method(thread, this->method());
368   ResourceMark rm(thread);
369 
370   if (!_is_success) {
371     assert(_failure_reason != nullptr, "missing");
372     const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
373     log->begin_elem("failure reason='");
374     log->text("%s", reason);
375     log->print("'");
376     log->end_elem();
377   }
378 

449     st->print("   %s", "failed to inline");
450   }
451   st->cr();
452 }
453 
454 void CompileTask::print_ul(const char* msg){
455   LogTarget(Debug, jit, compilation) lt;
456   if (lt.is_enabled()) {
457     LogStream ls(lt);
458     print(&ls, msg, /* short form */ true, /* cr */ true);
459   }
460 }
461 
462 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
463   LogTarget(Debug, jit, compilation) lt;
464   if (lt.is_enabled()) {
465     LogStream ls(lt);
466     print_impl(&ls, nm->method(), nm->compile_id(),
467                nm->comp_level(), nm->is_osr_method(),
468                nm->is_osr_method() ? nm->osr_entry_bci() : -1,
469                /*is_blocking*/ false,

470                msg, /* short form */ true, /* cr */ true);
471   }
472 }
473 
474 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
475   LogTarget(Debug, jit, inlining) lt;
476   if (lt.is_enabled()) {
477     LogStream ls(lt);
478     print_inlining_inner(&ls, method, inline_level, bci, result, msg);
479   }
480 }
481 

 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 
150   if (LogCompilation) {
151     if (hot_method.not_null()) {
152       if (hot_method == method) {
153         _hot_method = _method;
154       } else {
155         _hot_method = hot_method();
156         // only add loader or mirror if different from _method_holder
157         _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
158       }
159     }
160   }
161 
162   _next = nullptr;
163 }
164 
165 /**
166  * Returns the compiler for this task.
167  */
168 AbstractCompiler* CompileTask::compiler() const {
169   assert(_compiler != nullptr, "should be set");
170   return _compiler;
171 }
172 
173 // Replace weak handles by strong handles to avoid unloading during compilation.
174 CompileTask* CompileTask::select_for_compilation() {
175   if (_compile_reason == Reason_Preload) {
176     return this;
177   }
178   if (is_unloaded()) {
179     // Guard against concurrent class unloading
180     return nullptr;
181   }
182   Thread* thread = Thread::current();
183   assert(_method->method_holder()->is_loader_alive(), "should be alive");
184   Handle method_holder(thread, _method->method_holder()->klass_holder());
185   JNIHandles::destroy_weak_global(_method_holder);
186   JNIHandles::destroy_weak_global(_hot_method_holder);
187   _method_holder = JNIHandles::make_global(method_holder);
188   if (_hot_method != nullptr) {
189     _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
190   }
191   return this;
192 }
193 
194 void CompileTask::mark_on_stack() {
195   if (is_unloaded()) {
196     return;
197   }
198   // Mark these methods as something redefine classes cannot remove.
199   _method->set_on_stack(true);
200   if (_hot_method != nullptr) {
201     _hot_method->set_on_stack(true);
202   }
203 }
204 
205 bool CompileTask::is_unloaded() const {
206   if (preload()) return false;
207   return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
208 }
209 
210 // RedefineClasses support
211 void CompileTask::metadata_do(MetadataClosure* f) {
212   if (is_unloaded()) {
213     return;
214   }
215   f->do_metadata(method());
216   if (hot_method() != nullptr && hot_method() != method()) {
217     f->do_metadata(hot_method());
218   }
219 }
220 
221 // ------------------------------------------------------------------
222 // CompileTask::print_line_on_error
223 //
224 // This function is called by fatal error handler when the thread
225 // causing troubles is a compiler thread.
226 //
227 // Do not grab any lock, do not allocate memory.
228 //
229 // Otherwise it's the same as CompileTask::print_line()
230 //
231 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
232   // print compiler name
233   st->print("%s:", compiler()->name());
234   print(st);
235 }
236 
237 // ------------------------------------------------------------------
238 // CompileTask::print_tty
239 void CompileTask::print_tty() {
240   ttyLocker ttyl;  // keep the following output all in one block
241   print(tty);
242 }
243 
244 // ------------------------------------------------------------------
245 // CompileTask::print_impl
246 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
247                              bool is_osr_method, int osr_bci, bool is_blocking, bool is_scc, bool is_preload,
248                              const char* compiler_name,
249                              const char* msg, bool short_form, bool cr,
250                              jlong time_created, jlong time_queued, jlong time_started) {
251   if (!short_form) {
252     // Print current time
253     stringStream ss;
254     ss.print("%c" UINT64_FORMAT, (time_started != 0 ? 'F' : 'S'), (uint64_t)tty->time_stamp().milliseconds());
255     st->print("%7s ", ss.freeze());
256     if (time_created != 0) {
257       // Print time in queue and time being processed by compiler thread
258       jlong now = os::elapsed_counter();
259       st->print("C%d ", (int) TimeHelper::counter_to_millis((time_queued != 0 ? time_queued : now) - time_created));
260       if (time_queued != 0) {
261         st->print("Q%d ", (int) TimeHelper::counter_to_millis((time_started != 0 ? time_started : now) - time_queued));
262         if (time_started != 0) {
263           st->print("S%d ", (int) TimeHelper::counter_to_millis(now - time_started));
264         }
265       }
266     }
267   }
268   // print compiler name if requested
269   if (CIPrintCompilerName) {
270     st->print("%s:", compiler_name);
271   }
272   st->print("%4d ", compile_id);    // print compilation number
273 
274   bool is_synchronized = false;
275   bool has_exception_handler = false;
276   bool is_native = false;
277   if (method != nullptr) {
278     is_synchronized       = method->is_synchronized();
279     has_exception_handler = method->has_exception_handler();
280     is_native             = method->is_native();
281   }
282   // method attributes
283   const char compile_type   = is_osr_method                   ? '%' : ' ';
284   const char sync_char      = is_synchronized                 ? 's' : ' ';
285   const char exception_char = has_exception_handler           ? '!' : ' ';
286   const char blocking_char  = is_blocking                     ? 'b' : ' ';
287   const char native_char    = is_native                       ? 'n' : ' ';
288   const char scc_char       = is_scc                          ? 'A' : ' ';
289   const char preload_char   = is_preload                      ? 'P' : ' ';
290 
291   // print method attributes
292   st->print("%c%c%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char, scc_char, preload_char);
293 
294   if (TieredCompilation) {
295     if (comp_level != -1)  st->print("%d ", comp_level);
296     else                   st->print("- ");
297   }
298   st->print("     ");  // more indent
299 
300   if (method == nullptr) {
301     st->print("(method)");
302   } else {
303     method->print_short_name(st);
304     if (is_osr_method) {
305       st->print(" @ %d", osr_bci);
306     }
307     if (method->is_native())
308       st->print(" (native)");
309     else
310       st->print(" (%d bytes)", method->code_size());
311   }
312 

320 
321 void CompileTask::print_inline_indent(int inline_level, outputStream* st) {
322   //         1234567
323   st->print("        ");     // print timestamp
324   //         1234
325   st->print("     ");        // print compilation number
326   //         %s!bn
327   st->print("      ");       // print method attributes
328   if (TieredCompilation) {
329     st->print("  ");
330   }
331   st->print("     ");        // more indent
332   st->print("    ");         // initial inlining indent
333   for (int i = 0; i < inline_level; i++)  st->print("  ");
334 }
335 
336 // ------------------------------------------------------------------
337 // CompileTask::print_compilation
338 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
339   bool is_osr_method = osr_bci() != InvocationEntryBci;
340   print_impl(st, is_unloaded() ? nullptr : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), is_scc(), preload(),
341              compiler()->name(), msg, short_form, cr, _time_created, _time_queued, _time_started);
342 }
343 
344 // ------------------------------------------------------------------
345 // CompileTask::log_task
346 void CompileTask::log_task(xmlStream* log) {
347   Thread* thread = Thread::current();
348   methodHandle method(thread, this->method());
349   ResourceMark rm(thread);
350 
351   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
352   log->print(" compile_id='%d'", _compile_id);
353   if (_osr_bci != CompileBroker::standard_entry_bci) {
354     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
355   } // else compile_kind='c2c'
356   if (!method.is_null())  log->method(method());
357   if (_osr_bci != CompileBroker::standard_entry_bci) {
358     log->print(" osr_bci='%d'", _osr_bci);
359   }
360   if (_comp_level != CompilationPolicy::highest_compile_level()) {
361     log->print(" level='%d'", _comp_level);
362   }
363   if (_is_blocking) {
364     log->print(" blocking='1'");
365   }

366 }
367 
368 // ------------------------------------------------------------------
369 // CompileTask::log_task_queued
370 void CompileTask::log_task_queued() {
371   ttyLocker ttyl;
372   ResourceMark rm;
373   NoSafepointVerifier nsv;
374 
375   xtty->begin_elem("task_queued");
376   log_task(xtty);
377   assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
378   xtty->print(" comment='%s'", reason_name(_compile_reason));
379 
380   if (_hot_method != nullptr && _hot_method != _method) {
381     xtty->method(_hot_method, "hot_");
382   }
383   if (_hot_count != 0) {
384     xtty->print(" hot_count='%d'", _hot_count);
385   }
386   xtty->stamp();
387   xtty->end_elem();
388 }
389 
390 
391 // ------------------------------------------------------------------
392 // CompileTask::log_task_start
393 void CompileTask::log_task_start(CompileLog* log) {
394   log->begin_head("task");
395   log_task(log);
396   log->stamp();
397   log->end_head();
398 }
399 
400 
401 // ------------------------------------------------------------------
402 // CompileTask::log_task_done
403 void CompileTask::log_task_done(CompileLog* log) {
404   Thread* thread = Thread::current();
405   methodHandle method(thread, this->method());
406   ResourceMark rm(thread);
407 
408   if (!_is_success) {
409     assert(_failure_reason != nullptr, "missing");
410     const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
411     log->begin_elem("failure reason='");
412     log->text("%s", reason);
413     log->print("'");
414     log->end_elem();
415   }
416 

487     st->print("   %s", "failed to inline");
488   }
489   st->cr();
490 }
491 
492 void CompileTask::print_ul(const char* msg){
493   LogTarget(Debug, jit, compilation) lt;
494   if (lt.is_enabled()) {
495     LogStream ls(lt);
496     print(&ls, msg, /* short form */ true, /* cr */ true);
497   }
498 }
499 
500 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
501   LogTarget(Debug, jit, compilation) lt;
502   if (lt.is_enabled()) {
503     LogStream ls(lt);
504     print_impl(&ls, nm->method(), nm->compile_id(),
505                nm->comp_level(), nm->is_osr_method(),
506                nm->is_osr_method() ? nm->osr_entry_bci() : -1,
507                /*is_blocking*/ false, nm->scc_entry() != nullptr,
508                nm->preloaded(), nm->compiler_name(),
509                msg, /* short form */ true, /* cr */ true);
510   }
511 }
512 
513 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
514   LogTarget(Debug, jit, inlining) lt;
515   if (lt.is_enabled()) {
516     LogStream ls(lt);
517     print_inlining_inner(&ls, method, inline_level, bci, result, msg);
518   }
519 }
520 
< prev index next >