Skip to content

Commit

Permalink
8277102: Dubious PrintCompilation output
Browse files Browse the repository at this point in the history
Reviewed-by: thartmann, dnsimon
  • Loading branch information
y1yang0 committed Nov 19, 2021
1 parent 839033b commit 2f0bde1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ void nmethod::print_on(outputStream* st, const char* msg) const {
CompileTask::print(st, this, msg, /*short_form:*/ true);
st->print_cr(" (" INTPTR_FORMAT ")", p2i(this));
} else {
CompileTask::print(st, this, msg, /*short_form:*/ false, /* cr */ true, /* timestamp */ false);
CompileTask::print(st, this, msg, /*short_form:*/ false);
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/hotspot/share/compiler/compileTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,11 @@ void CompileTask::print_tty() {
// CompileTask::print_impl
void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
bool is_osr_method, int osr_bci, bool is_blocking,
const char* msg, bool short_form, bool cr, bool timestamp,
const char* msg, bool short_form, bool cr,
jlong time_queued, jlong time_started) {
if (!short_form) {
if (timestamp) {
// Print current time
st->print("%7d ", (int)tty->time_stamp().milliseconds());
}
// Print current time
st->print("%7d ", (int)tty->time_stamp().milliseconds());
if (Verbose && time_queued != 0) {
// Print time in queue and time being processed by compiler thread
jlong now = os::elapsed_counter();
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/compiler/compileTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ class CompileTask : public CHeapObj<mtCompiler> {
private:
static void print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
const char* msg = NULL, bool short_form = false, bool cr = true, bool timestamp = true,
const char* msg = NULL, bool short_form = false, bool cr = true,
jlong time_queued = 0, jlong time_started = 0);

public:
void print(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true);
void print_ul(const char* msg = NULL);
static void print(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false, bool cr = true, bool timestamp = true) {
static void print(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false, bool cr = true) {
print_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
msg, short_form, cr, timestamp);
msg, short_form, cr);
}
static void print_ul(const nmethod* nm, const char* msg = NULL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ private void check(CompileCodeTestCase testCase) {
// Therefore compare strings 2 and 3.
String str2 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
String str3 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
Asserts.assertEQ(str2, str3,
String[] str2Lines = str2.split(System.lineSeparator());
String[] str3Lines = str3.split(System.lineSeparator());
// skip the first two lines since it contains a timestamp that may vary from different invocations
// <empty-line>
// Compiled method (c2) 309 463 4 compiler.jvmci.compilerToVM.CompileCodeTestCase$Dummy::staticMethod (1 bytes)
// <empty-line>
// Compiled method (c2) 310 463 4 compiler.jvmci.compilerToVM.CompileCodeTestCase$Dummy::staticMethod (1 bytes)
for (int i = 2; i < str2Lines.length; i++) {
Asserts.assertEQ(str2Lines[i], str3Lines[i],
testCase + " : 3nd invocation returned different value from 2nd");
}
}
}

1 comment on commit 2f0bde1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.