1 /* 2 * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 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 CDSConfig : public AllStatic { 33 #if INCLUDE_CDS 34 static bool _is_dumping_static_archive; 35 static bool _is_dumping_dynamic_archive; 36 static bool _is_using_optimized_module_handling; 37 static bool _is_dumping_full_module_graph; 38 static bool _is_using_full_module_graph; 39 40 static bool _module_patching_disables_cds; 41 static bool _java_base_module_patching_disables_cds; 42 43 static char* _default_archive_path; 44 static char* _static_archive_path; 45 static char* _dynamic_archive_path; 46 #endif 47 48 static void extract_shared_archive_paths(const char* archive_path, 49 char** base_archive_path, 50 char** top_archive_path); 51 static void init_shared_archive_paths(); 52 53 public: 54 // Used by jdk.internal.misc.CDS.getCDSConfigStatus(); 55 static const int IS_DUMPING_ARCHIVE = 1 << 0; 56 static const int IS_DUMPING_STATIC_ARCHIVE = 1 << 1; 57 static const int IS_LOGGING_LAMBDA_FORM_INVOKERS = 1 << 2; 58 static const int IS_USING_ARCHIVE = 1 << 3; 59 static int get_status() NOT_CDS_RETURN_(0); 60 61 // Initialization and command-line checking 62 static void initialize() NOT_CDS_RETURN; 63 static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN; 64 static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN; 65 static void check_unsupported_dumping_module_options() NOT_CDS_RETURN; 66 static bool has_unsupported_runtime_module_options() NOT_CDS_RETURN_(false); 67 static bool check_vm_args_consistency(bool mode_flag_cmd_line) NOT_CDS_RETURN_(true); 68 69 static bool module_patching_disables_cds() { return _module_patching_disables_cds; } 70 static void set_module_patching_disables_cds() { _module_patching_disables_cds = true; } 71 static bool java_base_module_patching_disables_cds() { return _java_base_module_patching_disables_cds; } 72 static void set_java_base_module_patching_disables_cds() { _java_base_module_patching_disables_cds = true; } 73 74 // --- Basic CDS features 75 76 // archive(s) in general 77 static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); } 78 static bool is_using_archive() NOT_CDS_RETURN_(false); 79 static int num_archives(const char* archive_path) NOT_CDS_RETURN_(0); 80 81 // static_archive 82 static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); } 83 static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); } 84 85 // dynamic_archive 86 static bool is_dumping_dynamic_archive() { return CDS_ONLY(_is_dumping_dynamic_archive) NOT_CDS(false); } 87 static void enable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = true); } 88 static void disable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = false); } 89 90 // optimized_module_handling -- can we skip some expensive operations related to modules? 91 static bool is_using_optimized_module_handling() { return CDS_ONLY(_is_using_optimized_module_handling) NOT_CDS(false); } 92 static void stop_using_optimized_module_handling() NOT_CDS_RETURN; 93 94 static bool is_logging_lambda_form_invokers() NOT_CDS_RETURN_(false); 95 96 // archive_path 97 98 // Points to the classes.jsa in $JAVA_HOME 99 static char* default_archive_path() NOT_CDS_RETURN_(nullptr); 100 // The actual static archive (if any) selected at runtime 101 static const char* static_archive_path() { return CDS_ONLY(_static_archive_path) NOT_CDS(nullptr); } 102 // The actual dynamic archive (if any) selected at runtime 103 static const char* dynamic_archive_path() { return CDS_ONLY(_dynamic_archive_path) NOT_CDS(nullptr); } 104 105 // --- Archived java objects 106 107 static bool is_dumping_heap() NOT_CDS_JAVA_HEAP_RETURN_(false); 108 109 // full_module_graph (requires optimized_module_handling) 110 static bool is_dumping_full_module_graph() { return CDS_ONLY(_is_dumping_full_module_graph) NOT_CDS(false); } 111 static bool is_using_full_module_graph() NOT_CDS_JAVA_HEAP_RETURN_(false); 112 static void stop_dumping_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN; 113 static void stop_using_full_module_graph(const char* reason = nullptr) NOT_CDS_JAVA_HEAP_RETURN; 114 115 static bool is_valhalla_preview(); 116 117 }; 118 119 #endif // SHARE_CDS_CDSCONFIG_HPP