9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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 #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 static bool _is_single_command_training;
45 static bool _has_temp_aot_config_file;
46
47 const static char* _default_archive_path;
48 const static char* _input_static_archive_path;
49 const static char* _input_dynamic_archive_path;
50 const static char* _output_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_archive_paths(const char* archive_path,
60 const char** base_archive_path,
61 const char** top_archive_path);
62 static int num_archive_paths(const char* path_spec);
63 static void check_flag_single_path(const char* flag_name, const char* value);
64
65 // Checks before Arguments::apply_ergo()
66 static void check_new_flag(bool new_flag_is_default, const char* new_flag_name);
77 static void ergo_init_aot_paths();
78
79 public:
80 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
81 static const int IS_DUMPING_ARCHIVE = 1 << 0;
82 static const int IS_DUMPING_METHOD_HANDLES = 1 << 1;
83 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 2;
84 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 3;
85 static const int IS_USING_ARCHIVE = 1 << 4;
86
87 static int get_status() NOT_CDS_RETURN_(0);
88
89 // Initialization and command-line checking
90 static void ergo_initialize() NOT_CDS_RETURN;
91 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
92 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
93 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
94 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
95 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
96 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
97 static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
98 static const char* type_of_archive_being_loaded();
99 static const char* type_of_archive_being_written();
100 static void prepare_for_dumping();
101
102 // --- Basic CDS features
103
104 // archive(s) in general
105 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
106
107 // input archive(s)
108 static bool is_using_archive() NOT_CDS_RETURN_(false);
109 static bool is_using_only_default_archive() NOT_CDS_RETURN_(false);
110
111 // static_archive
112 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
113 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
114
115 // A static CDS archive can be dumped in three modes:
116 //
117 // "classic" - This is the traditional CDS workflow of
171
172 // --- Archived java objects
173
174 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
175 static void log_reasons_for_not_dumping_heap();
176
177 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
178 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
179 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
180 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
181
182 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
183 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
184
185 // full_module_graph (requires optimized_module_handling)
186 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
187 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
188 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
189 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
190
191 // --- AOT code
192
193 static bool is_dumping_aot_code() NOT_CDS_RETURN_(false);
194 static void disable_dumping_aot_code() NOT_CDS_RETURN;
195 static void enable_dumping_aot_code() NOT_CDS_RETURN;
196 static bool is_dumping_adapters() NOT_CDS_RETURN_(false);
197
198 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
199 // they are called from:
200 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
201 // - The thread that performs prepatory steps before switching to the VM thread
202 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
203 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
204 class DumperThreadMark {
205 public:
206 DumperThreadMark(JavaThread* current);
207 ~DumperThreadMark();
208 };
209
210 static bool current_thread_is_vm_or_dumper() NOT_CDS_RETURN_(false);
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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 #ifndef SHARE_CDS_CDSCONFIG_HPP
26 #define SHARE_CDS_CDSCONFIG_HPP
27
28 #include "memory/allStatic.hpp"
29 #include "runtime/arguments.hpp"
30 #include "utilities/globalDefinitions.hpp"
31 #include "utilities/macros.hpp"
32
33 class JavaThread;
34
35 class CDSConfig : public AllStatic {
36 #if INCLUDE_CDS
37 static bool _is_dumping_static_archive;
38 static bool _is_dumping_preimage_static_archive;
39 static bool _is_dumping_final_static_archive;
40 static bool _is_dumping_dynamic_archive;
41 static bool _is_using_optimized_module_handling;
42 static bool _is_dumping_full_module_graph;
43 static bool _is_using_full_module_graph;
44 static bool _has_aot_linked_classes;
45 static bool _is_single_command_training;
46 static bool _has_temp_aot_config_file;
47
48 static bool _module_patching_disables_cds;
49 static bool _java_base_module_patching_disables_cds;
50
51 const static char* _default_archive_path;
52 const static char* _input_static_archive_path;
53 const static char* _input_dynamic_archive_path;
54 const static char* _output_archive_path;
55
56 static bool _old_cds_flags_used;
57 static bool _new_aot_flags_used;
58 static bool _disable_heap_dumping;
59
60 static JavaThread* _dumper_thread;
61 #endif
62
63 static void extract_archive_paths(const char* archive_path,
64 const char** base_archive_path,
65 const char** top_archive_path);
66 static int num_archive_paths(const char* path_spec);
67 static void check_flag_single_path(const char* flag_name, const char* value);
68
69 // Checks before Arguments::apply_ergo()
70 static void check_new_flag(bool new_flag_is_default, const char* new_flag_name);
81 static void ergo_init_aot_paths();
82
83 public:
84 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
85 static const int IS_DUMPING_ARCHIVE = 1 << 0;
86 static const int IS_DUMPING_METHOD_HANDLES = 1 << 1;
87 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 2;
88 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 3;
89 static const int IS_USING_ARCHIVE = 1 << 4;
90
91 static int get_status() NOT_CDS_RETURN_(0);
92
93 // Initialization and command-line checking
94 static void ergo_initialize() NOT_CDS_RETURN;
95 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
96 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
97 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
98 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
99 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
100 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
101 static bool check_vm_args_consistency(bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
102
103 static bool module_patching_disables_cds() { return CDS_ONLY(_module_patching_disables_cds) NOT_CDS(false); }
104 static void set_module_patching_disables_cds() { CDS_ONLY(_module_patching_disables_cds = true;) }
105 static bool java_base_module_patching_disables_cds() { return CDS_ONLY(_java_base_module_patching_disables_cds) NOT_CDS(false); }
106 static void set_java_base_module_patching_disables_cds() { CDS_ONLY(_java_base_module_patching_disables_cds = true;) }
107 static const char* type_of_archive_being_loaded();
108 static const char* type_of_archive_being_written();
109 static void prepare_for_dumping();
110
111 // --- Basic CDS features
112
113 // archive(s) in general
114 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
115
116 // input archive(s)
117 static bool is_using_archive() NOT_CDS_RETURN_(false);
118 static bool is_using_only_default_archive() NOT_CDS_RETURN_(false);
119
120 // static_archive
121 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
122 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
123
124 // A static CDS archive can be dumped in three modes:
125 //
126 // "classic" - This is the traditional CDS workflow of
180
181 // --- Archived java objects
182
183 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
184 static void log_reasons_for_not_dumping_heap();
185
186 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
187 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
188 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
189 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
190
191 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
192 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
193
194 // full_module_graph (requires optimized_module_handling)
195 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
196 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
197 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
198 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
199
200 static bool is_valhalla_preview() {
201 return Arguments::enable_preview() && EnableValhalla;
202 }
203
204 // --- AOT code
205
206 static bool is_dumping_aot_code() NOT_CDS_RETURN_(false);
207 static void disable_dumping_aot_code() NOT_CDS_RETURN;
208 static void enable_dumping_aot_code() NOT_CDS_RETURN;
209 static bool is_dumping_adapters() NOT_CDS_RETURN_(false);
210
211 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
212 // they are called from:
213 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
214 // - The thread that performs prepatory steps before switching to the VM thread
215 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
216 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
217 class DumperThreadMark {
218 public:
219 DumperThreadMark(JavaThread* current);
220 ~DumperThreadMark();
221 };
222
223 static bool current_thread_is_vm_or_dumper() NOT_CDS_RETURN_(false);
|