< prev index next >

src/hotspot/share/compiler/compileTask.cpp

Print this page

 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 

 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 int CompileTask::_active_tasks = 0;
 41 
 42 /**
 43  * Allocate a CompileTask, from the free list if possible.
 44  */
 45 CompileTask* CompileTask::allocate() {
 46   MonitorLocker 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.");
 59   task->set_is_free(false);
 60   _active_tasks++;
 61   return task;
 62 }
 63 
 64 /**
 65 * Add a task to the free list.
 66 */
 67 void CompileTask::free(CompileTask* task) {
 68   MonitorLocker locker(CompileTaskAlloc_lock);
 69   if (!task->is_free()) {
 70     assert(!task->lock()->is_locked(), "Should not be locked when freed");
 71     if ((task->_method_holder != nullptr && JNIHandles::is_weak_global_handle(task->_method_holder))) {
 72       JNIHandles::destroy_weak_global(task->_method_holder);
 73     } else {
 74       JNIHandles::destroy_global(task->_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     _active_tasks--;
 86     if (_active_tasks == 0) {
 87       locker.notify_all();
 88     }
 89   }
 90 }
 91 
 92 void CompileTask::wait_for_no_active_tasks() {
 93   MonitorLocker locker(CompileTaskAlloc_lock);
 94   while (_active_tasks > 0) {
 95     locker.wait();
 96   }
 97 }
 98 
 99 void CompileTask::initialize(int compile_id,
100                              const methodHandle& method,
101                              int osr_bci,
102                              int comp_level,
103                              int hot_count,
104                              AOTCodeEntry* aot_code_entry,
105                              CompileTask::CompileReason compile_reason,
106                              CompileQueue* compile_queue,
107                              bool requires_online_compilation,
108                              bool is_blocking) {
109   assert(!_lock->is_locked(), "bad locking");
110 
111   Thread* thread = Thread::current();
112   _compile_id = compile_id;
113   _method = method();
114   _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
115   _osr_bci = osr_bci;
116   _requires_online_compilation = requires_online_compilation;
117   _is_blocking = is_blocking;


118   _comp_level = comp_level;
119   _num_inlined_bytecodes = 0;
120 
121   _waiting_count = 0;
122 
123   _is_complete = false;
124   _is_success = false;
125 
126   _next = nullptr;
127   _prev = nullptr;
128 
129   _hot_count = hot_count;
130   _time_created = os::elapsed_counter();
131   _time_queued = 0;
132   _time_started = 0;
133   _time_finished = 0;
134   _aot_load_start = 0;
135   _aot_load_finish = 0;
136   _compile_reason = compile_reason;
137   _nm_content_size = 0;


138   _nm_insts_size = 0;
139   _nm_total_size = 0;
140   _failure_reason = nullptr;
141   _failure_reason_on_C_heap = false;
142   _training_data = nullptr;
143   _aot_code_entry = aot_code_entry;
144   _compile_queue = compile_queue;
145 
146   AbstractCompiler* comp = CompileBroker::compiler(comp_level);
147 #if INCLUDE_JVMCI
148   if (comp->is_jvmci() && CompileBroker::compiler3() != nullptr) {
149     assert(_method != nullptr, "sanity");
150     if (((JVMCICompiler*)comp)->force_comp_at_level_simple(method)) {
151       comp = CompileBroker::compiler3();
152     }
153   }
154 #endif
155   _compiler = comp;
156   _directive = DirectivesStack::getMatchingDirective(method, comp);
157 
158   JVMCI_ONLY(_has_waiter = comp->is_jvmci();)
159   JVMCI_ONLY(_blocking_jvmci_compile_state = nullptr;)
160   _arena_bytes = 0;
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   _method_holder = JNIHandles::make_global(method_holder);
187   return this;
188 }
189 
190 void CompileTask::mark_on_stack() {
191   if (is_unloaded()) {
192     return;
193   }
194   // Mark these methods as something redefine classes cannot remove.
195   _method->set_on_stack(true);
196 }
197 
198 bool CompileTask::is_unloaded() const {
199   if (preload()) return false;
200   return _method_holder != nullptr && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_weak_global_cleared(_method_holder);
201 }
202 
203 // RedefineClasses support
204 void CompileTask::metadata_do(MetadataClosure* f) {
205   if (is_unloaded()) {
206     return;
207   }
208   f->do_metadata(method());
209 }
210 
211 // ------------------------------------------------------------------
212 // CompileTask::print_line_on_error
213 //
214 // This function is called by fatal error handler when the thread
215 // causing troubles is a compiler thread.
216 //
217 // Do not grab any lock, do not allocate memory.
218 //
219 // Otherwise it's the same as CompileTask::print_line()
220 //
221 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
222   // print compiler name
223   st->print("%s:", compiler()->name());
224   print(st);
225 }
226 
227 // ------------------------------------------------------------------
228 // CompileTask::print_tty
229 void CompileTask::print_tty() {
230   ttyLocker ttyl;  // keep the following output all in one block
231   print(tty);
232 }
233 
234 // ------------------------------------------------------------------
235 // CompileTask::print_impl
236 void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
237                              bool is_osr_method, int osr_bci, bool is_blocking, bool is_aot, bool is_preload,
238                              const char* compiler_name,
239                              const char* msg, bool short_form, bool cr,
240                              jlong time_created, jlong time_queued, jlong time_started, jlong time_finished,
241                              jlong aot_load_start, jlong aot_load_finish) {
242   if (!short_form) {
243     {
244       stringStream ss;
245       ss.print(UINT64_FORMAT, (uint64_t) tty->time_stamp().milliseconds());
246       st->print("%7s ", ss.freeze());
247     }
248     { // Time waiting to be put on queue
249       stringStream ss;
250       if (time_created != 0 && time_queued != 0) {
251         ss.print("W%.1f", TimeHelper::counter_to_millis(time_queued - time_created));
252       }
253       st->print("%7s ", ss.freeze());
254     }
255     { // Time in queue
256       stringStream ss;
257       if (time_queued != 0 && time_started != 0) {
258         ss.print("Q%.1f", TimeHelper::counter_to_millis(time_started - time_queued));
259       }
260       st->print("%7s ", ss.freeze());
261     }
262     { // Time in compilation
263       stringStream ss;
264       if (time_started != 0 && time_finished != 0) {
265         ss.print("C%.1f", TimeHelper::counter_to_millis(time_finished - time_started));
266       }
267       st->print("%7s ", ss.freeze());
268     }
269     { // Time to load from AOT code cache
270       stringStream ss;
271       if (aot_load_start != 0 && aot_load_finish != 0) {
272         ss.print("A%.1f", TimeHelper::counter_to_millis(aot_load_finish - aot_load_start));
273       }
274       st->print("%7s ", ss.freeze());
275     }
276     st->print("  ");
277   }
278 
279   // print compiler name if requested
280   if (CIPrintCompilerName) {
281     st->print("%s:", compiler_name);
282   }
283   st->print("%4d ", compile_id);    // print compilation number
284 
285   bool is_synchronized = false;
286   bool has_exception_handler = false;
287   bool is_native = false;
288   if (method != nullptr) {
289     is_synchronized       = method->is_synchronized();
290     has_exception_handler = method->has_exception_handler();
291     is_native             = method->is_native();
292   }
293   // method attributes
294   const char compile_type   = is_osr_method                   ? '%' : ' ';
295   const char sync_char      = is_synchronized                 ? 's' : ' ';
296   const char exception_char = has_exception_handler           ? '!' : ' ';
297   const char blocking_char  = is_blocking                     ? 'b' : ' ';
298   const char native_char    = is_native                       ? 'n' : ' ';
299   const char aot_char       = is_aot                          ? 'A' : ' ';
300   const char preload_char   = is_preload                      ? 'P' : ' ';
301 
302   // print method attributes
303   st->print("%c%c%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char, aot_char, preload_char);
304 
305   if (TieredCompilation) {
306     if (comp_level != -1)  st->print("%d ", comp_level);
307     else                   st->print("- ");
308   }
309   st->print("     ");  // more indent
310 
311   if (method == nullptr) {
312     st->print("(method)");
313   } else {
314     method->print_short_name(st);
315     if (is_osr_method) {
316       st->print(" @ %d", osr_bci);
317     }
318     if (method->is_native())
319       st->print(" (native)");
320     else
321       st->print(" (%d bytes)", method->code_size());
322   }
323 
324   if (msg != nullptr) {
325     st->print("   %s", msg);
326   }
327   if (cr) {
328     st->cr();
329   }
330 }
331 
332 // ------------------------------------------------------------------
333 // CompileTask::print_compilation
334 void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
335   bool is_osr_method = osr_bci() != InvocationEntryBci;
336   print_impl(st, is_unloaded() ? nullptr : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), is_aot(), preload(),
337              compiler()->name(), msg, short_form, cr, _time_created, _time_queued, _time_started, _time_finished, _aot_load_start, _aot_load_finish);
338 }
339 
340 // ------------------------------------------------------------------
341 // CompileTask::log_task
342 void CompileTask::log_task(xmlStream* log) {
343   Thread* thread = Thread::current();
344   methodHandle method(thread, this->method());
345   ResourceMark rm(thread);
346 
347   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
348   log->print(" compile_id='%d'", _compile_id);
349   if (_osr_bci != CompileBroker::standard_entry_bci) {
350     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
351   } // else compile_kind='c2c'
352   if (!method.is_null())  log->method(method());
353   if (_osr_bci != CompileBroker::standard_entry_bci) {
354     log->print(" osr_bci='%d'", _osr_bci);
355   }
356   if (_comp_level != CompilationPolicy::highest_compile_level()) {
357     log->print(" level='%d'", _comp_level);
358   }
359   if (_is_blocking) {
360     log->print(" blocking='1'");
361   }

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

511   } else if (result == InliningResult::FAILURE) {
512     st->print("   %s", "failed to inline");
513   }
514 }
515 
516 void CompileTask::print_ul(const char* msg){
517   LogTarget(Info, jit, compilation) lt;
518   if (lt.is_enabled()) {
519     LogStream ls(lt);
520     print(&ls, msg, /* short form */ true, /* cr */ true);
521   }
522 }
523 
524 void CompileTask::print_ul(const nmethod* nm, const char* msg) {
525   LogTarget(Info, jit, compilation) lt;
526   if (lt.is_enabled()) {
527     LogStream ls(lt);
528     print_impl(&ls, nm->method(), nm->compile_id(),
529                nm->comp_level(), nm->is_osr_method(),
530                nm->is_osr_method() ? nm->osr_entry_bci() : -1,
531                /*is_blocking*/ false, nm->aot_code_entry() != nullptr,
532                nm->preloaded(), nm->compiler_name(),
533                msg, /* short form */ true, /* cr */ true);
534   }
535 }
536 
537 void CompileTask::print_inlining_ul(ciMethod* method, int inline_level, int bci, InliningResult result, const char* msg) {
538   LogTarget(Debug, jit, inlining) lt;
539   if (lt.is_enabled()) {
540     LogStream ls(lt);
541     print_inlining_inner(&ls, method, inline_level, bci, result, msg);
542   }
543 }
544 
< prev index next >