From eda262734a29f59a1c909687ed15e19f09373541 Mon Sep 17 00:00:00 2001 From: Matias Saavedra Silva Date: Fri, 21 Nov 2025 13:25:05 -0500 Subject: [PATCH] Enable CDS heap dumping --- src/hotspot/share/cds/aotMetaspace.cpp | 5 ----- src/hotspot/share/cds/cdsConfig.cpp | 6 +----- src/hotspot/share/cds/heapShared.cpp | 6 ------ src/hotspot/share/classfile/systemDictionary.cpp | 10 +++++++++- src/hotspot/share/runtime/arguments.cpp | 14 +------------- src/hotspot/share/runtime/arguments.hpp | 1 - src/hotspot/share/runtime/sharedRuntime.cpp | 14 ++++++++++++++ .../classes/jdk/internal/jimage/PreviewMode.java | 2 +- 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/hotspot/share/cds/aotMetaspace.cpp b/src/hotspot/share/cds/aotMetaspace.cpp index 196773e30f3..369aafadc11 100644 --- a/src/hotspot/share/cds/aotMetaspace.cpp +++ b/src/hotspot/share/cds/aotMetaspace.cpp @@ -1262,11 +1262,6 @@ bool AOTMetaspace::try_link_class(JavaThread* current, InstanceKlass* ik) { } void VM_PopulateDumpSharedSpace::dump_java_heap_objects() { - if (CDSConfig::is_valhalla_preview()) { - log_info(cds)("Archived java heap is not yet supported with Valhalla preview"); - return; - } - if (CDSConfig::is_dumping_heap()) { HeapShared::write_heap(&_heap_info); } else { diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index dcfc9947b84..c606f7411f8 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -306,7 +306,7 @@ void CDSConfig::ergo_init_classic_archive_paths() { } void CDSConfig::check_internal_module_property(const char* key, const char* value) { - if (Arguments::is_incompatible_cds_internal_module_property(key) && !Arguments::patching_migrated_classes(key, value)) { + if (Arguments::is_incompatible_cds_internal_module_property(key)) { stop_using_optimized_module_handling(); aot_log_info(aot)("optimized module handling: disabled due to incompatible property: %s=%s", key, value); } @@ -981,10 +981,6 @@ bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() { } bool CDSConfig::is_dumping_heap() { - if (is_valhalla_preview()) { - // Not working yet -- e.g., HeapShared::oop_hash() needs to be implemented for value oops - return false; - } if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive()) || are_vm_options_incompatible_with_dumping_heap() || _disable_heap_dumping) { diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index 6ab5b0c336f..fd7c54c41f2 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -2089,12 +2089,6 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[], ArchivableStaticFieldInfo* info = &fields[i]; const char* klass_name = info->klass_name; - if (CDSConfig::is_valhalla_preview() && strcmp(klass_name, "jdk/internal/module/ArchivedModuleGraph") == 0) { - // FIXME -- ArchivedModuleGraph doesn't work when java.base is patched with valhalla classes. - i++; - continue; - } - start_recording_subgraph(info->klass, klass_name, is_full_module_graph); // If you have specified consecutive fields of the same klass in diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index fbd99ca978a..6f261c496f9 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -214,7 +214,15 @@ ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool cre bool created = false; ClassLoaderData* cld = ClassLoaderDataGraph::find_or_create(class_loader, created); if (created && Arguments::enable_preview()) { - add_migrated_value_classes(cld); + if (CDSConfig::is_using_aot_linked_classes() && java_system_loader() == nullptr) { + // We are inside AOTLinkedClassBulkLoader::preload_classes(). + // + // AOTLinkedClassBulkLoader will automatically initiate the loading of all archived + // public classes from the boot loader into platform/system loaders, so there's + // no need to call add_migrated_value_classes(). + } else { + add_migrated_value_classes(cld); + } } return cld; } diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 85adcc7d1d4..90f74b27488 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -364,18 +364,6 @@ bool Arguments::internal_module_property_helper(const char* property, bool check return false; } -bool Arguments::patching_migrated_classes(const char* property, const char* value) { - if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) { - const char* property_suffix = property + MODULE_PROPERTY_PREFIX_LEN; - if (matches_property_suffix(property_suffix, PATCH, PATCH_LEN)) { - if (strcmp(value, "java.base-valueclasses.jar")) { - return true; - } - } - } - return false; -} - // Process java launcher properties. void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) { // See if sun.java.launcher is defined. @@ -2089,7 +2077,7 @@ int Arguments::process_patch_mod_option(const char* patch_mod_tail) { // Temporary system property to disable preview patching and enable the new preview mode // feature for testing/development. Once the preview mode feature is finished, the value // will be always 'true' and this code, and all related dead-code can be removed. -#define DISABLE_PREVIEW_PATCHING_DEFAULT false +#define DISABLE_PREVIEW_PATCHING_DEFAULT true bool Arguments::disable_preview_patching() { const char* prop = get_property("DISABLE_PREVIEW_PATCHING"); diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index bef969f1c44..17bc7f1fad2 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -475,7 +475,6 @@ class Arguments : AllStatic { static bool is_internal_module_property(const char* option); static bool is_incompatible_cds_internal_module_property(const char* property); - static bool patching_migrated_classes(const char* property, const char* value); // Miscellaneous System property value getter and setters. static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 30991c7b0fa..e7787d6661e 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -2928,6 +2928,19 @@ void CompiledEntrySignature::compute_calling_conventions(bool init) { GrowableArray* supers = get_supers(); for (int i = 0; i < supers->length(); ++i) { Method* super_method = supers->at(i); + if (AOTCodeCache::is_using_adapter() && super_method->adapter()->get_sig_cc() == nullptr) { + // Calling conventions have to be regenerated at runtime and are accessed through method adapters, + // which are archived in the AOT code cache. If the adapters are not regenerated, the + // calling conventions should be regenerated here. + CompiledEntrySignature ces(super_method); + ces.compute_calling_conventions(); + if (ces.has_scalarized_args()) { + // Save a C heap allocated version of the scalarized signature and store it in the adapter + GrowableArray* heap_sig = new (mtInternal) GrowableArray(ces.sig_cc()->length(), mtInternal); + heap_sig->appendAll(ces.sig_cc()); + super_method->adapter()->set_sig_cc(heap_sig); + } + } if (super_method->is_scalarized_arg(arg_num)) { scalar_super = true; } else { @@ -3382,6 +3395,7 @@ void AdapterHandlerEntry::remove_unshareable_info() { #endif // ASSERT _adapter_blob = nullptr; _linked = false; + _sig_cc = nullptr; } class CopyAdapterTableToArchive : StackObj { diff --git a/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java b/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java index 5c90e6b587b..41bb385a8f8 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java +++ b/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java @@ -90,7 +90,7 @@ public boolean isPreviewModeEnabled() { // Temporary system property to disable preview patching and enable the new preview mode // feature for testing/development. Once the preview mode feature is finished, the value // will be always 'true' and this code, and all related dead-code can be removed. - private static final boolean DISABLE_PREVIEW_PATCHING_DEFAULT = false; + private static final boolean DISABLE_PREVIEW_PATCHING_DEFAULT = true; private static final boolean DISABLE_PREVIEW_PATCHING = Boolean.parseBoolean( System.getProperty( "DISABLE_PREVIEW_PATCHING",