25 #ifndef SHARE_CDS_CDSCONFIG_HPP
26 #define SHARE_CDS_CDSCONFIG_HPP
27
28 #include "memory/allStatic.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #include "utilities/macros.hpp"
31
32 class JavaThread;
33
34 class CDSConfig : public AllStatic {
35 #if INCLUDE_CDS
36 static bool _is_dumping_static_archive;
37 static bool _is_dumping_preimage_static_archive;
38 static bool _is_dumping_final_static_archive;
39 static bool _is_dumping_dynamic_archive;
40 static bool _is_using_optimized_module_handling;
41 static bool _is_dumping_full_module_graph;
42 static bool _is_using_full_module_graph;
43 static bool _has_aot_linked_classes;
44
45 static char* _default_archive_path;
46 static char* _static_archive_path;
47 static char* _dynamic_archive_path;
48
49 static bool _old_cds_flags_used;
50 static bool _new_aot_flags_used;
51 static bool _disable_heap_dumping;
52
53 static JavaThread* _dumper_thread;
54 #endif
55
56 static void extract_shared_archive_paths(const char* archive_path,
57 char** base_archive_path,
58 char** top_archive_path);
59 static void init_shared_archive_paths();
60
61 static void check_flag_alias(bool alias_is_default, const char* alias_name);
62 static void check_aot_flags();
63 static void check_aotmode_off();
64 static void check_aotmode_auto_or_on();
65 static void check_aotmode_record();
66 static void check_aotmode_create();
67
68 public:
69 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
70 static const int IS_DUMPING_ARCHIVE = 1 << 0;
71 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 1;
72 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 2;
73 static const int IS_USING_ARCHIVE = 1 << 3;
74 static int get_status() NOT_CDS_RETURN_(0);
75
76 // Initialization and command-line checking
77 static void initialize() NOT_CDS_RETURN;
78 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
79 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
80 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
81 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
82 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
83 static void check_unsupported_dumping_module_options() NOT_CDS_RETURN;
84 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
85 static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
86 static const char* type_of_archive_being_loaded();
87 static const char* type_of_archive_being_written();
88
89 // --- Basic CDS features
90
91 // archive(s) in general
92 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
93 static bool is_using_archive() NOT_CDS_RETURN_(false);
94 static int num_archives(const char* archive_path) NOT_CDS_RETURN_(0);
95
96 // static_archive
97 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
98 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
99
100 // A static CDS archive can be dumped in three modes:
101 //
102 // "classic" - This is the traditional CDS workflow of
103 // "java -Xshare:dump -XX:SharedClassListFile=file.txt".
104 //
105 // "preimage" - This happens when we execute the JEP 483 training run, e.g:
150
151 // --- Archived java objects
152
153 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
154 static void log_reasons_for_not_dumping_heap();
155
156 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
157 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
158 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
159 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
160
161 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
162 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
163
164 // full_module_graph (requires optimized_module_handling)
165 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
166 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
167 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
168 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
169
170 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
171 // they are called from:
172 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
173 // - The thread that performs prepatory steps before switching to the VM thread
174 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
175 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
176 class DumperThreadMark {
177 public:
178 DumperThreadMark(JavaThread* current);
179 ~DumperThreadMark();
180 };
181
182 static bool current_thread_is_vm_or_dumper() NOT_CDS_RETURN_(false);
183 };
184
185 #endif // SHARE_CDS_CDSCONFIG_HPP
|
25 #ifndef SHARE_CDS_CDSCONFIG_HPP
26 #define SHARE_CDS_CDSCONFIG_HPP
27
28 #include "memory/allStatic.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #include "utilities/macros.hpp"
31
32 class JavaThread;
33
34 class CDSConfig : public AllStatic {
35 #if INCLUDE_CDS
36 static bool _is_dumping_static_archive;
37 static bool _is_dumping_preimage_static_archive;
38 static bool _is_dumping_final_static_archive;
39 static bool _is_dumping_dynamic_archive;
40 static bool _is_using_optimized_module_handling;
41 static bool _is_dumping_full_module_graph;
42 static bool _is_using_full_module_graph;
43 static bool _has_aot_linked_classes;
44
45 static bool _module_patching_disables_cds;
46 static bool _java_base_module_patching_disables_cds;
47
48 static char* _default_archive_path;
49 static char* _static_archive_path;
50 static char* _dynamic_archive_path;
51
52 static bool _old_cds_flags_used;
53 static bool _new_aot_flags_used;
54 static bool _disable_heap_dumping;
55
56 static JavaThread* _dumper_thread;
57 #endif
58
59 static void extract_shared_archive_paths(const char* archive_path,
60 char** base_archive_path,
61 char** top_archive_path);
62 static void init_shared_archive_paths();
63
64 static void check_flag_alias(bool alias_is_default, const char* alias_name);
65 static void check_aot_flags();
66 static void check_aotmode_off();
67 static void check_aotmode_auto_or_on();
68 static void check_aotmode_record();
69 static void check_aotmode_create();
70
71 public:
72 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
73 static const int IS_DUMPING_ARCHIVE = 1 << 0;
74 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 1;
75 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 2;
76 static const int IS_USING_ARCHIVE = 1 << 3;
77 static int get_status() NOT_CDS_RETURN_(0);
78
79 // Initialization and command-line checking
80 static void initialize() NOT_CDS_RETURN;
81 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
82 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
83 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
84 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
85 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
86 static void check_unsupported_dumping_module_options() NOT_CDS_RETURN;
87 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
88 static bool check_vm_args_consistency(bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
89
90 static bool module_patching_disables_cds() { return _module_patching_disables_cds; }
91 static void set_module_patching_disables_cds() { _module_patching_disables_cds = true; }
92 static bool java_base_module_patching_disables_cds() { return _java_base_module_patching_disables_cds; }
93 static void set_java_base_module_patching_disables_cds() { _java_base_module_patching_disables_cds = true; }
94 static const char* type_of_archive_being_loaded();
95 static const char* type_of_archive_being_written();
96
97 // --- Basic CDS features
98
99 // archive(s) in general
100 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
101 static bool is_using_archive() NOT_CDS_RETURN_(false);
102 static int num_archives(const char* archive_path) NOT_CDS_RETURN_(0);
103
104 // static_archive
105 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
106 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
107
108 // A static CDS archive can be dumped in three modes:
109 //
110 // "classic" - This is the traditional CDS workflow of
111 // "java -Xshare:dump -XX:SharedClassListFile=file.txt".
112 //
113 // "preimage" - This happens when we execute the JEP 483 training run, e.g:
158
159 // --- Archived java objects
160
161 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
162 static void log_reasons_for_not_dumping_heap();
163
164 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
165 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
166 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
167 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
168
169 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
170 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
171
172 // full_module_graph (requires optimized_module_handling)
173 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
174 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
175 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
176 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
177
178 static bool is_valhalla_preview();
179
180 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
181 // they are called from:
182 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
183 // - The thread that performs prepatory steps before switching to the VM thread
184 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
185 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
186 class DumperThreadMark {
187 public:
188 DumperThreadMark(JavaThread* current);
189 ~DumperThreadMark();
190 };
191
192 static bool current_thread_is_vm_or_dumper() NOT_CDS_RETURN_(false);
193 };
194
195 #endif // SHARE_CDS_CDSCONFIG_HPP
|