20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "cds/aotLogging.hpp"
26 #include "cds/aotMapLogger.hpp"
27 #include "cds/archiveHeapLoader.hpp"
28 #include "cds/cdsConfig.hpp"
29 #include "cds/classListWriter.hpp"
30 #include "cds/filemap.hpp"
31 #include "cds/heapShared.hpp"
32 #include "classfile/classLoaderDataShared.hpp"
33 #include "classfile/moduleEntry.hpp"
34 #include "code/aotCodeCache.hpp"
35 #include "include/jvm_io.h"
36 #include "logging/log.hpp"
37 #include "memory/universe.hpp"
38 #include "prims/jvmtiAgentList.hpp"
39 #include "runtime/arguments.hpp"
40 #include "runtime/globals_extension.hpp"
41 #include "runtime/java.hpp"
42 #include "runtime/vmThread.hpp"
43 #include "utilities/defaultStream.hpp"
44 #include "utilities/formatBuffer.hpp"
45
46 bool CDSConfig::_is_dumping_static_archive = false;
47 bool CDSConfig::_is_dumping_preimage_static_archive = false;
48 bool CDSConfig::_is_dumping_final_static_archive = false;
49 bool CDSConfig::_is_dumping_dynamic_archive = false;
50 bool CDSConfig::_is_using_optimized_module_handling = true;
51 bool CDSConfig::_is_dumping_full_module_graph = true;
52 bool CDSConfig::_is_using_full_module_graph = true;
53 bool CDSConfig::_has_aot_linked_classes = false;
54 bool CDSConfig::_is_single_command_training = false;
55 bool CDSConfig::_has_temp_aot_config_file = false;
56 bool CDSConfig::_old_cds_flags_used = false;
57 bool CDSConfig::_new_aot_flags_used = false;
58 bool CDSConfig::_disable_heap_dumping = false;
59
60 const char* CDSConfig::_default_archive_path = nullptr;
61 const char* CDSConfig::_input_static_archive_path = nullptr;
62 const char* CDSConfig::_input_dynamic_archive_path = nullptr;
63 const char* CDSConfig::_output_archive_path = nullptr;
64
65 JavaThread* CDSConfig::_dumper_thread = nullptr;
66
67 int CDSConfig::get_status() {
68 assert(Universe::is_fully_initialized(), "status is finalized only after Universe is initialized");
69 return (is_dumping_archive() ? IS_DUMPING_ARCHIVE : 0) |
70 (is_dumping_method_handles() ? IS_DUMPING_METHOD_HANDLES : 0) |
71 (is_dumping_static_archive() ? IS_DUMPING_STATIC_ARCHIVE : 0) |
72 (is_logging_lambda_form_invokers() ? IS_LOGGING_LAMBDA_FORM_INVOKERS : 0) |
73 (is_using_archive() ? IS_USING_ARCHIVE : 0);
74 }
75
76 DEBUG_ONLY(static bool _cds_ergo_initialize_started = false);
77
78 void CDSConfig::ergo_initialize() {
79 DEBUG_ONLY(_cds_ergo_initialize_started = true);
125 Abstract_VM_Version::vm_variant(), os::file_separator());
126 } else {
127 // Assume .jsa is in the same directory where libjvm resides on
128 // non-static JDK.
129 char jvm_path[JVM_MAXPATHLEN];
130 os::jvm_path(jvm_path, sizeof(jvm_path));
131 char *end = strrchr(jvm_path, *os::file_separator());
132 if (end != nullptr) *end = '\0';
133 tmp.print("%s%sclasses", jvm_path, os::file_separator());
134 }
135 #ifdef _LP64
136 if (!UseCompressedOops) {
137 tmp.print_raw("_nocoops");
138 }
139 if (UseCompactObjectHeaders) {
140 // Note that generation of xxx_coh.jsa variants require
141 // --enable-cds-archive-coh at build time
142 tmp.print_raw("_coh");
143 }
144 #endif
145 tmp.print_raw(".jsa");
146 _default_archive_path = os::strdup(tmp.base());
147 }
148 return _default_archive_path;
149 }
150
151 int CDSConfig::num_archive_paths(const char* path_spec) {
152 if (path_spec == nullptr) {
153 return 0;
154 }
155 int npaths = 1;
156 char* p = (char*)path_spec;
157 while (*p != '\0') {
158 if (*p == os::path_separator()[0]) {
159 npaths++;
160 }
161 p++;
162 }
163 return npaths;
164 }
280 if (RecordDynamicDumpInfo) {
281 vm_exit_during_initialization("-XX:+RecordDynamicDumpInfo is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
282 SharedArchiveFile);
283 }
284 if (ArchiveClassesAtExit != nullptr) {
285 vm_exit_during_initialization("-XX:ArchiveClassesAtExit is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
286 SharedArchiveFile);
287 }
288 }
289
290 if (ArchiveClassesAtExit != nullptr && os::same_files(SharedArchiveFile, ArchiveClassesAtExit)) {
291 vm_exit_during_initialization(
292 "Cannot have the same archive file specified for -XX:SharedArchiveFile and -XX:ArchiveClassesAtExit",
293 SharedArchiveFile);
294 }
295 }
296 }
297 }
298
299 void CDSConfig::check_internal_module_property(const char* key, const char* value) {
300 if (Arguments::is_incompatible_cds_internal_module_property(key)) {
301 stop_using_optimized_module_handling();
302 aot_log_info(aot)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
303 }
304 }
305
306 void CDSConfig::check_incompatible_property(const char* key, const char* value) {
307 static const char* incompatible_properties[] = {
308 "java.system.class.loader",
309 "jdk.module.showModuleResolution",
310 "jdk.module.validation"
311 };
312
313 for (const char* property : incompatible_properties) {
314 if (strcmp(key, property) == 0) {
315 stop_dumping_full_module_graph();
316 stop_using_full_module_graph();
317 aot_log_info(aot)("full module graph: disabled due to incompatible property: %s=%s", key, value);
318 break;
319 }
320 }
321
322 }
323
324 // Returns any JVM command-line option, such as "--patch-module", that's not supported by CDS.
325 static const char* find_any_unsupported_module_option() {
326 // Note that arguments.cpp has translated the command-line options into properties. If we find an
327 // unsupported property, translate it back to its command-line option for better error reporting.
328
329 // The following properties are checked by Arguments::is_internal_module_property() and cannot be
330 // directly specified in the command-line.
331 static const char* unsupported_module_properties[] = {
332 "jdk.module.limitmods",
333 "jdk.module.upgrade.path",
334 "jdk.module.patch.0"
335 };
336 static const char* unsupported_module_options[] = {
337 "--limit-modules",
338 "--upgrade-module-path",
339 "--patch-module"
340 };
341
342 assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
343 SystemProperty* sp = Arguments::system_properties();
344 while (sp != nullptr) {
345 for (uint i = 0; i < ARRAY_SIZE(unsupported_module_properties); i++) {
346 if (strcmp(sp->key(), unsupported_module_properties[i]) == 0) {
347 return unsupported_module_options[i];
348 }
349 }
350 sp = sp->next();
351 }
352
353 return nullptr; // not found
354 }
355
356 void CDSConfig::check_unsupported_dumping_module_options() {
357 assert(is_dumping_archive(), "this function is only used with CDS dump time");
358 const char* option = find_any_unsupported_module_option();
359 if (option != nullptr) {
360 vm_exit_during_initialization("Cannot use the following option when dumping the shared archive", option);
361 }
362 // Check for an exploded module build in use with -Xshare:dump.
363 if (!Arguments::has_jimage()) {
364 vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
365 }
366 }
367
368 bool CDSConfig::has_unsupported_runtime_module_options() {
369 assert(is_using_archive(), "this function is only used with -Xshare:{on,auto}");
370 if (ArchiveClassesAtExit != nullptr) {
371 // dynamic dumping, just return false for now.
372 // check_unsupported_dumping_properties() will be called later to check the same set of
373 // properties, and will exit the VM with the correct error message if the unsupported properties
374 // are used.
375 return false;
376 }
377 const char* option = find_any_unsupported_module_option();
378 if (option != nullptr) {
379 if (RequireSharedSpaces) {
380 warning("CDS is disabled when the %s option is specified.", option);
381 } else {
382 if (new_aot_flags_used()) {
383 aot_log_warning(aot)("AOT cache is disabled when the %s option is specified.", option);
384 } else {
385 aot_log_info(aot)("CDS is disabled when the %s option is specified.", option);
386 }
387 }
388 return true;
389 }
390 return false;
391 }
392
393 #define CHECK_NEW_FLAG(f) check_new_flag(FLAG_IS_DEFAULT(f), #f)
394
395 void CDSConfig::check_new_flag(bool new_flag_is_default, const char* new_flag_name) {
396 if (old_cds_flags_used() && !new_flag_is_default) {
397 vm_exit_during_initialization(err_msg("Option %s cannot be used at the same time with "
398 "-Xshare:on, -Xshare:auto, -Xshare:off, -Xshare:dump, "
399 "DumpLoadedClassList, SharedClassListFile, or SharedArchiveFile",
400 new_flag_name));
401 }
402 }
403
404 #define CHECK_SINGLE_PATH(f) check_flag_single_path(#f, f)
405
406 void CDSConfig::check_flag_single_path(const char* flag_name, const char* value) {
407 if (value != nullptr && num_archive_paths(value) != 1) {
408 vm_exit_during_initialization(err_msg("Option %s must specify a single file name", flag_name));
409 }
608 void CDSConfig::ergo_init_aot_paths() {
609 assert(_cds_ergo_initialize_started, "sanity");
610 if (is_dumping_static_archive()) {
611 if (is_dumping_preimage_static_archive()) {
612 _output_archive_path = AOTConfiguration;
613 } else {
614 assert(is_dumping_final_static_archive(), "must be");
615 _input_static_archive_path = AOTConfiguration;
616 _output_archive_path = AOTCache;
617 }
618 } else if (is_using_archive()) {
619 if (FLAG_IS_DEFAULT(AOTCache)) {
620 // Only -XX:AOTMode={auto,on} is specified
621 _input_static_archive_path = default_archive_path();
622 } else {
623 _input_static_archive_path = AOTCache;
624 }
625 }
626 }
627
628 bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
629 assert(!_cds_ergo_initialize_started, "This is called earlier than CDSConfig::ergo_initialize()");
630
631 check_aot_flags();
632
633 if (!FLAG_IS_DEFAULT(AOTMode)) {
634 // Using any form of the new AOTMode switch enables enhanced optimizations.
635 FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
636 }
637
638 setup_compiler_args();
639
640 if (AOTClassLinking) {
641 // If AOTClassLinking is specified, enable all AOT optimizations by default.
642 FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);
643 } else {
644 // AOTInvokeDynamicLinking depends on AOTClassLinking.
645 FLAG_SET_ERGO(AOTInvokeDynamicLinking, false);
646 }
647
648 if (is_dumping_static_archive()) {
683 return false;
684 }
685
686 if (ArchiveClassesAtExit == nullptr && !RecordDynamicDumpInfo) {
687 disable_dumping_dynamic_archive();
688 } else {
689 enable_dumping_dynamic_archive(ArchiveClassesAtExit);
690 }
691
692 if (AutoCreateSharedArchive) {
693 if (SharedArchiveFile == nullptr) {
694 aot_log_warning(aot)("-XX:+AutoCreateSharedArchive requires -XX:SharedArchiveFile");
695 return false;
696 }
697 if (ArchiveClassesAtExit != nullptr) {
698 aot_log_warning(aot)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
699 return false;
700 }
701 }
702
703 if (is_using_archive() && patch_mod_javabase) {
704 Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
705 }
706 if (is_using_archive() && has_unsupported_runtime_module_options()) {
707 UseSharedSpaces = false;
708 }
709
710 if (is_dumping_archive()) {
711 // Always verify non-system classes during CDS dump
712 if (!BytecodeVerificationRemote) {
713 BytecodeVerificationRemote = true;
714 aot_log_info(aot)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
715 }
716 }
717
718 if (is_dumping_classic_static_archive() && AOTClassLinking) {
719 if (JvmtiAgentList::disable_agent_list()) {
720 FLAG_SET_ERGO(AllowArchivingWithJavaAgent, false);
721 log_warning(cds)("Disabled all JVMTI agents with -Xshare:dump -XX:+AOTClassLinking");
722 }
723 }
911 reason = "Programmatically disabled";
912 } else {
913 reason = check_options_incompatible_with_dumping_heap();
914 }
915
916 assert(reason != nullptr, "sanity");
917 aot_log_info(aot)("Archived java heap is not supported: %s", reason);
918 }
919
920 // This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
921 bool CDSConfig::is_dumping_lambdas_in_legacy_mode() {
922 return !is_dumping_method_handles();
923 }
924
925 #if INCLUDE_CDS_JAVA_HEAP
926 bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() {
927 return check_options_incompatible_with_dumping_heap() != nullptr;
928 }
929
930 bool CDSConfig::is_dumping_heap() {
931 if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive())
932 || are_vm_options_incompatible_with_dumping_heap()
933 || _disable_heap_dumping) {
934 return false;
935 }
936 return true;
937 }
938
939 bool CDSConfig::is_loading_heap() {
940 return ArchiveHeapLoader::is_in_use();
941 }
942
943 bool CDSConfig::is_using_full_module_graph() {
944 if (ClassLoaderDataShared::is_full_module_graph_loaded()) {
945 return true;
946 }
947
948 if (!_is_using_full_module_graph) {
949 return false;
950 }
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "cds/aotLogging.hpp"
26 #include "cds/aotMapLogger.hpp"
27 #include "cds/archiveHeapLoader.hpp"
28 #include "cds/cdsConfig.hpp"
29 #include "cds/classListWriter.hpp"
30 #include "cds/filemap.hpp"
31 #include "cds/heapShared.hpp"
32 #include "classfile/classLoaderDataShared.hpp"
33 #include "classfile/moduleEntry.hpp"
34 #include "code/aotCodeCache.hpp"
35 #include "include/jvm_io.h"
36 #include "logging/log.hpp"
37 #include "memory/universe.hpp"
38 #include "prims/jvmtiAgentList.hpp"
39 #include "runtime/arguments.hpp"
40 #include "runtime/globals.hpp"
41 #include "runtime/globals_extension.hpp"
42 #include "runtime/java.hpp"
43 #include "runtime/vmThread.hpp"
44 #include "utilities/defaultStream.hpp"
45 #include "utilities/formatBuffer.hpp"
46
47 bool CDSConfig::_is_dumping_static_archive = false;
48 bool CDSConfig::_is_dumping_preimage_static_archive = false;
49 bool CDSConfig::_is_dumping_final_static_archive = false;
50 bool CDSConfig::_is_dumping_dynamic_archive = false;
51 bool CDSConfig::_is_using_optimized_module_handling = true;
52 bool CDSConfig::_is_dumping_full_module_graph = true;
53 bool CDSConfig::_is_using_full_module_graph = true;
54 bool CDSConfig::_has_aot_linked_classes = false;
55 bool CDSConfig::_is_single_command_training = false;
56 bool CDSConfig::_has_temp_aot_config_file = false;
57 bool CDSConfig::_old_cds_flags_used = false;
58 bool CDSConfig::_new_aot_flags_used = false;
59 bool CDSConfig::_disable_heap_dumping = false;
60
61 bool CDSConfig::_module_patching_disables_cds = false;
62 bool CDSConfig::_java_base_module_patching_disables_cds = false;
63
64 const char* CDSConfig::_default_archive_path = nullptr;
65 const char* CDSConfig::_input_static_archive_path = nullptr;
66 const char* CDSConfig::_input_dynamic_archive_path = nullptr;
67 const char* CDSConfig::_output_archive_path = nullptr;
68
69 JavaThread* CDSConfig::_dumper_thread = nullptr;
70
71 int CDSConfig::get_status() {
72 assert(Universe::is_fully_initialized(), "status is finalized only after Universe is initialized");
73 return (is_dumping_archive() ? IS_DUMPING_ARCHIVE : 0) |
74 (is_dumping_method_handles() ? IS_DUMPING_METHOD_HANDLES : 0) |
75 (is_dumping_static_archive() ? IS_DUMPING_STATIC_ARCHIVE : 0) |
76 (is_logging_lambda_form_invokers() ? IS_LOGGING_LAMBDA_FORM_INVOKERS : 0) |
77 (is_using_archive() ? IS_USING_ARCHIVE : 0);
78 }
79
80 DEBUG_ONLY(static bool _cds_ergo_initialize_started = false);
81
82 void CDSConfig::ergo_initialize() {
83 DEBUG_ONLY(_cds_ergo_initialize_started = true);
129 Abstract_VM_Version::vm_variant(), os::file_separator());
130 } else {
131 // Assume .jsa is in the same directory where libjvm resides on
132 // non-static JDK.
133 char jvm_path[JVM_MAXPATHLEN];
134 os::jvm_path(jvm_path, sizeof(jvm_path));
135 char *end = strrchr(jvm_path, *os::file_separator());
136 if (end != nullptr) *end = '\0';
137 tmp.print("%s%sclasses", jvm_path, os::file_separator());
138 }
139 #ifdef _LP64
140 if (!UseCompressedOops) {
141 tmp.print_raw("_nocoops");
142 }
143 if (UseCompactObjectHeaders) {
144 // Note that generation of xxx_coh.jsa variants require
145 // --enable-cds-archive-coh at build time
146 tmp.print_raw("_coh");
147 }
148 #endif
149 if (is_valhalla_preview()) {
150 tmp.print_raw("_valhalla");
151 }
152 tmp.print_raw(".jsa");
153 _default_archive_path = os::strdup(tmp.base());
154 }
155 return _default_archive_path;
156 }
157
158 int CDSConfig::num_archive_paths(const char* path_spec) {
159 if (path_spec == nullptr) {
160 return 0;
161 }
162 int npaths = 1;
163 char* p = (char*)path_spec;
164 while (*p != '\0') {
165 if (*p == os::path_separator()[0]) {
166 npaths++;
167 }
168 p++;
169 }
170 return npaths;
171 }
287 if (RecordDynamicDumpInfo) {
288 vm_exit_during_initialization("-XX:+RecordDynamicDumpInfo is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
289 SharedArchiveFile);
290 }
291 if (ArchiveClassesAtExit != nullptr) {
292 vm_exit_during_initialization("-XX:ArchiveClassesAtExit is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile",
293 SharedArchiveFile);
294 }
295 }
296
297 if (ArchiveClassesAtExit != nullptr && os::same_files(SharedArchiveFile, ArchiveClassesAtExit)) {
298 vm_exit_during_initialization(
299 "Cannot have the same archive file specified for -XX:SharedArchiveFile and -XX:ArchiveClassesAtExit",
300 SharedArchiveFile);
301 }
302 }
303 }
304 }
305
306 void CDSConfig::check_internal_module_property(const char* key, const char* value) {
307 if (Arguments::is_incompatible_cds_internal_module_property(key) && !Arguments::patching_migrated_classes(key, value)) {
308 stop_using_optimized_module_handling();
309 aot_log_info(aot)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
310 }
311 }
312
313 void CDSConfig::check_incompatible_property(const char* key, const char* value) {
314 static const char* incompatible_properties[] = {
315 "java.system.class.loader",
316 "jdk.module.showModuleResolution",
317 "jdk.module.validation"
318 };
319
320 for (const char* property : incompatible_properties) {
321 if (strcmp(key, property) == 0) {
322 stop_dumping_full_module_graph();
323 stop_using_full_module_graph();
324 aot_log_info(aot)("full module graph: disabled due to incompatible property: %s=%s", key, value);
325 break;
326 }
327 }
328
329 }
330
331 // Returns any JVM command-line option, such as "--patch-module", that's not supported by CDS.
332 static const char* find_any_unsupported_module_option() {
333 // Note that arguments.cpp has translated the command-line options into properties. If we find an
334 // unsupported property, translate it back to its command-line option for better error reporting.
335
336 // The following properties are checked by Arguments::is_internal_module_property() and cannot be
337 // directly specified in the command-line.
338 static const char* unsupported_module_properties[] = {
339 "jdk.module.limitmods",
340 "jdk.module.upgrade.path"
341 };
342 static const char* unsupported_module_options[] = {
343 "--limit-modules",
344 "--upgrade-module-path"
345 };
346
347 assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
348 SystemProperty* sp = Arguments::system_properties();
349 while (sp != nullptr) {
350 for (uint i = 0; i < ARRAY_SIZE(unsupported_module_properties); i++) {
351 if (strcmp(sp->key(), unsupported_module_properties[i]) == 0) {
352 return unsupported_module_options[i];
353 }
354 }
355 sp = sp->next();
356 }
357
358 return nullptr; // not found
359 }
360
361 void CDSConfig::check_unsupported_dumping_module_options() {
362 assert(is_dumping_archive(), "this function is only used with CDS dump time");
363 const char* option = find_any_unsupported_module_option();
364 if (option != nullptr) {
365 vm_exit_during_initialization("Cannot use the following option when dumping the shared archive", option);
366 }
367
368 if (module_patching_disables_cds()) {
369 vm_exit_during_initialization(
370 "Cannot use the following option when dumping the shared archive", "--patch-module");
371 }
372
373 // Check for an exploded module build in use with -Xshare:dump.
374 if (!Arguments::has_jimage()) {
375 vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
376 }
377 }
378
379 bool CDSConfig::has_unsupported_runtime_module_options() {
380 assert(is_using_archive(), "this function is only used with -Xshare:{on,auto}");
381 if (ArchiveClassesAtExit != nullptr) {
382 // dynamic dumping, just return false for now.
383 // check_unsupported_dumping_properties() will be called later to check the same set of
384 // properties, and will exit the VM with the correct error message if the unsupported properties
385 // are used.
386 return false;
387 }
388 const char* option = find_any_unsupported_module_option();
389 if (option != nullptr) {
390 if (RequireSharedSpaces) {
391 warning("CDS is disabled when the %s option is specified.", option);
392 } else {
393 if (new_aot_flags_used()) {
394 aot_log_warning(aot)("AOT cache is disabled when the %s option is specified.", option);
395 } else {
396 aot_log_info(aot)("CDS is disabled when the %s option is specified.", option);
397 }
398 }
399 return true;
400 }
401
402 if (module_patching_disables_cds()) {
403 if (RequireSharedSpaces) {
404 warning("CDS is disabled when the %s option is specified.", "--patch-module");
405 } else {
406 log_info(cds)("CDS is disabled when the %s option is specified.", "--patch-module");
407 }
408 return true;
409 }
410
411 return false;
412 }
413
414 #define CHECK_NEW_FLAG(f) check_new_flag(FLAG_IS_DEFAULT(f), #f)
415
416 void CDSConfig::check_new_flag(bool new_flag_is_default, const char* new_flag_name) {
417 if (old_cds_flags_used() && !new_flag_is_default) {
418 vm_exit_during_initialization(err_msg("Option %s cannot be used at the same time with "
419 "-Xshare:on, -Xshare:auto, -Xshare:off, -Xshare:dump, "
420 "DumpLoadedClassList, SharedClassListFile, or SharedArchiveFile",
421 new_flag_name));
422 }
423 }
424
425 #define CHECK_SINGLE_PATH(f) check_flag_single_path(#f, f)
426
427 void CDSConfig::check_flag_single_path(const char* flag_name, const char* value) {
428 if (value != nullptr && num_archive_paths(value) != 1) {
429 vm_exit_during_initialization(err_msg("Option %s must specify a single file name", flag_name));
430 }
629 void CDSConfig::ergo_init_aot_paths() {
630 assert(_cds_ergo_initialize_started, "sanity");
631 if (is_dumping_static_archive()) {
632 if (is_dumping_preimage_static_archive()) {
633 _output_archive_path = AOTConfiguration;
634 } else {
635 assert(is_dumping_final_static_archive(), "must be");
636 _input_static_archive_path = AOTConfiguration;
637 _output_archive_path = AOTCache;
638 }
639 } else if (is_using_archive()) {
640 if (FLAG_IS_DEFAULT(AOTCache)) {
641 // Only -XX:AOTMode={auto,on} is specified
642 _input_static_archive_path = default_archive_path();
643 } else {
644 _input_static_archive_path = AOTCache;
645 }
646 }
647 }
648
649 bool CDSConfig::check_vm_args_consistency(bool mode_flag_cmd_line) {
650 assert(!_cds_ergo_initialize_started, "This is called earlier than CDSConfig::ergo_initialize()");
651
652 check_aot_flags();
653
654 if (!FLAG_IS_DEFAULT(AOTMode)) {
655 // Using any form of the new AOTMode switch enables enhanced optimizations.
656 FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
657 }
658
659 setup_compiler_args();
660
661 if (AOTClassLinking) {
662 // If AOTClassLinking is specified, enable all AOT optimizations by default.
663 FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);
664 } else {
665 // AOTInvokeDynamicLinking depends on AOTClassLinking.
666 FLAG_SET_ERGO(AOTInvokeDynamicLinking, false);
667 }
668
669 if (is_dumping_static_archive()) {
704 return false;
705 }
706
707 if (ArchiveClassesAtExit == nullptr && !RecordDynamicDumpInfo) {
708 disable_dumping_dynamic_archive();
709 } else {
710 enable_dumping_dynamic_archive(ArchiveClassesAtExit);
711 }
712
713 if (AutoCreateSharedArchive) {
714 if (SharedArchiveFile == nullptr) {
715 aot_log_warning(aot)("-XX:+AutoCreateSharedArchive requires -XX:SharedArchiveFile");
716 return false;
717 }
718 if (ArchiveClassesAtExit != nullptr) {
719 aot_log_warning(aot)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
720 return false;
721 }
722 }
723
724 if (is_using_archive() && java_base_module_patching_disables_cds() && module_patching_disables_cds()) {
725 Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
726 }
727 if (is_using_archive() && has_unsupported_runtime_module_options()) {
728 UseSharedSpaces = false;
729 }
730
731 if (is_dumping_archive()) {
732 // Always verify non-system classes during CDS dump
733 if (!BytecodeVerificationRemote) {
734 BytecodeVerificationRemote = true;
735 aot_log_info(aot)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
736 }
737 }
738
739 if (is_dumping_classic_static_archive() && AOTClassLinking) {
740 if (JvmtiAgentList::disable_agent_list()) {
741 FLAG_SET_ERGO(AllowArchivingWithJavaAgent, false);
742 log_warning(cds)("Disabled all JVMTI agents with -Xshare:dump -XX:+AOTClassLinking");
743 }
744 }
932 reason = "Programmatically disabled";
933 } else {
934 reason = check_options_incompatible_with_dumping_heap();
935 }
936
937 assert(reason != nullptr, "sanity");
938 aot_log_info(aot)("Archived java heap is not supported: %s", reason);
939 }
940
941 // This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
942 bool CDSConfig::is_dumping_lambdas_in_legacy_mode() {
943 return !is_dumping_method_handles();
944 }
945
946 #if INCLUDE_CDS_JAVA_HEAP
947 bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() {
948 return check_options_incompatible_with_dumping_heap() != nullptr;
949 }
950
951 bool CDSConfig::is_dumping_heap() {
952 if (is_valhalla_preview()) {
953 // Not working yet -- e.g., HeapShared::oop_hash() needs to be implemented for value oops
954 return false;
955 }
956 if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive())
957 || are_vm_options_incompatible_with_dumping_heap()
958 || _disable_heap_dumping) {
959 return false;
960 }
961 return true;
962 }
963
964 bool CDSConfig::is_loading_heap() {
965 return ArchiveHeapLoader::is_in_use();
966 }
967
968 bool CDSConfig::is_using_full_module_graph() {
969 if (ClassLoaderDataShared::is_full_module_graph_loaded()) {
970 return true;
971 }
972
973 if (!_is_using_full_module_graph) {
974 return false;
975 }
|