69 static void check_aot_flags();
70 static void check_aotmode_off();
71 static void check_aotmode_auto_or_on();
72 static void check_aotmode_record();
73 static void check_aotmode_create();
74 static void setup_compiler_args();
75 static void check_unsupported_dumping_module_options();
76
77 // Called after Arguments::apply_ergo() has started
78 static void ergo_init_classic_archive_paths();
79 static void ergo_init_aot_paths();
80
81 public:
82 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
83 static const int IS_DUMPING_AOT_LINKED_CLASSES = 1 << 0;
84 static const int IS_DUMPING_ARCHIVE = 1 << 1;
85 static const int IS_DUMPING_METHOD_HANDLES = 1 << 2;
86 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 3;
87 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 4;
88 static const int IS_USING_ARCHIVE = 1 << 5;
89
90 static int get_status() NOT_CDS_RETURN_(0);
91
92 // Initialization and command-line checking
93 static void ergo_initialize() NOT_CDS_RETURN;
94 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
95 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
96 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
97 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
98 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
99 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
100 static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
101 static const char* type_of_archive_being_loaded();
102 static const char* type_of_archive_being_written();
103 static void prepare_for_dumping();
104
105 static bool is_at_aot_safepoint() { return CDS_ONLY(_is_at_aot_safepoint) NOT_CDS(false); }
106 static void set_is_at_aot_safepoint(bool value) { CDS_ONLY(_is_at_aot_safepoint = value); }
107
108 // --- Basic CDS features
121 // A static CDS archive can be dumped in three modes:
122 //
123 // "classic" - This is the traditional CDS workflow of
124 // "java -Xshare:dump -XX:SharedClassListFile=file.txt".
125 //
126 // "preimage" - This happens when we execute the JEP 483 training run, e.g:
127 // "java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconfig -cp app.jar App"
128 // The above command writes app.aotconfig as a "CDS preimage". This
129 // is a binary file that contains all the classes loaded during the
130 // training run, plus profiling data (e.g., the resolved constant pool entries).
131 //
132 // "final" - This happens when we execute the JEP 483 assembly phase, e.g:
133 // "java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconfig -XX:AOTCache=app.aot -cp app.jar"
134 // The above command loads all classes from app.aotconfig, perform additional linking,
135 // and writes app.aot as a "CDS final image" file.
136 //
137 // The main structural difference between "preimage" and "final" is that the preimage
138 // - has a different magic number (0xcafea07c)
139 // - does not have any archived Java heap objects
140 // - does not have aot-linked classes
141 static bool is_dumping_classic_static_archive() NOT_CDS_RETURN_(false);
142 static bool is_dumping_preimage_static_archive() NOT_CDS_RETURN_(false);
143 static bool is_dumping_final_static_archive() NOT_CDS_RETURN_(false);
144
145 // dynamic_archive
146 static bool is_dumping_dynamic_archive() { return CDS_ONLY(_is_dumping_dynamic_archive) NOT_CDS(false); }
147 static void enable_dumping_dynamic_archive(const char* output_path) NOT_CDS_RETURN;
148 static void disable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = false); }
149
150 // Misc CDS features
151 static bool allow_only_single_java_thread() NOT_CDS_RETURN_(false);
152
153 static bool is_single_command_training() { return CDS_ONLY(_is_single_command_training) NOT_CDS(false); }
154 static bool has_temp_aot_config_file() { return CDS_ONLY(_has_temp_aot_config_file) NOT_CDS(false); }
155
156 // This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
157 static bool is_dumping_lambdas_in_legacy_mode() NOT_CDS_RETURN_(false);
158
159 // optimized_module_handling -- can we skip some expensive operations related to modules?
160 static bool is_using_optimized_module_handling() { return CDS_ONLY(_is_using_optimized_module_handling) NOT_CDS(false); }
161 static void stop_using_optimized_module_handling() NOT_CDS_RETURN;
162
163 static bool is_logging_lambda_form_invokers() NOT_CDS_RETURN_(false);
175
176 // Points to the classes.jsa in $JAVA_HOME (could be input or output)
177 static const char* default_archive_path() NOT_CDS_RETURN_(nullptr);
178 static const char* input_static_archive_path() { return CDS_ONLY(_input_static_archive_path) NOT_CDS(nullptr); }
179 static const char* input_dynamic_archive_path() { return CDS_ONLY(_input_dynamic_archive_path) NOT_CDS(nullptr); }
180 static const char* output_archive_path() { return CDS_ONLY(_output_archive_path) NOT_CDS(nullptr); }
181
182 // --- Archived java objects
183
184 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
185 static void log_reasons_for_not_dumping_heap();
186
187 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
188 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
189 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
190 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
191
192 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
193 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
194
195 // full_module_graph (requires optimized_module_handling)
196 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
197 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
198 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
199 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
200
201 // --- AOT code
202
203 static bool is_dumping_aot_code() NOT_CDS_RETURN_(false);
204 static void disable_dumping_aot_code() NOT_CDS_RETURN;
205 static void enable_dumping_aot_code() NOT_CDS_RETURN;
206 static bool is_dumping_adapters() NOT_CDS_RETURN_(false);
207
208 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
209 // they are called from:
210 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
211 // - The thread that performs prepatory steps before switching to the VM thread
212 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
213 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
214 class DumperThreadMark {
|
69 static void check_aot_flags();
70 static void check_aotmode_off();
71 static void check_aotmode_auto_or_on();
72 static void check_aotmode_record();
73 static void check_aotmode_create();
74 static void setup_compiler_args();
75 static void check_unsupported_dumping_module_options();
76
77 // Called after Arguments::apply_ergo() has started
78 static void ergo_init_classic_archive_paths();
79 static void ergo_init_aot_paths();
80
81 public:
82 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
83 static const int IS_DUMPING_AOT_LINKED_CLASSES = 1 << 0;
84 static const int IS_DUMPING_ARCHIVE = 1 << 1;
85 static const int IS_DUMPING_METHOD_HANDLES = 1 << 2;
86 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 3;
87 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 4;
88 static const int IS_USING_ARCHIVE = 1 << 5;
89 static const int IS_DUMPING_HEAP = 1 << 6;
90 static const int IS_LOGGING_DYNAMIC_PROXIES = 1 << 7;
91
92 static int get_status() NOT_CDS_RETURN_(0);
93
94 // Initialization and command-line checking
95 static void ergo_initialize() NOT_CDS_RETURN;
96 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
97 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
98 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
99 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
100 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
101 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
102 static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
103 static const char* type_of_archive_being_loaded();
104 static const char* type_of_archive_being_written();
105 static void prepare_for_dumping();
106
107 static bool is_at_aot_safepoint() { return CDS_ONLY(_is_at_aot_safepoint) NOT_CDS(false); }
108 static void set_is_at_aot_safepoint(bool value) { CDS_ONLY(_is_at_aot_safepoint = value); }
109
110 // --- Basic CDS features
123 // A static CDS archive can be dumped in three modes:
124 //
125 // "classic" - This is the traditional CDS workflow of
126 // "java -Xshare:dump -XX:SharedClassListFile=file.txt".
127 //
128 // "preimage" - This happens when we execute the JEP 483 training run, e.g:
129 // "java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconfig -cp app.jar App"
130 // The above command writes app.aotconfig as a "CDS preimage". This
131 // is a binary file that contains all the classes loaded during the
132 // training run, plus profiling data (e.g., the resolved constant pool entries).
133 //
134 // "final" - This happens when we execute the JEP 483 assembly phase, e.g:
135 // "java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconfig -XX:AOTCache=app.aot -cp app.jar"
136 // The above command loads all classes from app.aotconfig, perform additional linking,
137 // and writes app.aot as a "CDS final image" file.
138 //
139 // The main structural difference between "preimage" and "final" is that the preimage
140 // - has a different magic number (0xcafea07c)
141 // - does not have any archived Java heap objects
142 // - does not have aot-linked classes
143 static bool is_dumping_classic_static_archive() NOT_CDS_RETURN_(false);
144 static bool is_dumping_preimage_static_archive() NOT_CDS_RETURN_(false);
145 static bool is_dumping_preimage_static_archive_with_triggers() NOT_CDS_RETURN_(false);
146 static bool is_dumping_final_static_archive() NOT_CDS_RETURN_(false);
147
148 // dynamic_archive
149 static bool is_dumping_dynamic_archive() { return CDS_ONLY(_is_dumping_dynamic_archive) NOT_CDS(false); }
150 static void enable_dumping_dynamic_archive(const char* output_path) NOT_CDS_RETURN;
151 static void disable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = false); }
152
153 // Misc CDS features
154 static bool allow_only_single_java_thread() NOT_CDS_RETURN_(false);
155
156 static bool is_single_command_training() { return CDS_ONLY(_is_single_command_training) NOT_CDS(false); }
157 static bool has_temp_aot_config_file() { return CDS_ONLY(_has_temp_aot_config_file) NOT_CDS(false); }
158
159 // This is *Legacy* optimization for lambdas before JEP 483. May be removed in the future.
160 static bool is_dumping_lambdas_in_legacy_mode() NOT_CDS_RETURN_(false);
161
162 // optimized_module_handling -- can we skip some expensive operations related to modules?
163 static bool is_using_optimized_module_handling() { return CDS_ONLY(_is_using_optimized_module_handling) NOT_CDS(false); }
164 static void stop_using_optimized_module_handling() NOT_CDS_RETURN;
165
166 static bool is_logging_lambda_form_invokers() NOT_CDS_RETURN_(false);
178
179 // Points to the classes.jsa in $JAVA_HOME (could be input or output)
180 static const char* default_archive_path() NOT_CDS_RETURN_(nullptr);
181 static const char* input_static_archive_path() { return CDS_ONLY(_input_static_archive_path) NOT_CDS(nullptr); }
182 static const char* input_dynamic_archive_path() { return CDS_ONLY(_input_dynamic_archive_path) NOT_CDS(nullptr); }
183 static const char* output_archive_path() { return CDS_ONLY(_output_archive_path) NOT_CDS(nullptr); }
184
185 // --- Archived java objects
186
187 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
188 static void log_reasons_for_not_dumping_heap();
189
190 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
191 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
192 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
193 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
194
195 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
196 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
197
198 static bool is_dumping_reflection_data() NOT_CDS_JAVA_HEAP_RETURN_(false);
199
200 static bool is_dumping_dynamic_proxies() NOT_CDS_JAVA_HEAP_RETURN_(false);
201 static bool is_logging_dynamic_proxies() NOT_CDS_RETURN_(false);
202
203 // full_module_graph (requires optimized_module_handling)
204 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
205 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
206 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
207 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
208
209 // --- AOT code
210
211 static bool is_dumping_aot_code() NOT_CDS_RETURN_(false);
212 static void disable_dumping_aot_code() NOT_CDS_RETURN;
213 static void enable_dumping_aot_code() NOT_CDS_RETURN;
214 static bool is_dumping_adapters() NOT_CDS_RETURN_(false);
215
216 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
217 // they are called from:
218 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
219 // - The thread that performs prepatory steps before switching to the VM thread
220 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
221 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
222 class DumperThreadMark {
|