Skip to content

Commit 3e8f1eb

Browse files
ashu-mehratstuefe
authored andcommitted
8311976: Inconsistency in usage of CITimeVerbose to generate compilation logs
Reviewed-by: kvn, thartmann
1 parent d4aacdb commit 3e8f1eb

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

src/hotspot/share/c1/c1_Compilation.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef enum {
5454
_t_codeemit,
5555
_t_codeinstall,
5656
max_phase_timers
57-
} TimerName;
57+
} TimerId;
5858

5959
static const char * timer_name[] = {
6060
"compile",
@@ -78,27 +78,29 @@ static int totalInstructionNodes = 0;
7878
class PhaseTraceTime: public TraceTime {
7979
private:
8080
CompileLog* _log;
81-
TimerName _timer;
81+
TimerId _timer_id;
82+
bool _dolog;
8283

8384
public:
84-
PhaseTraceTime(TimerName timer)
85-
: TraceTime("", &timers[timer], CITime || CITimeEach, Verbose),
86-
_log(nullptr), _timer(timer)
85+
PhaseTraceTime(TimerId timer_id)
86+
: TraceTime(timer_name[timer_id], &timers[timer_id], CITime, CITimeVerbose),
87+
_log(nullptr), _timer_id(timer_id), _dolog(CITimeVerbose)
8788
{
88-
if (Compilation::current() != nullptr) {
89+
if (_dolog) {
90+
assert(Compilation::current() != nullptr, "sanity check");
8991
_log = Compilation::current()->log();
9092
}
9193

9294
if (_log != nullptr) {
93-
_log->begin_head("phase name='%s'", timer_name[_timer]);
95+
_log->begin_head("phase name='%s'", timer_name[_timer_id]);
9496
_log->stamp();
9597
_log->end_head();
9698
}
9799
}
98100

99101
~PhaseTraceTime() {
100102
if (_log != nullptr)
101-
_log->done("phase name='%s'", timer_name[_timer]);
103+
_log->done("phase name='%s'", timer_name[_timer_id]);
102104
}
103105
};
104106

@@ -587,11 +589,11 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho
587589
, _cfg_printer_output(nullptr)
588590
#endif // PRODUCT
589591
{
590-
PhaseTraceTime timeit(_t_compile);
591592
_arena = Thread::current()->resource_area();
592593
_env->set_compiler_data(this);
593594
_exception_info_list = new ExceptionInfoList();
594595
_implicit_exception_table.set_size(0);
596+
PhaseTraceTime timeit(_t_compile);
595597
#ifndef PRODUCT
596598
if (PrintCFGToFile) {
597599
_cfg_printer_output = new CFGPrinterOutput(this);

src/hotspot/share/opto/compile.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,6 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
673673
C = this;
674674
CompileWrapper cw(this);
675675

676-
if (CITimeVerbose) {
677-
tty->print(" ");
678-
target->holder()->name()->print();
679-
tty->print(".");
680-
target->print_short_name();
681-
tty->print(" ");
682-
}
683676
TraceTime t1("Total compilation time", &_t_totalCompilation, CITime, CITimeVerbose);
684677
TraceTime t2(nullptr, &_t_methodCompilation, CITime, false);
685678

@@ -4339,35 +4332,24 @@ void Compile::record_failure(const char* reason) {
43394332

43404333
Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator)
43414334
: TraceTime(name, accumulator, CITime, CITimeVerbose),
4342-
_phase_name(name), _dolog(CITimeVerbose)
4335+
_compile(nullptr), _log(nullptr), _phase_name(name), _dolog(CITimeVerbose)
43434336
{
43444337
if (_dolog) {
4345-
C = Compile::current();
4346-
_log = C->log();
4347-
} else {
4348-
C = nullptr;
4349-
_log = nullptr;
4338+
_compile = Compile::current();
4339+
_log = _compile->log();
43504340
}
43514341
if (_log != nullptr) {
4352-
_log->begin_head("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes());
4342+
_log->begin_head("phase name='%s' nodes='%d' live='%d'", _phase_name, _compile->unique(), _compile->live_nodes());
43534343
_log->stamp();
43544344
_log->end_head();
43554345
}
43564346
}
43574347

43584348
Compile::TracePhase::~TracePhase() {
4359-
4360-
C = Compile::current();
4361-
if (_dolog) {
4362-
_log = C->log();
4363-
} else {
4364-
_log = nullptr;
4365-
}
4366-
43674349
#ifdef ASSERT
43684350
if (PrintIdealNodeCount) {
43694351
tty->print_cr("phase name='%s' nodes='%d' live='%d' live_graph_walk='%d'",
4370-
_phase_name, C->unique(), C->live_nodes(), C->count_live_nodes_by_graph_walk());
4352+
_phase_name, _compile->unique(), _compile->live_nodes(), _compile->count_live_nodes_by_graph_walk());
43714353
}
43724354

43734355
if (VerifyIdealNodeCount) {
@@ -4376,7 +4358,7 @@ Compile::TracePhase::~TracePhase() {
43764358
#endif
43774359

43784360
if (_log != nullptr) {
4379-
_log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes());
4361+
_log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, _compile->unique(), _compile->live_nodes());
43804362
}
43814363
}
43824364

src/hotspot/share/opto/compile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class Compile : public Phase {
228228
// (The time collection itself is always conditionalized on CITime.)
229229
class TracePhase : public TraceTime {
230230
private:
231-
Compile* C;
231+
Compile* _compile;
232232
CompileLog* _log;
233233
const char* _phase_name;
234234
bool _dolog;

src/hotspot/share/utilities/xmlstream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ void xmlStream::va_done(const char* format, va_list ap) {
357357
size_t kind_len;
358358
if (kind_end != nullptr) {
359359
kind_len = kind_end - kind;
360-
int n = os::snprintf(buffer, sizeof(buffer), "%.*s_done", (int)kind_len, kind);
360+
int n = os::snprintf(buffer, sizeof(buffer), "%.*s_done%s", (int)kind_len, kind, kind + kind_len);
361361
assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string");
362362
} else {
363363
kind_len = format_len;
364-
int n = os::snprintf(buffer, sizeof(buffer), "%s_done%s", kind, kind + kind_len);
364+
int n = os::snprintf(buffer, sizeof(buffer), "%s_done", kind);
365365
assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string");
366366
}
367367
// Output the trailing event with the timestamp.

0 commit comments

Comments
 (0)