< prev index next >

src/hotspot/share/compiler/compileTask.cpp

Print this page

 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/compileBroker.hpp"
 27 #include "compiler/compileLog.hpp"
 28 #include "compiler/compilerDirectives.hpp"
 29 #include "compiler/compileTask.hpp"
 30 #include "logging/log.hpp"
 31 #include "logging/logStream.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "oops/klass.inline.hpp"
 34 #include "oops/method.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.");
 58   task->set_is_free(false);
 59   return task;
 60 }
 61 
 62 /**
 63 * Add a task to the free list.
 64 */
 65 void CompileTask::free(CompileTask* task) {
 66   MutexLocker locker(CompileTaskAlloc_lock);
 67   if (!task->is_free()) {
 68     assert(!task->lock()->is_locked(), "Should not be locked when freed");
 69     if ((task->_method_holder != nullptr && JNIHandles::is_weak_global_handle(task->_method_holder))) {
 70       JNIHandles::destroy_weak_global(task->_method_holder);
 71     } else {
 72       JNIHandles::destroy_global(task->_method_holder);
 73     }
 74     if (task->_failure_reason_on_C_heap && task->_failure_reason != nullptr) {
 75       os::free((void*) task->_failure_reason);
 76     }
 77     task->_failure_reason = nullptr;
 78     task->_failure_reason_on_C_heap = false;
 79 
 80     task->set_is_free(true);
 81     task->set_next(_task_free_list);
 82     _task_free_list = task;
 83   }
 84 }
 85 
 86 void CompileTask::initialize(int compile_id,
 87                              const methodHandle& method,
 88                              int osr_bci,
 89                              int comp_level,
 90                              int hot_count,
 91                              CompileTask::CompileReason compile_reason,
 92                              bool is_blocking) {
 93   assert(!_lock->is_locked(), "bad locking");
 94 
 95   Thread* thread = Thread::current();
 96   _compile_id = compile_id;
 97   _method = method();
 98   _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
 99   _osr_bci = osr_bci;

100   _is_blocking = is_blocking;
101   JVMCI_ONLY(_has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();)
102   JVMCI_ONLY(_blocking_jvmci_compile_state = nullptr;)
103   _comp_level = comp_level;
104   _num_inlined_bytecodes = 0;
105 
106   _waiting_count = 0;
107 
108   _is_complete = false;
109   _is_success = false;
110 



111   _hot_count = hot_count;
112   _time_queued = os::elapsed_counter();

113   _time_started = 0;



114   _compile_reason = compile_reason;
115   _nm_content_size = 0;
116   AbstractCompiler* comp = compiler();
117   _directive = DirectivesStack::getMatchingDirective(method, comp);
118   _nm_insts_size = 0;
119   _nm_total_size = 0;
120   _failure_reason = nullptr;
121   _failure_reason_on_C_heap = false;
122   _training_data = nullptr;









123   _arena_bytes = 0;
124 
125   _next = nullptr;



























126 }
127 
128 /**
129  * Returns the compiler for this task.
130  */
131 AbstractCompiler* CompileTask::compiler() const {
132   return CompileBroker::compiler(_comp_level);

133 }
134 
135 // Replace weak handles by strong handles to avoid unloading during compilation.
136 CompileTask* CompileTask::select_for_compilation() {



137   if (is_unloaded()) {
138     // Guard against concurrent class unloading
139     return nullptr;
140   }
141   Thread* thread = Thread::current();
142   assert(_method->method_holder()->is_loader_alive(), "should be alive");
143   Handle method_holder(thread, _method->method_holder()->klass_holder());
144   JNIHandles::destroy_weak_global(_method_holder);
145   _method_holder = JNIHandles::make_global(method_holder);
146   return this;
147 }
148 
149 void CompileTask::mark_on_stack() {
150   if (is_unloaded()) {
151     return;
152   }
153   // Mark these methods as something redefine classes cannot remove.
154   _method->set_on_stack(true);
155 }
156 
157 bool CompileTask::is_unloaded() const {

158   return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
159 }
160 
161 // RedefineClasses support
162 void CompileTask::metadata_do(MetadataClosure* f) {
163   if (is_unloaded()) {
164     return;
165   }
166   f->do_metadata(method());
167 }
168 
169 // ------------------------------------------------------------------
170 // CompileTask::print_line_on_error
171 //
172 // This function is called by fatal error handler when the thread
173 // causing troubles is a compiler thread.
174 //
175 // Do not grab any lock, do not allocate memory.
176 //
177 // Otherwise it's the same as CompileTask::print_line()
178 //
179 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
180   // print compiler name
181   st->print("%s:", CompileBroker::compiler_name(comp_level()));
182   print(st);
183 }
184 
185 // ------------------------------------------------------------------
186 // CompileTask::print_tty
187 void CompileTask::print_tty() {
188   ttyLocker ttyl;  // keep the following output all in one block
189   print(tty);
190 }
191 
192 // ------------------------------------------------------------------
193 // CompileTask::print_impl
194 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
195                              bool is_osr_method, int osr_bci, bool is_blocking,

196                              const char* msg, bool short_form, bool cr,
197                              jlong time_queued, jlong time_started) {

198   if (!short_form) {
199     // Print current time
200     st->print(UINT64_FORMAT " ", (uint64_t) tty->time_stamp().milliseconds());
201     if (Verbose && time_queued != 0) {
202       // Print time in queue and time being processed by compiler thread
203       jlong now = os::elapsed_counter();
204       st->print("%.0f ", TimeHelper::counter_to_millis(now-time_queued));
205       if (time_started != 0) {
206         st->print("%.0f ", TimeHelper::counter_to_millis(now-time_started));






















207       }

208     }

209   }

210   // print compiler name if requested
211   if (CIPrintCompilerName) {
212     st->print("%s:", CompileBroker::compiler_name(comp_level));
213   }
214   st->print("%4d ", compile_id);    // print compilation number
215 
216   bool is_synchronized = false;
217   bool has_exception_handler = false;
218   bool is_native = false;
219   if (method != nullptr) {
220     is_synchronized       = method->is_synchronized();
221     has_exception_handler = method->has_exception_handler();
222     is_native             = method->is_native();
223   }
224   // method attributes
225   const char compile_type   = is_osr_method                   ? '%' : ' ';
226   const char sync_char      = is_synchronized                 ? 's' : ' ';
227   const char exception_char = has_exception_handler           ? '!' : ' ';
228   const char blocking_char  = is_blocking                     ? 'b' : ' ';
229   const char native_char    = is_native                       ? 'n' : ' ';


230 
231   // print method attributes
232   st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char);
233 
234   if (TieredCompilation) {
235     if (comp_level != -1)  st->print("%d ", comp_level);
236     else                   st->print("- ");
237   }
238   st->print("     ");  // more indent
239 
240   if (method == nullptr) {
241     st->print("(method)");
242   } else {
243     method->print_short_name(st);
244     if (is_osr_method) {
245       st->print(" @ %d", osr_bci);
246     }
247     if (method->is_native())
248       st->print(" (native)");
249     else
250       st->print(" (%d bytes)", method->code_size());
251   }
252 
253   if (msg != nullptr) {
254     st->print("   %s", msg);
255   }
256   if (cr) {
257     st->cr();
258   }
259 }
260 
261 // ------------------------------------------------------------------
262 // CompileTask::print_compilation
263 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
264   bool is_osr_method = osr_bci() != InvocationEntryBci;
265   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);








266 }
267 
268 // ------------------------------------------------------------------
269 // CompileTask::log_task
270 void CompileTask::log_task(xmlStream* log) {
271   Thread* thread = Thread::current();
272   methodHandle method(thread, this->method());
273   ResourceMark rm(thread);
274 
275   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
276   log->print(" compile_id='%d'", _compile_id);
277   if (_osr_bci != CompileBroker::standard_entry_bci) {
278     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind




279   } // else compile_kind='c2c'
280   if (!method.is_null())  log->method(method());
281   if (_osr_bci != CompileBroker::standard_entry_bci) {
282     log->print(" osr_bci='%d'", _osr_bci);
283   }
284   if (_comp_level != CompilationPolicy::highest_compile_level()) {
285     log->print(" level='%d'", _comp_level);
286   }
287   if (_is_blocking) {
288     log->print(" blocking='1'");
289   }
290   log->stamp();
291 }
292 
293 // ------------------------------------------------------------------
294 // CompileTask::log_task_queued
295 void CompileTask::log_task_queued() {
296   ttyLocker ttyl;
297   ResourceMark rm;
298   NoSafepointVerifier nsv;
299 
300   xtty->begin_elem("task_queued");
301   log_task(xtty);
302   assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
303   xtty->print(" comment='%s'", reason_name(_compile_reason));
304 
305   if (_hot_count != 0) {
306     xtty->print(" hot_count='%d'", _hot_count);
307   }

308   xtty->end_elem();
309 }
310 
311 
312 // ------------------------------------------------------------------
313 // CompileTask::log_task_start
314 void CompileTask::log_task_start(CompileLog* log)   {
315   log->begin_head("task");
316   log_task(log);

317   log->end_head();
318 }
319 
320 
321 // ------------------------------------------------------------------
322 // CompileTask::log_task_done
323 void CompileTask::log_task_done(CompileLog* log) {
324   Thread* thread = Thread::current();
325   methodHandle method(thread, this->method());
326   ResourceMark rm(thread);
327 
328   if (!_is_success) {
329     assert(_failure_reason != nullptr, "missing");
330     const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
331     log->begin_elem("failure reason='");
332     log->text("%s", reason);
333     log->print("'");
334     log->end_elem();
335   }
336 

438   } else if (result == InliningResult::FAILURE) {
439     st->print("   %s", "failed to inline");
440   }
441 }
442 
443 void CompileTask::print_ul(const char* msg){
444   LogTarget(Info, jit, compilation) lt;
445   if (lt.is_enabled()) {
446     LogStream ls(lt);
447     print(&ls, msg, /* short form */ true, /* cr */ true);
448   }
449 }
450 
451 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
452   LogTarget(Info, jit, compilation) lt;
453   if (lt.is_enabled()) {
454     LogStream ls(lt);
455     print_impl(&ls, nm->method(), nm->compile_id(),
456                nm->comp_level(), nm->is_osr_method(),
457                nm->is_osr_method() ? nm->osr_entry_bci() : -1,
458                /*is_blocking*/ false,

459                msg, /* short form */ true, /* cr */ true);
460   }
461 }
462 
463 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
464   LogTarget(Debug, jit, inlining) lt;
465   if (lt.is_enabled()) {
466     LogStream ls(lt);
467     print_inlining_inner(&ls, method, inline_level, bci, result, msg);
468   }
469 }
470 

 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/compileBroker.hpp"
 27 #include "compiler/compileLog.hpp"
 28 #include "compiler/compilerDirectives.hpp"
 29 #include "compiler/compileTask.hpp"
 30 #include "logging/log.hpp"
 31 #include "logging/logStream.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "oops/klass.inline.hpp"
 34 #include "oops/method.inline.hpp"
 35 #include "runtime/handles.inline.hpp"
 36 #include "runtime/jniHandles.hpp"
 37 #include "runtime/mutexLocker.hpp"
 38 
 39 int CompileTask::_active_tasks = 0;
 40 
 41 CompileTask::CompileTask(int compile_id,
 42                          const methodHandle& method,
 43                          int osr_bci,
 44                          int comp_level,
 45                          int hot_count,
 46                          AOTCodeEntry* aot_code_entry,
 47                          CompileTask::CompileReason compile_reason,
 48                          CompileQueue* compile_queue,
 49                          bool requires_online_compilation,
 50                          bool is_blocking) {












































 51   Thread* thread = Thread::current();
 52   _compile_id = compile_id;
 53   _method = method();
 54   _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
 55   _osr_bci = osr_bci;
 56   _requires_online_compilation = requires_online_compilation;
 57   _is_blocking = is_blocking;


 58   _comp_level = comp_level;
 59   _num_inlined_bytecodes = 0;
 60 


 61   _is_complete = false;
 62   _is_success = false;
 63 
 64   _next = nullptr;
 65   _prev = nullptr;
 66 
 67   _hot_count = hot_count;
 68   _time_created = os::elapsed_counter();
 69   _time_queued = 0;
 70   _time_started = 0;
 71   _time_finished = 0;
 72   _aot_load_start = 0;
 73   _aot_load_finish = 0;
 74   _compile_reason = compile_reason;
 75   _nm_content_size = 0;


 76   _nm_insts_size = 0;
 77   _nm_total_size = 0;
 78   _failure_reason = nullptr;
 79   _failure_reason_on_C_heap = false;
 80   _training_data = nullptr;
 81   _aot_code_entry = aot_code_entry;
 82   _compile_queue = compile_queue;
 83 
 84   AbstractCompiler* comp = CompileBroker::compiler(comp_level);
 85   _compiler = comp;
 86   _directive = DirectivesStack::getMatchingDirective(method, comp);
 87 
 88   JVMCI_ONLY(_has_waiter = comp->is_jvmci();)
 89   JVMCI_ONLY(_blocking_jvmci_compile_state = nullptr;)
 90   _arena_bytes = 0;
 91 
 92   _next = nullptr;
 93 
 94   Atomic::add(&_active_tasks, 1);
 95 }
 96 
 97 CompileTask::~CompileTask() {
 98   if ((_method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder))) {
 99     JNIHandles::destroy_weak_global(_method_holder);
100   } else {
101     JNIHandles::destroy_global(_method_holder);
102   }
103   if (_failure_reason_on_C_heap && _failure_reason != nullptr) {
104     os::free((void*) _failure_reason);
105     _failure_reason = nullptr;
106     _failure_reason_on_C_heap = false;
107   }
108 
109   if (Atomic::sub(&_active_tasks, 1) == 0) {
110     MonitorLocker wait_ml(CompileTaskWait_lock);
111     wait_ml.notify_all();
112   }
113 }
114 
115 void CompileTask::wait_for_no_active_tasks() {
116   MonitorLocker locker(CompileTaskWait_lock);
117   while (Atomic::load(&_active_tasks) > 0) {
118     locker.wait();
119   }
120 }
121 
122 /**
123  * Returns the compiler for this task.
124  */
125 AbstractCompiler* CompileTask::compiler() const {
126   assert(_compiler != nullptr, "should be set");
127   return _compiler;
128 }
129 
130 // Replace weak handles by strong handles to avoid unloading during compilation.
131 CompileTask* CompileTask::select_for_compilation() {
132   if (_compile_reason == Reason_Preload) {
133     return this;
134   }
135   if (is_unloaded()) {
136     // Guard against concurrent class unloading
137     return nullptr;
138   }
139   Thread* thread = Thread::current();
140   assert(_method->method_holder()->is_loader_alive(), "should be alive");
141   Handle method_holder(thread, _method->method_holder()->klass_holder());
142   JNIHandles::destroy_weak_global(_method_holder);
143   _method_holder = JNIHandles::make_global(method_holder);
144   return this;
145 }
146 
147 void CompileTask::mark_on_stack() {
148   if (is_unloaded()) {
149     return;
150   }
151   // Mark these methods as something redefine classes cannot remove.
152   _method->set_on_stack(true);
153 }
154 
155 bool CompileTask::is_unloaded() const {
156   if (preload()) return false;
157   return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
158 }
159 
160 // RedefineClasses support
161 void CompileTask::metadata_do(MetadataClosure* f) {
162   if (is_unloaded()) {
163     return;
164   }
165   f->do_metadata(method());
166 }
167 
168 // ------------------------------------------------------------------
169 // CompileTask::print_line_on_error
170 //
171 // This function is called by fatal error handler when the thread
172 // causing troubles is a compiler thread.
173 //
174 // Do not grab any lock, do not allocate memory.
175 //
176 // Otherwise it's the same as CompileTask::print_line()
177 //
178 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
179   // print compiler name
180   st->print("%s:", compiler()->name());
181   print(st);
182 }
183 
184 // ------------------------------------------------------------------
185 // CompileTask::print_tty
186 void CompileTask::print_tty() {
187   ttyLocker ttyl;  // keep the following output all in one block
188   print(tty);
189 }
190 
191 // ------------------------------------------------------------------
192 // CompileTask::print_impl
193 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
194                              bool is_osr_method, int osr_bci, bool is_blocking, bool is_aot, bool is_preload,
195                              const char* compiler_name,
196                              const char* msg, bool short_form, bool cr,
197                              jlong time_created, jlong time_queued, jlong time_started, jlong time_finished,
198                              jlong aot_load_start, jlong aot_load_finish) {
199   if (!short_form) {
200     {
201       stringStream ss;
202       ss.print(UINT64_FORMAT, (uint64_t) tty->time_stamp().milliseconds());
203       st->print("%7s ", ss.freeze());
204     }
205     { // Time waiting to be put on queue
206       stringStream ss;
207       if (time_created != 0 && time_queued != 0) {
208         ss.print("W%.1f", TimeHelper::counter_to_millis(time_queued - time_created));
209       }
210       st->print("%7s ", ss.freeze());
211     }
212     { // Time in queue
213       stringStream ss;
214       if (time_queued != 0 && time_started != 0) {
215         ss.print("Q%.1f", TimeHelper::counter_to_millis(time_started - time_queued));
216       }
217       st->print("%7s ", ss.freeze());
218     }
219     { // Time in compilation
220       stringStream ss;
221       if (time_started != 0 && time_finished != 0) {
222         ss.print("C%.1f", TimeHelper::counter_to_millis(time_finished - time_started));
223       }
224       st->print("%7s ", ss.freeze());
225     }
226     { // Time to load from AOT code cache
227       stringStream ss;
228       if (aot_load_start != 0 && aot_load_finish != 0) {
229         ss.print("A%.1f", TimeHelper::counter_to_millis(aot_load_finish - aot_load_start));
230       }
231       st->print("%7s ", ss.freeze());
232     }
233     st->print("  ");
234   }
235 
236   // print compiler name if requested
237   if (CIPrintCompilerName) {
238     st->print("%s:", compiler_name);
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   const char aot_char       = is_aot                          ? 'A' : ' ';
257   const char preload_char   = is_preload                      ? 'P' : ' ';
258 
259   // print method attributes
260   st->print("%c%c%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char, aot_char, preload_char);
261 
262   if (TieredCompilation) {
263     if (comp_level != -1)  st->print("%d ", comp_level);
264     else                   st->print("- ");
265   }
266   st->print("     ");  // more indent
267 
268   if (method == nullptr) {
269     st->print("(method)");
270   } else {
271     method->print_short_name(st);
272     if (is_osr_method) {
273       st->print(" @ %d", osr_bci);
274     }
275     if (method->is_native())
276       st->print(" (native)");
277     else
278       st->print(" (%d bytes)", method->code_size());
279   }
280 
281   if (msg != nullptr) {
282     st->print("   %s", msg);
283   }
284   if (cr) {
285     st->cr();
286   }
287 }
288 
289 // ------------------------------------------------------------------
290 // CompileTask::print_compilation
291 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
292   bool is_osr_method = osr_bci() != InvocationEntryBci;
293   bool is_aot = is_aot_load();
294   bool is_preload = preload();
295   if (is_precompile()) {
296     // Tag aot compilation too
297     is_preload = (compile_reason() == Reason_PrecompileForPreload);
298     is_aot = !is_preload;
299   }
300   print_impl(st, is_unloaded() ? nullptr : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), is_aot, is_preload,
301              compiler()->name(), msg, short_form, cr, _time_created, _time_queued, _time_started, _time_finished, _aot_load_start, _aot_load_finish);
302 }
303 
304 // ------------------------------------------------------------------
305 // CompileTask::log_task
306 void CompileTask::log_task(xmlStream* log) {
307   Thread* thread = Thread::current();
308   methodHandle method(thread, this->method());
309   ResourceMark rm(thread);
310 
311   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
312   log->print(" compile_id='%d'", _compile_id);
313   if (_osr_bci != CompileBroker::standard_entry_bci) {
314     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
315   } else if (preload()) {
316     log->print(" compile_kind='AP'");
317   } else if (is_aot_load()) {
318     log->print(" compile_kind='A'");
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 }
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_count != 0) {
345     xtty->print(" hot_count='%d'", _hot_count);
346   }
347   xtty->stamp();
348   xtty->end_elem();
349 }
350 
351 
352 // ------------------------------------------------------------------
353 // CompileTask::log_task_start
354 void CompileTask::log_task_start(CompileLog* log) {
355   log->begin_head("task");
356   log_task(log);
357   log->stamp();
358   log->end_head();
359 }
360 
361 
362 // ------------------------------------------------------------------
363 // CompileTask::log_task_done
364 void CompileTask::log_task_done(CompileLog* log) {
365   Thread* thread = Thread::current();
366   methodHandle method(thread, this->method());
367   ResourceMark rm(thread);
368 
369   if (!_is_success) {
370     assert(_failure_reason != nullptr, "missing");
371     const char* reason = _failure_reason != nullptr ? _failure_reason : "unknown";
372     log->begin_elem("failure reason='");
373     log->text("%s", reason);
374     log->print("'");
375     log->end_elem();
376   }
377 

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