16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "cds/archiveHeapLoader.hpp"
26 #include "cds/cdsConfig.hpp"
27 #include "cds/classListWriter.hpp"
28 #include "cds/filemap.hpp"
29 #include "cds/heapShared.hpp"
30 #include "classfile/classLoaderDataShared.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "include/jvm_io.h"
33 #include "logging/log.hpp"
34 #include "memory/universe.hpp"
35 #include "runtime/arguments.hpp"
36 #include "runtime/globals_extension.hpp"
37 #include "runtime/java.hpp"
38 #include "runtime/vmThread.hpp"
39 #include "utilities/defaultStream.hpp"
40 #include "utilities/formatBuffer.hpp"
41
42 bool CDSConfig::_is_dumping_static_archive = false;
43 bool CDSConfig::_is_dumping_preimage_static_archive = false;
44 bool CDSConfig::_is_dumping_final_static_archive = false;
45 bool CDSConfig::_is_dumping_dynamic_archive = false;
46 bool CDSConfig::_is_using_optimized_module_handling = true;
47 bool CDSConfig::_is_dumping_full_module_graph = true;
48 bool CDSConfig::_is_using_full_module_graph = true;
49 bool CDSConfig::_has_aot_linked_classes = false;
50 bool CDSConfig::_old_cds_flags_used = false;
51 bool CDSConfig::_new_aot_flags_used = false;
52 bool CDSConfig::_disable_heap_dumping = false;
53
54 char* CDSConfig::_default_archive_path = nullptr;
55 char* CDSConfig::_static_archive_path = nullptr;
56 char* CDSConfig::_dynamic_archive_path = nullptr;
57
58 JavaThread* CDSConfig::_dumper_thread = nullptr;
59
60 int CDSConfig::get_status() {
61 assert(Universe::is_fully_initialized(), "status is finalized only after Universe is initialized");
62 return (is_dumping_archive() ? IS_DUMPING_ARCHIVE : 0) |
63 (is_dumping_method_handles() ? IS_DUMPING_METHOD_HANDLES : 0) |
64 (is_dumping_static_archive() ? IS_DUMPING_STATIC_ARCHIVE : 0) |
65 (is_logging_lambda_form_invokers() ? IS_LOGGING_LAMBDA_FORM_INVOKERS : 0) |
66 (is_using_archive() ? IS_USING_ARCHIVE : 0);
67 }
68
69 void CDSConfig::initialize() {
70 if (is_dumping_static_archive() && !is_dumping_final_static_archive()) {
71 // Note: -Xshare and -XX:AOTMode flags are mutually exclusive.
72 // - Classic workflow: -Xshare:on and -Xshare:dump cannot take effect at the same time.
73 // - JEP 483 workflow: -XX:AOTMode:record and -XX:AOTMode=on cannot take effect at the same time.
93 _is_dumping_full_module_graph = false;
94 }
95 }
96
97 char* CDSConfig::default_archive_path() {
98 if (_default_archive_path == nullptr) {
99 stringStream tmp;
100 const char* subdir = WINDOWS_ONLY("bin") NOT_WINDOWS("lib");
101 tmp.print("%s%s%s%s%s%sclasses", Arguments::get_java_home(), os::file_separator(), subdir,
102 os::file_separator(), Abstract_VM_Version::vm_variant(), os::file_separator());
103 #ifdef _LP64
104 if (!UseCompressedOops) {
105 tmp.print_raw("_nocoops");
106 }
107 if (UseCompactObjectHeaders) {
108 // Note that generation of xxx_coh.jsa variants require
109 // --enable-cds-archive-coh at build time
110 tmp.print_raw("_coh");
111 }
112 #endif
113 tmp.print_raw(".jsa");
114 _default_archive_path = os::strdup(tmp.base());
115 }
116 return _default_archive_path;
117 }
118
119 int CDSConfig::num_archives(const char* archive_path) {
120 if (archive_path == nullptr) {
121 return 0;
122 }
123 int npaths = 1;
124 char* p = (char*)archive_path;
125 while (*p != '\0') {
126 if (*p == os::path_separator()[0]) {
127 npaths++;
128 }
129 p++;
130 }
131 return npaths;
132 }
276 for (const char* property : incompatible_properties) {
277 if (strcmp(key, property) == 0) {
278 stop_dumping_full_module_graph();
279 stop_using_full_module_graph();
280 log_info(cds)("full module graph: disabled due to incompatible property: %s=%s", key, value);
281 break;
282 }
283 }
284
285 }
286
287 // Returns any JVM command-line option, such as "--patch-module", that's not supported by CDS.
288 static const char* find_any_unsupported_module_option() {
289 // Note that arguments.cpp has translated the command-line options into properties. If we find an
290 // unsupported property, translate it back to its command-line option for better error reporting.
291
292 // The following properties are checked by Arguments::is_internal_module_property() and cannot be
293 // directly specified in the command-line.
294 static const char* unsupported_module_properties[] = {
295 "jdk.module.limitmods",
296 "jdk.module.upgrade.path",
297 "jdk.module.patch.0"
298 };
299 static const char* unsupported_module_options[] = {
300 "--limit-modules",
301 "--upgrade-module-path",
302 "--patch-module"
303 };
304
305 assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
306 SystemProperty* sp = Arguments::system_properties();
307 while (sp != nullptr) {
308 for (uint i = 0; i < ARRAY_SIZE(unsupported_module_properties); i++) {
309 if (strcmp(sp->key(), unsupported_module_properties[i]) == 0) {
310 return unsupported_module_options[i];
311 }
312 }
313 sp = sp->next();
314 }
315
316 return nullptr; // not found
317 }
318
319 void CDSConfig::check_unsupported_dumping_module_options() {
320 assert(is_dumping_archive(), "this function is only used with CDS dump time");
321 const char* option = find_any_unsupported_module_option();
322 if (option != nullptr) {
323 vm_exit_during_initialization("Cannot use the following option when dumping the shared archive", option);
324 }
325 // Check for an exploded module build in use with -Xshare:dump.
326 if (!Arguments::has_jimage()) {
327 vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
328 }
329 }
330
331 bool CDSConfig::has_unsupported_runtime_module_options() {
332 assert(is_using_archive(), "this function is only used with -Xshare:{on,auto}");
333 if (ArchiveClassesAtExit != nullptr) {
334 // dynamic dumping, just return false for now.
335 // check_unsupported_dumping_properties() will be called later to check the same set of
336 // properties, and will exit the VM with the correct error message if the unsupported properties
337 // are used.
338 return false;
339 }
340 const char* option = find_any_unsupported_module_option();
341 if (option != nullptr) {
342 if (RequireSharedSpaces) {
343 warning("CDS is disabled when the %s option is specified.", option);
344 } else {
345 if (new_aot_flags_used()) {
346 log_warning(cds)("AOT cache is disabled when the %s option is specified.", option);
347 } else {
348 log_info(cds)("CDS is disabled when the %s option is specified.", option);
349 }
350 }
351 return true;
352 }
353 return false;
354 }
355
356 #define CHECK_ALIAS(f) check_flag_alias(FLAG_IS_DEFAULT(f), #f)
357
358 void CDSConfig::check_flag_alias(bool alias_is_default, const char* alias_name) {
359 if (old_cds_flags_used() && !alias_is_default) {
360 vm_exit_during_initialization(err_msg("Option %s cannot be used at the same time with "
361 "-Xshare:on, -Xshare:auto, -Xshare:off, -Xshare:dump, "
362 "DumpLoadedClassList, SharedClassListFile, or SharedArchiveFile",
363 alias_name));
364 }
365 }
366
367 void CDSConfig::check_aot_flags() {
368 if (!FLAG_IS_DEFAULT(DumpLoadedClassList) ||
369 !FLAG_IS_DEFAULT(SharedClassListFile) ||
370 !FLAG_IS_DEFAULT(SharedArchiveFile)) {
371 _old_cds_flags_used = true;
372 }
446
447 void CDSConfig::check_aotmode_create() {
448 if (FLAG_IS_DEFAULT(AOTCache)) {
449 vm_exit_during_initialization("AOTCache must be specified when using -XX:AOTMode=create");
450 }
451
452 assert(FLAG_IS_DEFAULT(SharedArchiveFile), "already checked");
453
454 _is_dumping_final_static_archive = true;
455 FLAG_SET_ERGO(SharedArchiveFile, AOTConfiguration);
456 UseSharedSpaces = true;
457 RequireSharedSpaces = true;
458
459 if (!FileMapInfo::is_preimage_static_archive(AOTConfiguration)) {
460 vm_exit_during_initialization("Must be a valid AOT configuration generated by the current JVM", AOTConfiguration);
461 }
462
463 CDSConfig::enable_dumping_static_archive();
464 }
465
466 bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
467 check_aot_flags();
468
469 if (!FLAG_IS_DEFAULT(AOTMode)) {
470 // Using any form of the new AOTMode switch enables enhanced optimizations.
471 FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
472 }
473
474 if (AOTClassLinking) {
475 // If AOTClassLinking is specified, enable all AOT optimizations by default.
476 FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);
477 } else {
478 // AOTInvokeDynamicLinking depends on AOTClassLinking.
479 FLAG_SET_ERGO(AOTInvokeDynamicLinking, false);
480 }
481
482 if (is_dumping_static_archive()) {
483 if (is_dumping_preimage_static_archive()) {
484 // Don't tweak execution mode
485 } else if (!mode_flag_cmd_line) {
486 // By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
511 return false;
512 }
513
514 if (ArchiveClassesAtExit == nullptr && !RecordDynamicDumpInfo) {
515 disable_dumping_dynamic_archive();
516 } else {
517 enable_dumping_dynamic_archive();
518 }
519
520 if (AutoCreateSharedArchive) {
521 if (SharedArchiveFile == nullptr) {
522 log_warning(cds)("-XX:+AutoCreateSharedArchive requires -XX:SharedArchiveFile");
523 return false;
524 }
525 if (ArchiveClassesAtExit != nullptr) {
526 log_warning(cds)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
527 return false;
528 }
529 }
530
531 if (is_using_archive() && patch_mod_javabase) {
532 Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
533 }
534 if (is_using_archive() && has_unsupported_runtime_module_options()) {
535 UseSharedSpaces = false;
536 }
537
538 if (is_dumping_archive()) {
539 // Always verify non-system classes during CDS dump
540 if (!BytecodeVerificationRemote) {
541 BytecodeVerificationRemote = true;
542 log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
543 }
544 }
545
546 return true;
547 }
548
549 bool CDSConfig::is_dumping_classic_static_archive() {
550 return _is_dumping_static_archive &&
551 !is_dumping_preimage_static_archive() &&
642 reason = "Programmatically disabled";
643 } else {
644 reason = check_options_incompatible_with_dumping_heap();
645 }
646
647 assert(reason != nullptr, "sanity");
648 log_info(cds)("Archived java heap is not supported: %s", reason);
649 }
650
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
656 #if INCLUDE_CDS_JAVA_HEAP
657 bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() {
658 return check_options_incompatible_with_dumping_heap() != nullptr;
659 }
660
661 bool CDSConfig::is_dumping_heap() {
662 if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive())
663 || are_vm_options_incompatible_with_dumping_heap()
664 || _disable_heap_dumping) {
665 return false;
666 }
667 return true;
668 }
669
670 bool CDSConfig::is_loading_heap() {
671 return ArchiveHeapLoader::is_in_use();
672 }
673
674 bool CDSConfig::is_using_full_module_graph() {
675 if (ClassLoaderDataShared::is_full_module_graph_loaded()) {
676 return true;
677 }
678
679 if (!_is_using_full_module_graph) {
680 return false;
681 }
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "cds/archiveHeapLoader.hpp"
26 #include "cds/cdsConfig.hpp"
27 #include "cds/classListWriter.hpp"
28 #include "cds/filemap.hpp"
29 #include "cds/heapShared.hpp"
30 #include "classfile/classLoaderDataShared.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "include/jvm_io.h"
33 #include "logging/log.hpp"
34 #include "memory/universe.hpp"
35 #include "runtime/arguments.hpp"
36 #include "runtime/globals.hpp"
37 #include "runtime/globals_extension.hpp"
38 #include "runtime/java.hpp"
39 #include "runtime/vmThread.hpp"
40 #include "utilities/defaultStream.hpp"
41 #include "utilities/formatBuffer.hpp"
42
43 bool CDSConfig::_is_dumping_static_archive = false;
44 bool CDSConfig::_is_dumping_preimage_static_archive = false;
45 bool CDSConfig::_is_dumping_final_static_archive = false;
46 bool CDSConfig::_is_dumping_dynamic_archive = false;
47 bool CDSConfig::_is_using_optimized_module_handling = true;
48 bool CDSConfig::_is_dumping_full_module_graph = true;
49 bool CDSConfig::_is_using_full_module_graph = true;
50 bool CDSConfig::_has_aot_linked_classes = false;
51 bool CDSConfig::_old_cds_flags_used = false;
52 bool CDSConfig::_new_aot_flags_used = false;
53 bool CDSConfig::_disable_heap_dumping = false;
54
55 bool CDSConfig::_module_patching_disables_cds = false;
56 bool CDSConfig::_java_base_module_patching_disables_cds = false;
57
58 bool CDSConfig::is_valhalla_preview() {
59 return Arguments::enable_preview() && EnableValhalla;
60 }
61
62
63 char* CDSConfig::_default_archive_path = nullptr;
64 char* CDSConfig::_static_archive_path = nullptr;
65 char* CDSConfig::_dynamic_archive_path = nullptr;
66
67 JavaThread* CDSConfig::_dumper_thread = nullptr;
68
69 int CDSConfig::get_status() {
70 assert(Universe::is_fully_initialized(), "status is finalized only after Universe is initialized");
71 return (is_dumping_archive() ? IS_DUMPING_ARCHIVE : 0) |
72 (is_dumping_method_handles() ? IS_DUMPING_METHOD_HANDLES : 0) |
73 (is_dumping_static_archive() ? IS_DUMPING_STATIC_ARCHIVE : 0) |
74 (is_logging_lambda_form_invokers() ? IS_LOGGING_LAMBDA_FORM_INVOKERS : 0) |
75 (is_using_archive() ? IS_USING_ARCHIVE : 0);
76 }
77
78 void CDSConfig::initialize() {
79 if (is_dumping_static_archive() && !is_dumping_final_static_archive()) {
80 // Note: -Xshare and -XX:AOTMode flags are mutually exclusive.
81 // - Classic workflow: -Xshare:on and -Xshare:dump cannot take effect at the same time.
82 // - JEP 483 workflow: -XX:AOTMode:record and -XX:AOTMode=on cannot take effect at the same time.
102 _is_dumping_full_module_graph = false;
103 }
104 }
105
106 char* CDSConfig::default_archive_path() {
107 if (_default_archive_path == nullptr) {
108 stringStream tmp;
109 const char* subdir = WINDOWS_ONLY("bin") NOT_WINDOWS("lib");
110 tmp.print("%s%s%s%s%s%sclasses", Arguments::get_java_home(), os::file_separator(), subdir,
111 os::file_separator(), Abstract_VM_Version::vm_variant(), os::file_separator());
112 #ifdef _LP64
113 if (!UseCompressedOops) {
114 tmp.print_raw("_nocoops");
115 }
116 if (UseCompactObjectHeaders) {
117 // Note that generation of xxx_coh.jsa variants require
118 // --enable-cds-archive-coh at build time
119 tmp.print_raw("_coh");
120 }
121 #endif
122 if (is_valhalla_preview()) {
123 tmp.print_raw("_valhalla");
124 }
125 tmp.print_raw(".jsa");
126 _default_archive_path = os::strdup(tmp.base());
127 }
128 return _default_archive_path;
129 }
130
131 int CDSConfig::num_archives(const char* archive_path) {
132 if (archive_path == nullptr) {
133 return 0;
134 }
135 int npaths = 1;
136 char* p = (char*)archive_path;
137 while (*p != '\0') {
138 if (*p == os::path_separator()[0]) {
139 npaths++;
140 }
141 p++;
142 }
143 return npaths;
144 }
288 for (const char* property : incompatible_properties) {
289 if (strcmp(key, property) == 0) {
290 stop_dumping_full_module_graph();
291 stop_using_full_module_graph();
292 log_info(cds)("full module graph: disabled due to incompatible property: %s=%s", key, value);
293 break;
294 }
295 }
296
297 }
298
299 // Returns any JVM command-line option, such as "--patch-module", that's not supported by CDS.
300 static const char* find_any_unsupported_module_option() {
301 // Note that arguments.cpp has translated the command-line options into properties. If we find an
302 // unsupported property, translate it back to its command-line option for better error reporting.
303
304 // The following properties are checked by Arguments::is_internal_module_property() and cannot be
305 // directly specified in the command-line.
306 static const char* unsupported_module_properties[] = {
307 "jdk.module.limitmods",
308 "jdk.module.upgrade.path"
309 };
310 static const char* unsupported_module_options[] = {
311 "--limit-modules",
312 "--upgrade-module-path"
313 };
314
315 assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
316 SystemProperty* sp = Arguments::system_properties();
317 while (sp != nullptr) {
318 for (uint i = 0; i < ARRAY_SIZE(unsupported_module_properties); i++) {
319 if (strcmp(sp->key(), unsupported_module_properties[i]) == 0) {
320 return unsupported_module_options[i];
321 }
322 }
323 sp = sp->next();
324 }
325
326 return nullptr; // not found
327 }
328
329 void CDSConfig::check_unsupported_dumping_module_options() {
330 assert(is_dumping_archive(), "this function is only used with CDS dump time");
331 const char* option = find_any_unsupported_module_option();
332 if (option != nullptr) {
333 vm_exit_during_initialization("Cannot use the following option when dumping the shared archive", option);
334 }
335
336 if (module_patching_disables_cds()) {
337 vm_exit_during_initialization(
338 "Cannot use the following option when dumping the shared archive", "--patch-module");
339 }
340
341 // Check for an exploded module build in use with -Xshare:dump.
342 if (!Arguments::has_jimage()) {
343 vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
344 }
345 }
346
347 bool CDSConfig::has_unsupported_runtime_module_options() {
348 assert(is_using_archive(), "this function is only used with -Xshare:{on,auto}");
349 if (ArchiveClassesAtExit != nullptr) {
350 // dynamic dumping, just return false for now.
351 // check_unsupported_dumping_properties() will be called later to check the same set of
352 // properties, and will exit the VM with the correct error message if the unsupported properties
353 // are used.
354 return false;
355 }
356 const char* option = find_any_unsupported_module_option();
357 if (option != nullptr) {
358 if (RequireSharedSpaces) {
359 warning("CDS is disabled when the %s option is specified.", option);
360 } else {
361 if (new_aot_flags_used()) {
362 log_warning(cds)("AOT cache is disabled when the %s option is specified.", option);
363 } else {
364 log_info(cds)("CDS is disabled when the %s option is specified.", option);
365 }
366 }
367 return true;
368 }
369
370 if (module_patching_disables_cds()) {
371 if (RequireSharedSpaces) {
372 warning("CDS is disabled when the %s option is specified.", "--patch-module");
373 } else {
374 log_info(cds)("CDS is disabled when the %s option is specified.", "--patch-module");
375 }
376 return true;
377 }
378
379 return false;
380 }
381
382 #define CHECK_ALIAS(f) check_flag_alias(FLAG_IS_DEFAULT(f), #f)
383
384 void CDSConfig::check_flag_alias(bool alias_is_default, const char* alias_name) {
385 if (old_cds_flags_used() && !alias_is_default) {
386 vm_exit_during_initialization(err_msg("Option %s cannot be used at the same time with "
387 "-Xshare:on, -Xshare:auto, -Xshare:off, -Xshare:dump, "
388 "DumpLoadedClassList, SharedClassListFile, or SharedArchiveFile",
389 alias_name));
390 }
391 }
392
393 void CDSConfig::check_aot_flags() {
394 if (!FLAG_IS_DEFAULT(DumpLoadedClassList) ||
395 !FLAG_IS_DEFAULT(SharedClassListFile) ||
396 !FLAG_IS_DEFAULT(SharedArchiveFile)) {
397 _old_cds_flags_used = true;
398 }
472
473 void CDSConfig::check_aotmode_create() {
474 if (FLAG_IS_DEFAULT(AOTCache)) {
475 vm_exit_during_initialization("AOTCache must be specified when using -XX:AOTMode=create");
476 }
477
478 assert(FLAG_IS_DEFAULT(SharedArchiveFile), "already checked");
479
480 _is_dumping_final_static_archive = true;
481 FLAG_SET_ERGO(SharedArchiveFile, AOTConfiguration);
482 UseSharedSpaces = true;
483 RequireSharedSpaces = true;
484
485 if (!FileMapInfo::is_preimage_static_archive(AOTConfiguration)) {
486 vm_exit_during_initialization("Must be a valid AOT configuration generated by the current JVM", AOTConfiguration);
487 }
488
489 CDSConfig::enable_dumping_static_archive();
490 }
491
492 bool CDSConfig::check_vm_args_consistency(bool mode_flag_cmd_line) {
493 check_aot_flags();
494
495 if (!FLAG_IS_DEFAULT(AOTMode)) {
496 // Using any form of the new AOTMode switch enables enhanced optimizations.
497 FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
498 }
499
500 if (AOTClassLinking) {
501 // If AOTClassLinking is specified, enable all AOT optimizations by default.
502 FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);
503 } else {
504 // AOTInvokeDynamicLinking depends on AOTClassLinking.
505 FLAG_SET_ERGO(AOTInvokeDynamicLinking, false);
506 }
507
508 if (is_dumping_static_archive()) {
509 if (is_dumping_preimage_static_archive()) {
510 // Don't tweak execution mode
511 } else if (!mode_flag_cmd_line) {
512 // By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
537 return false;
538 }
539
540 if (ArchiveClassesAtExit == nullptr && !RecordDynamicDumpInfo) {
541 disable_dumping_dynamic_archive();
542 } else {
543 enable_dumping_dynamic_archive();
544 }
545
546 if (AutoCreateSharedArchive) {
547 if (SharedArchiveFile == nullptr) {
548 log_warning(cds)("-XX:+AutoCreateSharedArchive requires -XX:SharedArchiveFile");
549 return false;
550 }
551 if (ArchiveClassesAtExit != nullptr) {
552 log_warning(cds)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
553 return false;
554 }
555 }
556
557 if (is_using_archive() && java_base_module_patching_disables_cds() && module_patching_disables_cds()) {
558 Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
559 }
560 if (is_using_archive() && has_unsupported_runtime_module_options()) {
561 UseSharedSpaces = false;
562 }
563
564 if (is_dumping_archive()) {
565 // Always verify non-system classes during CDS dump
566 if (!BytecodeVerificationRemote) {
567 BytecodeVerificationRemote = true;
568 log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
569 }
570 }
571
572 return true;
573 }
574
575 bool CDSConfig::is_dumping_classic_static_archive() {
576 return _is_dumping_static_archive &&
577 !is_dumping_preimage_static_archive() &&
668 reason = "Programmatically disabled";
669 } else {
670 reason = check_options_incompatible_with_dumping_heap();
671 }
672
673 assert(reason != nullptr, "sanity");
674 log_info(cds)("Archived java heap is not supported: %s", reason);
675 }
676
677 // This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
678 bool CDSConfig::is_dumping_lambdas_in_legacy_mode() {
679 return !is_dumping_method_handles();
680 }
681
682 #if INCLUDE_CDS_JAVA_HEAP
683 bool CDSConfig::are_vm_options_incompatible_with_dumping_heap() {
684 return check_options_incompatible_with_dumping_heap() != nullptr;
685 }
686
687 bool CDSConfig::is_dumping_heap() {
688 if (is_valhalla_preview()) {
689 // Not working yet -- e.g., HeapShared::oop_hash() needs to be implemented for value oops
690 return false;
691 }
692 if (!(is_dumping_classic_static_archive() || is_dumping_final_static_archive())
693 || are_vm_options_incompatible_with_dumping_heap()
694 || _disable_heap_dumping) {
695 return false;
696 }
697 return true;
698 }
699
700 bool CDSConfig::is_loading_heap() {
701 return ArchiveHeapLoader::is_in_use();
702 }
703
704 bool CDSConfig::is_using_full_module_graph() {
705 if (ClassLoaderDataShared::is_full_module_graph_loaded()) {
706 return true;
707 }
708
709 if (!_is_using_full_module_graph) {
710 return false;
711 }
|