< prev index next >

src/hotspot/share/cds/cdsConfig.hpp

Print this page

  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 



 45   const static char* _default_archive_path;
 46   const static char* _input_static_archive_path;
 47   const static char* _input_dynamic_archive_path;
 48   const static char* _output_archive_path;
 49 
 50   static bool  _old_cds_flags_used;
 51   static bool  _new_aot_flags_used;
 52   static bool  _disable_heap_dumping;
 53 
 54   static JavaThread* _dumper_thread;
 55 #endif
 56 
 57   static void extract_archive_paths(const char* archive_path,
 58                                     const char** base_archive_path,
 59                                     const char** top_archive_path);
 60   static int num_archive_paths(const char* path_spec);
 61   static void check_flag_single_path(const char* flag_name, const char* value);
 62 
 63   // Checks before Arguments::apply_ergo()
 64   static void check_new_flag(bool new_flag_is_default, const char* new_flag_name);

 74   static void ergo_init_aot_paths();
 75 
 76 public:
 77   // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
 78   static const int IS_DUMPING_ARCHIVE              = 1 << 0;
 79   static const int IS_DUMPING_METHOD_HANDLES       = 1 << 1;
 80   static const int IS_DUMPING_STATIC_ARCHIVE       = 1 << 2;
 81   static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 3;
 82   static const int IS_USING_ARCHIVE                = 1 << 4;
 83 
 84   static int get_status() NOT_CDS_RETURN_(0);
 85 
 86   // Initialization and command-line checking
 87   static void ergo_initialize() NOT_CDS_RETURN;
 88   static void set_old_cds_flags_used()                       { CDS_ONLY(_old_cds_flags_used = true); }
 89   static bool old_cds_flags_used()                           { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
 90   static bool new_aot_flags_used()                           { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
 91   static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
 92   static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
 93   static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
 94   static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);





 95   static const char* type_of_archive_being_loaded();
 96   static const char* type_of_archive_being_written();
 97   static void prepare_for_dumping();
 98 
 99   // --- Basic CDS features
100 
101   // archive(s) in general
102   static bool is_dumping_archive()                           { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
103 
104   // input archive(s)
105   static bool is_using_archive()                             NOT_CDS_RETURN_(false);
106   static bool is_using_only_default_archive()                NOT_CDS_RETURN_(false);
107 
108   // static_archive
109   static bool is_dumping_static_archive()                    { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
110   static void enable_dumping_static_archive()                { CDS_ONLY(_is_dumping_static_archive = true); }
111 
112   // A static CDS archive can be dumped in three modes:
113   //
114   // "classic"   - This is the traditional CDS workflow of

165 
166   // --- Archived java objects
167 
168   static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
169   static void log_reasons_for_not_dumping_heap();
170 
171   static void disable_heap_dumping()                         { CDS_ONLY(_disable_heap_dumping = true); }
172   static bool is_dumping_heap()                              NOT_CDS_JAVA_HEAP_RETURN_(false);
173   static bool is_loading_heap()                              NOT_CDS_JAVA_HEAP_RETURN_(false);
174   static bool is_initing_classes_at_dump_time()              NOT_CDS_JAVA_HEAP_RETURN_(false);
175 
176   static bool is_dumping_invokedynamic()                     NOT_CDS_JAVA_HEAP_RETURN_(false);
177   static bool is_dumping_method_handles()                    NOT_CDS_JAVA_HEAP_RETURN_(false);
178 
179   // full_module_graph (requires optimized_module_handling)
180   static bool is_dumping_full_module_graph()                 { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
181   static bool is_using_full_module_graph()                   NOT_CDS_JAVA_HEAP_RETURN_(false);
182   static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
183   static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
184 




185   // --- AOT code
186 
187   static bool is_dumping_aot_code()                          NOT_CDS_RETURN_(false);
188   static void disable_dumping_aot_code()                     NOT_CDS_RETURN;
189   static void enable_dumping_aot_code()                      NOT_CDS_RETURN;
190   static bool is_dumping_adapters()                          NOT_CDS_RETURN_(false);
191 
192   // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
193   // they are called from:
194   //    - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
195   //    - The thread that performs prepatory steps before switching to the VM thread
196   // Since these two threads never execute concurrently, we can avoid using locks in these CDS
197   // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
198   class DumperThreadMark {
199   public:
200     DumperThreadMark(JavaThread* current);
201     ~DumperThreadMark();
202   };
203 
204   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 
 46   static bool _module_patching_disables_cds;
 47   static bool _java_base_module_patching_disables_cds;
 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);

 78   static void ergo_init_aot_paths();
 79 
 80 public:
 81   // Used by jdk.internal.misc.CDS.getCDSConfigStatus();
 82   static const int IS_DUMPING_ARCHIVE              = 1 << 0;
 83   static const int IS_DUMPING_METHOD_HANDLES       = 1 << 1;
 84   static const int IS_DUMPING_STATIC_ARCHIVE       = 1 << 2;
 85   static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 3;
 86   static const int IS_USING_ARCHIVE                = 1 << 4;
 87 
 88   static int get_status() NOT_CDS_RETURN_(0);
 89 
 90   // Initialization and command-line checking
 91   static void ergo_initialize() NOT_CDS_RETURN;
 92   static void set_old_cds_flags_used()                       { CDS_ONLY(_old_cds_flags_used = true); }
 93   static bool old_cds_flags_used()                           { return CDS_ONLY(_old_cds_flags_used) NOT_CDS(false); }
 94   static bool new_aot_flags_used()                           { return CDS_ONLY(_new_aot_flags_used) NOT_CDS(false); }
 95   static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
 96   static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
 97   static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false);
 98   static bool check_vm_args_consistency(bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
 99 
100   static bool module_patching_disables_cds() { return CDS_ONLY(_module_patching_disables_cds) NOT_CDS(false); }
101   static void set_module_patching_disables_cds() { CDS_ONLY(_module_patching_disables_cds = true;) }
102   static bool java_base_module_patching_disables_cds() { return CDS_ONLY(_java_base_module_patching_disables_cds) NOT_CDS(false); }
103   static void set_java_base_module_patching_disables_cds() { CDS_ONLY(_java_base_module_patching_disables_cds = true;) }
104   static const char* type_of_archive_being_loaded();
105   static const char* type_of_archive_being_written();
106   static void prepare_for_dumping();
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 
121   // A static CDS archive can be dumped in three modes:
122   //
123   // "classic"   - This is the traditional CDS workflow of

174 
175   // --- Archived java objects
176 
177   static bool are_vm_options_incompatible_with_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(true);
178   static void log_reasons_for_not_dumping_heap();
179 
180   static void disable_heap_dumping()                         { CDS_ONLY(_disable_heap_dumping = true); }
181   static bool is_dumping_heap()                              NOT_CDS_JAVA_HEAP_RETURN_(false);
182   static bool is_loading_heap()                              NOT_CDS_JAVA_HEAP_RETURN_(false);
183   static bool is_initing_classes_at_dump_time()              NOT_CDS_JAVA_HEAP_RETURN_(false);
184 
185   static bool is_dumping_invokedynamic()                     NOT_CDS_JAVA_HEAP_RETURN_(false);
186   static bool is_dumping_method_handles()                    NOT_CDS_JAVA_HEAP_RETURN_(false);
187 
188   // full_module_graph (requires optimized_module_handling)
189   static bool is_dumping_full_module_graph()                 { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); }
190   static bool is_using_full_module_graph()                   NOT_CDS_JAVA_HEAP_RETURN_(false);
191   static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
192   static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN;
193 
194   static bool is_valhalla_preview() {
195     return Arguments::enable_preview() && EnableValhalla;
196   }
197 
198   // --- AOT code
199 
200   static bool is_dumping_aot_code()                          NOT_CDS_RETURN_(false);
201   static void disable_dumping_aot_code()                     NOT_CDS_RETURN;
202   static void enable_dumping_aot_code()                      NOT_CDS_RETURN;
203   static bool is_dumping_adapters()                          NOT_CDS_RETURN_(false);
204 
205   // Some CDS functions assume that they are called only within a single-threaded context. I.e.,
206   // they are called from:
207   //    - The VM thread (e.g., inside VM_PopulateDumpSharedSpace)
208   //    - The thread that performs prepatory steps before switching to the VM thread
209   // Since these two threads never execute concurrently, we can avoid using locks in these CDS
210   // function. For safety, these functions should assert with CDSConfig::current_thread_is_vm_or_dumper().
211   class DumperThreadMark {
212   public:
213     DumperThreadMark(JavaThread* current);
214     ~DumperThreadMark();
215   };
216 
217   static bool current_thread_is_vm_or_dumper() NOT_CDS_RETURN_(false);
< prev index next >