Skip to content

Commit 3fb808e

Browse files
committedSep 22, 2023
Cleaned up -Xlog:scc to print to the specified LogStream instead of tty

File tree

4 files changed

+60
-51
lines changed

4 files changed

+60
-51
lines changed
 

‎src/hotspot/share/code/SCCache.cpp

+54-45
Original file line numberDiff line numberDiff line change
@@ -1278,21 +1278,22 @@ bool SCCache::write_klass(Klass* klass) {
12781278
dest[total_length - 1] = '\0';
12791279
LogTarget(Info, scc, loader) log;
12801280
if (log.is_enabled()) {
1281+
LogStream ls(log);
12811282
oop loader = klass->class_loader();
12821283
oop domain = klass->protection_domain();
1283-
tty->print("Class %s loader: ", dest);
1284+
ls.print("Class %s loader: ", dest);
12841285
if (loader == nullptr) {
1285-
tty->print("nullptr");
1286+
ls.print("nullptr");
12861287
} else {
1287-
loader->print_value_on(tty);
1288+
loader->print_value_on(&ls);
12881289
}
1289-
tty->print(" domain: ");
1290+
ls.print(" domain: ");
12901291
if (domain == nullptr) {
1291-
tty->print("nullptr");
1292+
ls.print("nullptr");
12921293
} else {
1293-
domain->print_value_on(tty);
1294+
domain->print_value_on(&ls);
12941295
}
1295-
tty->cr();
1296+
ls.cr();
12961297
}
12971298
n = write_bytes(&name_length, sizeof(int));
12981299
if (n != sizeof(int)) {
@@ -1382,21 +1383,22 @@ bool SCCache::write_method(Method* method) {
13821383

13831384
LogTarget(Info, scc, loader) log;
13841385
if (log.is_enabled()) {
1386+
LogStream ls(log);
13851387
oop loader = klass->class_loader();
13861388
oop domain = klass->protection_domain();
1387-
tty->print("Holder %s loader: ", dest);
1389+
ls.print("Holder %s loader: ", dest);
13881390
if (loader == nullptr) {
1389-
tty->print("nullptr");
1391+
ls.print("nullptr");
13901392
} else {
1391-
loader->print_value_on(tty);
1393+
loader->print_value_on(&ls);
13921394
}
1393-
tty->print(" domain: ");
1395+
ls.print(" domain: ");
13941396
if (domain == nullptr) {
1395-
tty->print("nullptr");
1397+
ls.print("nullptr");
13961398
} else {
1397-
domain->print_value_on(tty);
1399+
domain->print_value_on(&ls);
13981400
}
1399-
tty->cr();
1401+
ls.cr();
14001402
}
14011403

14021404
n = write_bytes(&holder_length, sizeof(int));
@@ -1454,7 +1456,8 @@ bool SCCReader::read_relocations(CodeBuffer* buffer, CodeBuffer* orig_buffer,
14541456
set_read_position(code_offset);
14551457
LogTarget(Info, scc, reloc) log;
14561458
if (log.is_enabled()) {
1457-
tty->print_cr("======== read code section %d relocations [%d]:", i, reloc_count);
1459+
LogStream ls(log);
1460+
ls.print_cr("======== read code section %d relocations [%d]:", i, reloc_count);
14581461
}
14591462
RelocIterator iter(cs);
14601463
int j = 0;
@@ -1732,7 +1735,8 @@ bool SCCache::write_relocations(CodeBuffer* buffer, uint& all_reloc_size) {
17321735
}
17331736
LogTarget(Info, scc, reloc) log;
17341737
if (log.is_enabled()) {
1735-
tty->print_cr("======== write code section %d relocations [%d]:", i, reloc_count);
1738+
LogStream ls(log);
1739+
ls.print_cr("======== write code section %d relocations [%d]:", i, reloc_count);
17361740
}
17371741
// Collect additional data
17381742
RelocIterator iter(cs);
@@ -2188,15 +2192,16 @@ bool SCCReader::read_oops(OopRecorder* oop_recorder, ciMethod* target) {
21882192
}
21892193
LogTarget(Debug, scc, oops) log;
21902194
if (log.is_enabled()) {
2191-
tty->print("%d: " INTPTR_FORMAT " ", i, p2i(jo));
2195+
LogStream ls(log);
2196+
ls.print("%d: " INTPTR_FORMAT " ", i, p2i(jo));
21922197
if (jo == (jobject)Universe::non_oop_word()) {
2193-
tty->print("non-oop word");
2198+
ls.print("non-oop word");
21942199
} else if (jo == nullptr) {
2195-
tty->print("nullptr-oop");
2200+
ls.print("nullptr-oop");
21962201
} else {
2197-
JNIHandles::resolve(jo)->print_value_on(tty);
2202+
JNIHandles::resolve(jo)->print_value_on(&ls);
21982203
}
2199-
tty->cr();
2204+
ls.cr();
22002205
}
22012206
}
22022207
}
@@ -2268,15 +2273,16 @@ bool SCCReader::read_metadata(OopRecorder* oop_recorder, ciMethod* target) {
22682273
}
22692274
LogTarget(Debug, scc, metadata) log;
22702275
if (log.is_enabled()) {
2271-
tty->print("%d: " INTPTR_FORMAT " ", i, p2i(m));
2276+
LogStream ls(log);
2277+
ls.print("%d: " INTPTR_FORMAT " ", i, p2i(m));
22722278
if (m == (Metadata*)Universe::non_oop_word()) {
2273-
tty->print("non-metadata word");
2279+
ls.print("non-metadata word");
22742280
} else if (m == nullptr) {
2275-
tty->print("nullptr-oop");
2281+
ls.print("nullptr-oop");
22762282
} else {
2277-
Metadata::print_value_on_maybe_null(tty, m);
2283+
Metadata::print_value_on_maybe_null(&ls, m);
22782284
}
2279-
tty->cr();
2285+
ls.cr();
22802286
}
22812287
}
22822288
}
@@ -2402,15 +2408,16 @@ bool SCCache::write_oops(OopRecorder* oop_recorder) {
24022408
jobject jo = oop_recorder->oop_at(i);
24032409
LogTarget(Info, scc, oops) log;
24042410
if (log.is_enabled()) {
2405-
tty->print("%d: " INTPTR_FORMAT " ", i, p2i(jo));
2411+
LogStream ls(log);
2412+
ls.print("%d: " INTPTR_FORMAT " ", i, p2i(jo));
24062413
if (jo == (jobject)Universe::non_oop_word()) {
2407-
tty->print("non-oop word");
2414+
ls.print("non-oop word");
24082415
} else if (jo == nullptr) {
2409-
tty->print("nullptr-oop");
2416+
ls.print("nullptr-oop");
24102417
} else {
2411-
JNIHandles::resolve(jo)->print_value_on(tty);
2418+
JNIHandles::resolve(jo)->print_value_on(&ls);
24122419
}
2413-
tty->cr();
2420+
ls.cr();
24142421
}
24152422
if (!write_oop(jo)) {
24162423
return false;
@@ -2471,15 +2478,16 @@ bool SCCache::write_metadata(OopRecorder* oop_recorder) {
24712478
Metadata* m = oop_recorder->metadata_at(i);
24722479
LogTarget(Debug, scc, metadata) log;
24732480
if (log.is_enabled()) {
2474-
tty->print("%d: " INTPTR_FORMAT " ", i, p2i(m));
2481+
LogStream ls(log);
2482+
ls.print("%d: " INTPTR_FORMAT " ", i, p2i(m));
24752483
if (m == (Metadata*)Universe::non_oop_word()) {
2476-
tty->print("non-metadata word");
2484+
ls.print("non-metadata word");
24772485
} else if (m == nullptr) {
2478-
tty->print("nillptr-oop");
2486+
ls.print("nillptr-oop");
24792487
} else {
2480-
Metadata::print_value_on_maybe_null(tty, m);
2488+
Metadata::print_value_on_maybe_null(&ls, m);
24812489
}
2482-
tty->cr();
2490+
ls.cr();
24832491
}
24842492
if (!write_metadata(m)) {
24852493
return false;
@@ -2791,23 +2799,24 @@ SCCEntry* SCCache::store_nmethod(const methodHandle& method,
27912799

27922800
LogTarget(Info, scc, loader) log;
27932801
if (log.is_enabled()) {
2802+
LogStream ls(log);
27942803
oop loader = holder->class_loader();
27952804
oop domain = holder->protection_domain();
2796-
tty->print("Holder: ");
2797-
holder->print_value_on(tty);
2798-
tty->print(" loader: ");
2805+
ls.print("Holder: ");
2806+
holder->print_value_on(&ls);
2807+
ls.print(" loader: ");
27992808
if (loader == nullptr) {
2800-
tty->print("nullptr");
2809+
ls.print("nullptr");
28012810
} else {
2802-
loader->print_value_on(tty);
2811+
loader->print_value_on(&ls);
28032812
}
2804-
tty->print(" domain: ");
2813+
ls.print(" domain: ");
28052814
if (domain == nullptr) {
2806-
tty->print("nullptr");
2815+
ls.print("nullptr");
28072816
} else {
2808-
domain->print_value_on(tty);
2817+
domain->print_value_on(&ls);
28092818
}
2810-
tty->cr();
2819+
ls.cr();
28112820
}
28122821
name_offset = cache->_write_position - entry_position;
28132822
name_size = (uint)strlen(name) + 1; // Includes '/0'

‎test/hotspot/jtreg/premain/javac/javac-test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ for i in $TESTS; do
428428
fi
429429

430430
#----------------------------------------------------------------------
431-
CMD="$JVM_AND_ARGS $EXTRA_ARGS -Xlog:scc*=trace:file=javac.scc-store.log::filesize=0 \
431+
CMD="$JVM_AND_ARGS $EXTRA_ARGS -Xlog:scc*=warning:file=javac.scc-store.log::filesize=0 \
432432
-XX:SharedArchiveFile=$JSA2 $X2 -XX:+StoreCachedCode -XX:CachedCodeFile=${JSA2}-sc -XX:CachedCodeMaxSize=100M \
433433
-cp JavacBench.jar JavacBench $LOOPS"
434434
test-info "${STEP4}Run with $JSA2 and generate AOT code" &&
@@ -439,7 +439,7 @@ for i in $TESTS; do
439439
fi
440440

441441
#----------------------------------------------------------------------
442-
CMD="$JVM_AND_ARGS $EXTRA_ARGS -Xlog:scc*=trace:file=javac.scc-load.log::filesize=0 \
442+
CMD="$JVM_AND_ARGS $EXTRA_ARGS -Xlog:scc*=warning:file=javac.scc-load.log::filesize=0 \
443443
-XX:SharedArchiveFile=$JSA2 $X2 -XX:+LoadCachedCode -XX:CachedCodeFile=${JSA2}-sc \
444444
-cp JavacBench.jar JavacBench $LOOPS"
445445
test-info "${STEP5}Final production run: with $JSA2 and load AOT code" &&

‎test/hotspot/jtreg/premain/jmh/run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ do_test "(STEP 3 of 5) Run with $APP-static.jsa and dump profile in $APP-dynamic
9191

9292
do_test "(STEP 4 of 5) Run with $APP-dynamic.jsa and generate AOT code" \
9393
$JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+StoreCachedCode \
94-
-Xlog:scc*=trace:file=$APP-store-sc.log \
94+
-Xlog:scc*=warning:file=$APP-store-sc.log \
9595
-XX:CachedCodeFile=$APP-dynamic.jsa-sc -XX:CachedCodeMaxSize=100M $CMDLINE
9696

9797
do_test "(STEP 5 of 5) Final production run: with $APP-dynamic.jsa and load AOT code" \
9898
$JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+LoadCachedCode \
99-
-Xlog:scc*=trace:file=$APP-load-sc.log \
99+
-Xlog:scc*=warning:file=$APP-load-sc.log \
100100
-XX:CachedCodeFile=$APP-dynamic.jsa-sc $CMDLINE

‎test/hotspot/jtreg/premain/lib/premain-run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ do_test "(STEP 3 of 5) Run with $APP-static.jsa and dump profile in $APP-dynamic
9292

9393
do_test "(STEP 4 of 5) Run with $APP-dynamic.jsa and generate AOT code" \
9494
$JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+StoreCachedCode \
95-
-Xlog:scc*=trace:file=$APP-store-sc.log::filesize=0 \
95+
-Xlog:scc*=warning:file=$APP-store-sc.log::filesize=0 \
9696
-XX:CachedCodeFile=$APP-dynamic.jsa-sc -XX:CachedCodeMaxSize=100M $CMDLINE
9797

9898
do_test "(STEP 5 of 5) Final production run: with $APP-dynamic.jsa and load AOT code" \
9999
$JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+LoadCachedCode \
100-
-Xlog:scc*=trace:file=$APP-load-sc.log::filesize=0 \
100+
-Xlog:scc*=warning:file=$APP-load-sc.log::filesize=0 \
101101
-XX:CachedCodeFile=$APP-dynamic.jsa-sc $CMDLINE

0 commit comments

Comments
 (0)
Please sign in to comment.