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