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 class InstanceKlass;
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 static bool _is_at_aot_safepoint;
48
49 const static char* _default_archive_path;
50 const static char* _input_static_archive_path;
51 const static char* _input_dynamic_archive_path;
52 const static char* _output_archive_path;
53
54 static bool _old_cds_flags_used;
55 static bool _new_aot_flags_used;
56 static bool _disable_heap_dumping;
57
58 static JavaThread* _dumper_thread;
59 #endif
60
61 static void extract_archive_paths(const char* archive_path,
62 const char** base_archive_path,
63 const char** top_archive_path);
64 static int num_archive_paths(const char* path_spec);
65 static void check_flag_single_path(const char* flag_name, const char* value);
66
67 // Checks before Arguments::apply_ergo()
68 static void check_new_flag(bool new_flag_is_default, const char* new_flag_name);
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
109
110 // archive(s) in general
111 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
112
113 // input archive(s)
114 static bool is_using_archive() NOT_CDS_RETURN_(false);
115 static bool is_using_only_default_archive() NOT_CDS_RETURN_(false);
116
117 // static_archive
118 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
119 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
120
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 {
215 public:
216 DumperThreadMark(JavaThread* current);
217 ~DumperThreadMark();
218 };
219
220 static bool current_thread_is_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 class InstanceKlass;
35
36 class CDSConfig : public AllStatic {
37 #if INCLUDE_CDS
38 static bool _is_dumping_static_archive;
39 static bool _is_dumping_preimage_static_archive;
40 static bool _is_dumping_final_static_archive;
41 static bool _is_dumping_dynamic_archive;
42 static bool _is_using_optimized_module_handling;
43 static bool _is_dumping_full_module_graph;
44 static bool _is_using_full_module_graph;
45 static bool _has_aot_linked_classes;
46 static bool _is_single_command_training;
47 static bool _has_temp_aot_config_file;
48 static bool _is_at_aot_safepoint;
49
50 static bool _module_patching_disables_cds;
51 static bool _java_base_module_patching_disables_cds;
52
53 const static char* _default_archive_path;
54 const static char* _input_static_archive_path;
55 const static char* _input_dynamic_archive_path;
56 const static char* _output_archive_path;
57
58 static bool _old_cds_flags_used;
59 static bool _new_aot_flags_used;
60 static bool _disable_heap_dumping;
61
62 static JavaThread* _dumper_thread;
63 #endif
64
65 static void extract_archive_paths(const char* archive_path,
66 const char** base_archive_path,
67 const char** top_archive_path);
68 static int num_archive_paths(const char* path_spec);
69 static void check_flag_single_path(const char* flag_name, const char* value);
70
71 // Checks before Arguments::apply_ergo()
72 static void check_new_flag(bool new_flag_is_default, const char* new_flag_name);
84
85 public:
86 // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
87 static const int IS_DUMPING_AOT_LINKED_CLASSES = 1 << 0;
88 static const int IS_DUMPING_ARCHIVE = 1 << 1;
89 static const int IS_DUMPING_METHOD_HANDLES = 1 << 2;
90 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 3;
91 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 4;
92 static const int IS_USING_ARCHIVE = 1 << 5;
93
94 static int get_status() NOT_CDS_RETURN_(0);
95
96 // Initialization and command-line checking
97 static void ergo_initialize() NOT_CDS_RETURN;
98 static void set_old_cds_flags_used() { CDS_ONLY(_old_cds_flags_used = true); }
99 static bool old_cds_flags_used() { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
100 static bool new_aot_flags_used() { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
101 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
102 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
103 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
104 static bool check_vm_args_consistency(bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
105
106 static bool module_patching_disables_cds() { return CDS_ONLY(_module_patching_disables_cds) NOT_CDS(false); }
107 static void set_module_patching_disables_cds() { CDS_ONLY(_module_patching_disables_cds = true;) }
108 static bool java_base_module_patching_disables_cds() { return CDS_ONLY(_java_base_module_patching_disables_cds) NOT_CDS(false); }
109 static void set_java_base_module_patching_disables_cds() { CDS_ONLY(_java_base_module_patching_disables_cds = true;) }
110 static const char* type_of_archive_being_loaded();
111 static const char* type_of_archive_being_written();
112 static void prepare_for_dumping();
113
114 static bool is_at_aot_safepoint() { return CDS_ONLY(_is_at_aot_safepoint) NOT_CDS(false); }
115 static void set_is_at_aot_safepoint(bool value) { CDS_ONLY(_is_at_aot_safepoint = value); }
116
117 // --- Basic CDS features
118
119 // archive(s) in general
120 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
121
122 // input archive(s)
123 static bool is_using_archive() NOT_CDS_RETURN_(false);
124 static bool is_using_only_default_archive() NOT_CDS_RETURN_(false);
125
126 // static_archive
127 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
128 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
129
190
191 // --- Archived java objects
192
193 static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
194 static void log_reasons_for_not_dumping_heap();
195
196 static void disable_heap_dumping() { CDS_ONLY(_disable_heap_dumping = true); }
197 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
198 static bool is_loading_heap() NOT_CDS_JAVA_HEAP_RETURN_(false);
199 static bool is_initing_classes_at_dump_time() NOT_CDS_JAVA_HEAP_RETURN_(false);
200
201 static bool is_dumping_invokedynamic() NOT_CDS_JAVA_HEAP_RETURN_(false);
202 static bool is_dumping_method_handles() NOT_CDS_JAVA_HEAP_RETURN_(false);
203
204 // full_module_graph (requires optimized_module_handling)
205 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
206 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false);
207 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
208 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
209
210 static bool is_valhalla_preview() {
211 return Arguments::enable_preview() && EnableValhalla;
212 }
213
214 // --- AOT code
215
216 static bool is_dumping_aot_code() NOT_CDS_RETURN_(false);
217 static void disable_dumping_aot_code() NOT_CDS_RETURN;
218 static void enable_dumping_aot_code() NOT_CDS_RETURN;
219 static bool is_dumping_adapters() NOT_CDS_RETURN_(false);
220
221 // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
222 // they are called from:
223 // - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
224 // - The thread that performs prepatory steps before switching to the VM thread
225 // Since these two threads never execute concurrently, we can avoid using locks in these CDS
226 // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
227 class DumperThreadMark {
228 public:
229 DumperThreadMark(JavaThread* current);
230 ~DumperThreadMark();
231 };
232
233 static bool current_thread_is_dumper() NOT_CDS_RETURN_(false);
|