Skip to content

Commit 2483340

Browse files
committed
8352579: Refactor CDS legacy optimization for lambda proxy classes
Reviewed-by: ccheung, matsaave
1 parent 1397ee5 commit 2483340

18 files changed

+607
-508
lines changed

src/hotspot/share/cds/aotArtifactFinder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "cds/aotClassInitializer.hpp"
2828
#include "cds/dumpTimeClassInfo.inline.hpp"
2929
#include "cds/heapShared.hpp"
30+
#include "cds/lambdaProxyClassDictionary.hpp"
3031
#include "classfile/systemDictionaryShared.hpp"
3132
#include "logging/log.hpp"
3233
#include "memory/metaspaceClosure.hpp"
@@ -114,13 +115,13 @@ void AOTArtifactFinder::find_artifacts() {
114115
// All non-hidden classes are always included into the AOT cache
115116
add = true;
116117
} else {
117-
if (!CDSConfig::is_dumping_invokedynamic()) {
118+
if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
118119
// Legacy support of lambda proxies -- these are always included into the AOT cache
119-
if (SystemDictionaryShared::is_registered_lambda_proxy_class(ik)) {
120+
if (LambdaProxyClassDictionary::is_registered_lambda_proxy_class(ik)) {
120121
add = true;
121122
}
122123
} else {
123-
assert(!SystemDictionaryShared::is_registered_lambda_proxy_class(ik),
124+
assert(!LambdaProxyClassDictionary::is_registered_lambda_proxy_class(ik),
124125
"registered lambda proxies are only for legacy lambda proxy support");
125126
}
126127
}

src/hotspot/share/cds/archiveUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cds/dynamicArchive.hpp"
3232
#include "cds/filemap.hpp"
3333
#include "cds/heapShared.hpp"
34+
#include "cds/lambdaProxyClassDictionary.hpp"
3435
#include "cds/metaspaceShared.hpp"
3536
#include "classfile/systemDictionaryShared.hpp"
3637
#include "classfile/vmClasses.hpp"
@@ -351,7 +352,7 @@ void ReadClosure::do_tag(int tag) {
351352

352353
void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
353354
if (ClassListWriter::is_enabled()) {
354-
if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
355+
if (LambdaProxyClassDictionary::is_supported_invokedynamic(bootstrap_specifier)) {
355356
const constantPoolHandle& pool = bootstrap_specifier->pool();
356357
if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
357358
// Currently lambda proxy classes are supported only for the built-in loaders.

src/hotspot/share/cds/cdsConfig.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,16 @@ void CDSConfig::log_reasons_for_not_dumping_heap() {
648648
log_info(cds)("Archived java heap is not supported: %s", reason);
649649
}
650650

651+
// This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
652+
bool CDSConfig::is_dumping_lambdas_in_legacy_mode() {
653+
return !is_dumping_method_handles();
654+
}
655+
651656
#if INCLUDE_CDS_JAVA_HEAP
652657
bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() {
653658
return check_options_incompatible_with_dumping_heap() != nullptr;
654659
}
655660

656-
657661
bool CDSConfig::is_dumping_heap() {
658662
if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive())
659663
|| are_vm_options_incompatible_with_dumping_heap()

src/hotspot/share/cds/cdsConfig.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ class CDSConfig : public AllStatic {
131131
// Misc CDS features
132132
static bool allow_only_single_java_thread() NOT_CDS_RETURN_(false);
133133

134+
// This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
135+
static bool is_dumping_lambdas_in_legacy_mode() NOT_CDS_RETURN_(false);
136+
134137
// optimized_module_handling -- can we skip some expensive operations related to modules?
135138
static bool is_using_optimized_module_handling() { return CDS_ONLY(_is_using_optimized_module_handling) NOT_CDS(false); }
136139
static void stop_using_optimized_module_handling() NOT_CDS_RETURN;

src/hotspot/share/cds/classListParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "cds/archiveUtils.hpp"
2727
#include "cds/classListParser.hpp"
2828
#include "cds/lambdaFormInvokers.hpp"
29+
#include "cds/lambdaProxyClassDictionary.hpp"
2930
#include "cds/metaspaceShared.hpp"
3031
#include "cds/unregisteredClasses.hpp"
3132
#include "classfile/classLoaderExt.hpp"
@@ -657,7 +658,7 @@ void ClassListParser::resolve_indy_impl(Symbol* class_name_symbol, TRAPS) {
657658
constantPoolHandle pool(THREAD, cp);
658659
BootstrapInfo bootstrap_specifier(pool, pool_index, indy_index);
659660
Handle bsm = bootstrap_specifier.resolve_bsm(CHECK);
660-
if (!SystemDictionaryShared::is_supported_invokedynamic(&bootstrap_specifier)) {
661+
if (!LambdaProxyClassDictionary::is_supported_invokedynamic(&bootstrap_specifier)) {
661662
log_debug(cds, lambda)("is_supported_invokedynamic check failed for cp_index %d", pool_index);
662663
continue;
663664
}

src/hotspot/share/cds/dynamicArchive.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cds/cds_globals.hpp"
3232
#include "cds/cdsConfig.hpp"
3333
#include "cds/dynamicArchive.hpp"
34+
#include "cds/lambdaProxyClassDictionary.hpp"
3435
#include "cds/regeneratedClasses.hpp"
3536
#include "classfile/classLoader.hpp"
3637
#include "classfile/classLoaderData.inline.hpp"
@@ -159,8 +160,10 @@ class DynamicArchiveBuilder : public ArchiveBuilder {
159160
ArchiveBuilder::serialize_dynamic_archivable_items(&wc);
160161
}
161162

162-
log_info(cds)("Adjust lambda proxy class dictionary");
163-
SystemDictionaryShared::adjust_lambda_proxy_class_dictionary();
163+
if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
164+
log_info(cds)("Adjust lambda proxy class dictionary");
165+
LambdaProxyClassDictionary::adjust_dumptime_table();
166+
}
164167

165168
relocate_to_requested();
166169

0 commit comments

Comments
 (0)