@@ -51,26 +51,31 @@ CompileTask::CompileTask(int compile_id,
5151 _method_holder = JNIHandles::make_weak_global (Handle (thread, method->method_holder ()->klass_holder ()));
5252 _osr_bci = osr_bci;
5353 _is_blocking = is_blocking;
54- JVMCI_ONLY (_has_waiter = CompileBroker::compiler (comp_level)->is_jvmci ();)
55- JVMCI_ONLY (_blocking_jvmci_compile_state = nullptr ;)
5654 _comp_level = comp_level;
5755 _num_inlined_bytecodes = 0 ;
5856
5957 _is_complete = false ;
6058 _is_success = false ;
6159
6260 _hot_count = hot_count;
63- _time_queued = os::elapsed_counter ();
61+ _time_created = os::elapsed_counter ();
62+ _time_queued = 0 ;
6463 _time_started = 0 ;
64+ _time_finished = 0 ;
6565 _compile_reason = compile_reason;
6666 _nm_content_size = 0 ;
67- AbstractCompiler* comp = compiler ();
68- _directive = DirectivesStack::getMatchingDirective (method, comp);
6967 _nm_insts_size = 0 ;
7068 _nm_total_size = 0 ;
7169 _failure_reason = nullptr ;
7270 _failure_reason_on_C_heap = false ;
7371 _training_data = nullptr ;
72+
73+ AbstractCompiler* comp = CompileBroker::compiler (comp_level);
74+ _compiler = comp;
75+ _directive = DirectivesStack::getMatchingDirective (method, comp);
76+
77+ JVMCI_ONLY (_has_waiter = comp->is_jvmci ();)
78+ JVMCI_ONLY (_blocking_jvmci_compile_state = nullptr ;)
7479 _arena_bytes = 0 ;
7580
7681 _next = nullptr ;
@@ -108,7 +113,8 @@ void CompileTask::wait_for_no_active_tasks() {
108113 * Returns the compiler for this task.
109114 */
110115AbstractCompiler* CompileTask::compiler () const {
111- return CompileBroker::compiler (_comp_level);
116+ assert (_compiler != nullptr , " should be set" );
117+ return _compiler;
112118}
113119
114120// Replace weak handles by strong handles to avoid unloading during compilation.
@@ -157,7 +163,7 @@ void CompileTask::metadata_do(MetadataClosure* f) {
157163//
158164void CompileTask::print_line_on_error (outputStream* st, char * buf, int buflen) {
159165 // print compiler name
160- st->print (" %s:" , CompileBroker::compiler_name ( comp_level () ));
166+ st->print (" %s:" , compiler ()-> name ( ));
161167 print (st);
162168}
163169
@@ -168,29 +174,71 @@ void CompileTask::print_tty() {
168174 print (tty);
169175}
170176
177+ void CompileTask::print_post (outputStream* st) {
178+ bool is_osr_method = osr_bci () != InvocationEntryBci;
179+ print_impl (st, is_unloaded () ? nullptr : method (), compile_id (), comp_level (),
180+ is_osr_method, osr_bci (), is_blocking (),
181+ compiler ()->name (), nullptr , false /* short_form */ , true /* cr */ ,
182+ true /* after_compile_details */ ,
183+ _num_inlined_bytecodes, _nm_total_size, _nm_insts_size,
184+ _time_created, _time_queued, _time_started, _time_finished);
185+ }
186+
171187// ------------------------------------------------------------------
172188// CompileTask::print_impl
173189void CompileTask::print_impl (outputStream* st, Method* method, int compile_id, int comp_level,
174190 bool is_osr_method, int osr_bci, bool is_blocking,
175- const char * msg, bool short_form, bool cr,
176- jlong time_queued, jlong time_started) {
177- if (!short_form) {
191+ const char * compiler_name,
192+ const char * msg, bool short_form, bool cr, bool after_compile_details,
193+ int inlined_bytecodes, int nm_total_size, int nm_insts_size,
194+ jlong time_created, jlong time_queued, jlong time_started, jlong time_finished) {
195+ // Use stringStream to avoid breaking the line
196+ stringStream sst;
197+ if (after_compile_details) {
198+ { // Print current time
199+ stringStream ss;
200+ ss.print (UINT64_FORMAT, (uint64_t ) tty->time_stamp ().milliseconds ());
201+ sst.print (" %7s " , ss.freeze ());
202+ }
203+ { // Time waiting to be put on queue
204+ stringStream ss;
205+ if (time_created != 0 && time_queued != 0 ) {
206+ ss.print (" W%.1f" , TimeHelper::counter_to_millis (time_queued - time_created));
207+ }
208+ sst.print (" %7s " , ss.freeze ());
209+ }
210+ { // Time in queue
211+ stringStream ss;
212+ if (time_queued != 0 && time_started != 0 ) {
213+ ss.print (" Q%.1f" , TimeHelper::counter_to_millis (time_started - time_queued));
214+ }
215+ sst.print (" %7s " , ss.freeze ());
216+ }
217+ { // Time in compilation
218+ stringStream ss;
219+ if (time_started != 0 && time_finished != 0 ) {
220+ ss.print (" C%.1f" , TimeHelper::counter_to_millis (time_finished - time_started));
221+ }
222+ sst.print (" %7s " , ss.freeze ());
223+ }
224+ } else if (!short_form) {
178225 // Print current time
179- st-> print (UINT64_FORMAT " " , (uint64_t ) tty->time_stamp ().milliseconds ());
226+ sst. print (UINT64_FORMAT " " , (uint64_t ) tty->time_stamp ().milliseconds ());
180227 if (Verbose && time_queued != 0 ) {
181228 // Print time in queue and time being processed by compiler thread
182229 jlong now = os::elapsed_counter ();
183- st-> print (" %.0f " , TimeHelper::counter_to_millis (now-time_queued));
230+ sst. print (" %.0f " , TimeHelper::counter_to_millis (now-time_queued));
184231 if (time_started != 0 ) {
185- st-> print (" %.0f " , TimeHelper::counter_to_millis (now-time_started));
232+ sst. print (" %.0f " , TimeHelper::counter_to_millis (now-time_started));
186233 }
187234 }
188235 }
236+
189237 // print compiler name if requested
190238 if (CIPrintCompilerName) {
191- st-> print (" %s:" , CompileBroker:: compiler_name(comp_level) );
239+ sst. print (" %s:" , compiler_name);
192240 }
193- st-> print (" %4d " , compile_id); // print compilation number
241+ sst. print (" %4d " , compile_id); // print compilation number
194242
195243 bool is_synchronized = false ;
196244 bool has_exception_handler = false ;
@@ -208,40 +256,52 @@ void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, i
208256 const char native_char = is_native ? ' n' : ' ' ;
209257
210258 // print method attributes
211- st-> print (" %c%c%c%c%c " , compile_type, sync_char, exception_char, blocking_char, native_char);
259+ sst. print (" %c%c%c%c%c " , compile_type, sync_char, exception_char, blocking_char, native_char);
212260
213261 if (TieredCompilation) {
214- if (comp_level != -1 ) st-> print (" %d " , comp_level);
215- else st-> print (" - " );
262+ if (comp_level != -1 ) sst. print (" %d " , comp_level);
263+ else sst. print (" - " );
216264 }
217- st-> print (" " ); // more indent
265+ sst. print (" " ); // more indent
218266
219267 if (method == nullptr ) {
220- st-> print (" (method)" );
268+ sst. print (" (method)" );
221269 } else {
222- method->print_short_name (st);
270+ if (after_compile_details) {
271+ sst.print (" %s" , method->name_and_sig_as_C_string (true /* use_double_colon */ ));
272+ } else {
273+ method->print_short_name (&sst);
274+ }
223275 if (is_osr_method) {
224- st-> print (" @ %d" , osr_bci);
276+ sst. print (" @ %d" , osr_bci);
225277 }
226- if (method->is_native ())
227- st->print (" (native)" );
228- else
229- st->print (" (%d bytes)" , method->code_size ());
278+ if (method->is_native ()) {
279+ sst.print (" (native)" );
280+ } else {
281+ sst.print (" (%d bytes)" , method->code_size ());
282+ }
283+ }
284+ if (after_compile_details) {
285+ sst.print (" (inlined %d)" , inlined_bytecodes);
286+ sst.print (" (size %d/%d)" , nm_total_size, nm_insts_size);
230287 }
231288
232289 if (msg != nullptr ) {
233- st-> print (" %s" , msg);
290+ sst. print (" %s" , msg);
234291 }
235292 if (cr) {
236- st-> cr ();
293+ sst. cr ();
237294 }
295+ st->print (" %s" ,sst.freeze ());
238296}
239297
240298// ------------------------------------------------------------------
241299// CompileTask::print_compilation
242300void CompileTask::print (outputStream* st, const char * msg, bool short_form, bool cr) {
243301 bool is_osr_method = osr_bci () != InvocationEntryBci;
244- 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);
302+ print_impl (st, is_unloaded () ? nullptr : method (), compile_id (), comp_level (),
303+ is_osr_method, osr_bci (), is_blocking (),
304+ compiler ()->name (), msg, short_form, cr);
245305}
246306
247307// ------------------------------------------------------------------
@@ -435,6 +495,7 @@ void CompileTask::print_ul(const nmethod* nm, const char* msg) {
435495 nm->comp_level (), nm->is_osr_method (),
436496 nm->is_osr_method () ? nm->osr_entry_bci () : -1 ,
437497 /* is_blocking*/ false ,
498+ nm->compiler_name (),
438499 msg, /* short form */ true , /* cr */ true );
439500 }
440501}
0 commit comments