Skip to content

Commit 397bae2

Browse files
committed
8255860: Clean up CDS logging related to lambda
Reviewed-by: ccheung, minqi
1 parent 97a81ce commit 397bae2

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

src/hotspot/share/classfile/classListParser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ bool ClassListParser::is_matching_cp_entry(constantPoolHandle &pool, int cp_inde
461461
}
462462

463463
void ClassListParser::resolve_indy(Symbol* class_name_symbol, TRAPS) {
464-
465464
Handle class_loader(THREAD, SystemDictionary::java_system_loader());
466465
Handle protection_domain;
467466
Klass* klass = SystemDictionary::resolve_or_fail(class_name_symbol, class_loader, protection_domain, true, THREAD); // FIXME should really be just a lookup
@@ -482,8 +481,8 @@ void ClassListParser::resolve_indy(Symbol* class_name_symbol, TRAPS) {
482481
BootstrapInfo bootstrap_specifier(pool, pool_index, indy_index);
483482
Handle bsm = bootstrap_specifier.resolve_bsm(THREAD);
484483
if (!SystemDictionaryShared::is_supported_invokedynamic(&bootstrap_specifier)) {
485-
tty->print_cr("is_supported_invokedynamic check failed for cp_index %d", pool_index);
486-
continue;
484+
log_debug(cds, lambda)("is_supported_invokedynamic check failed for cp_index %d", pool_index);
485+
continue;
487486
}
488487
if (is_matching_cp_entry(pool, pool_index, THREAD)) {
489488
found = true;

src/hotspot/share/classfile/lambdaFormInvokers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ void LambdaFormInvokers::reload_class(char* name, ClassFileStream& st, TRAPS) {
147147

148148
// exclude the existing class from dump
149149
SystemDictionaryShared::set_excluded(InstanceKlass::cast(klass));
150-
log_info(cds)("Replaced class %s, old: %p new: %p", name, klass, result);
150+
log_info(cds, lambda)("Replaced class %s, old: %p new: %p", name, klass, result);
151151
}

src/hotspot/share/classfile/systemDictionaryShared.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "interpreter/bootstrapInfo.hpp"
4141
#include "jfr/jfrEvents.hpp"
4242
#include "logging/log.hpp"
43+
#include "logging/logStream.hpp"
4344
#include "memory/allocation.hpp"
4445
#include "memory/archiveUtils.hpp"
4546
#include "memory/dynamicArchive.hpp"
@@ -1924,26 +1925,28 @@ bool SystemDictionaryShared::check_linking_constraints(InstanceKlass* klass, TRA
19241925
}
19251926

19261927
bool SystemDictionaryShared::is_supported_invokedynamic(BootstrapInfo* bsi) {
1928+
LogTarget(Debug, cds, lambda) log;
19271929
if (bsi->arg_values() == NULL || !bsi->arg_values()->is_objArray()) {
1928-
DEBUG_ONLY(
1929-
tty->print_cr("bsi check failed");
1930-
tty->print_cr(" bsi->arg_values().not_null() %d", bsi->arg_values().not_null());
1930+
if (log.is_enabled()) {
1931+
LogStream log_stream(log);
1932+
log.print("bsi check failed");
1933+
log.print(" bsi->arg_values().not_null() %d", bsi->arg_values().not_null());
19311934
if (bsi->arg_values().not_null()) {
1932-
tty->print_cr(" bsi->arg_values()->is_objArray() %d", bsi->arg_values()->is_objArray());
1933-
bsi->print();
1935+
log.print(" bsi->arg_values()->is_objArray() %d", bsi->arg_values()->is_objArray());
1936+
bsi->print_msg_on(&log_stream);
19341937
}
1935-
)
1938+
}
19361939
return false;
19371940
}
19381941

19391942
Handle bsm = bsi->bsm();
19401943
if (bsm.is_null() || !java_lang_invoke_DirectMethodHandle::is_instance(bsm())) {
1941-
DEBUG_ONLY(
1942-
tty->print_cr("bsm check failed");
1943-
tty->print_cr(" bsm.is_null() %d", bsm.is_null());
1944-
tty->print_cr(" java_lang_invoke_DirectMethodHandle::is_instance(bsm()) %d",
1944+
if (log.is_enabled()) {
1945+
log.print("bsm check failed");
1946+
log.print(" bsm.is_null() %d", bsm.is_null());
1947+
log.print(" java_lang_invoke_DirectMethodHandle::is_instance(bsm()) %d",
19451948
java_lang_invoke_DirectMethodHandle::is_instance(bsm()));
1946-
)
1949+
}
19471950
return false;
19481951
}
19491952

@@ -1954,13 +1957,13 @@ bool SystemDictionaryShared::is_supported_invokedynamic(BootstrapInfo* bsi) {
19541957
method->signature()->equals("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;")) {
19551958
return true;
19561959
} else {
1957-
DEBUG_ONLY(
1960+
if (log.is_enabled()) {
19581961
ResourceMark rm;
1959-
tty->print_cr("method check failed");
1960-
tty->print_cr(" klass_name() %s", method->klass_name()->as_C_string());
1961-
tty->print_cr(" name() %s", method->name()->as_C_string());
1962-
tty->print_cr(" signature() %s", method->signature()->as_C_string());
1963-
)
1962+
log.print("method check failed");
1963+
log.print(" klass_name() %s", method->klass_name()->as_C_string());
1964+
log.print(" name() %s", method->name()->as_C_string());
1965+
log.print(" signature() %s", method->signature()->as_C_string());
1966+
}
19641967
}
19651968

19661969
return false;

src/hotspot/share/logging/logTag.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
LOG_TAG(jit) \
9696
LOG_TAG(jni) \
9797
LOG_TAG(jvmti) \
98+
LOG_TAG(lambda) \
9899
LOG_TAG(library) \
99100
LOG_TAG(liveness) \
100101
LOG_TAG(load) /* Trace all classes loaded */ \

test/hotspot/jtreg/runtime/cds/appcds/BadBSM.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static void main(String[] args) throws Exception {
4242

4343
OutputAnalyzer out = TestCommon.dump(appJar,
4444
TestCommon.list("WrongBSM",
45-
"@lambda-proxy WrongBSM 7"));
45+
"@lambda-proxy WrongBSM 7"),
46+
"-Xlog:cds+lambda=debug");
4647
out.shouldHaveExitValue(0);
4748
out.shouldContain( "is_supported_invokedynamic check failed for cp_index 7");
4849
}

test/hotspot/jtreg/runtime/cds/appcds/ClassListFormatBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void dumpShouldFail(String caseHelp, String appJar, String[] appClasses,
4141
System.out.println("------------------------------");
4242

4343
try {
44-
OutputAnalyzer output = TestCommon.dump(appJar, appClasses);
44+
OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds+lambda=debug");
4545
output.shouldHaveExitValue(1);
4646
for (String s : expected_errors) {
4747
output.shouldContain(s);
@@ -63,7 +63,7 @@ static void dumpShouldPass(String caseHelp, String appJar, String[] appClasses,
6363
System.out.println("------------------------------");
6464

6565
try {
66-
OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds");
66+
OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds", "-Xlog:cds+lambda=debug");
6767
output.shouldHaveExitValue(0);
6868
output.shouldContain("Dumping");
6969
for (String s : expected_msgs) {

0 commit comments

Comments
 (0)