< prev index next >

src/hotspot/share/cds/cdsConfig.cpp

Print this page
*** 31,19 ***
--- 31,28 ---
  #include "classfile/moduleEntry.hpp"
  #include "include/jvm_io.h"
  #include "logging/log.hpp"
  #include "memory/universe.hpp"
  #include "runtime/arguments.hpp"
+ #include "runtime/globals.hpp"
  #include "runtime/java.hpp"
  #include "utilities/defaultStream.hpp"
  
  bool CDSConfig::_is_dumping_static_archive = false;
  bool CDSConfig::_is_dumping_dynamic_archive = false;
  bool CDSConfig::_is_using_optimized_module_handling = true;
  bool CDSConfig::_is_dumping_full_module_graph = true;
  bool CDSConfig::_is_using_full_module_graph = true;
  
+ bool CDSConfig::_module_patching_disables_cds = false;
+ bool CDSConfig::_java_base_module_patching_disables_cds = false;
+ 
+ bool CDSConfig::is_valhalla_preview() {
+   return Arguments::enable_preview() && EnableValhalla;
+ }
+ 
+ 
  char* CDSConfig::_default_archive_path = nullptr;
  char* CDSConfig::_static_archive_path = nullptr;
  char* CDSConfig::_dynamic_archive_path = nullptr;
  
  int CDSConfig::get_status() {

*** 82,15 ***
      os::jvm_path(jvm_path, sizeof(jvm_path));
      char *end = strrchr(jvm_path, *os::file_separator());
      if (end != nullptr) *end = '\0';
      size_t jvm_path_len = strlen(jvm_path);
      size_t file_sep_len = strlen(os::file_separator());
!     const size_t len = jvm_path_len + file_sep_len + 20;
      _default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
!     jio_snprintf(_default_archive_path, len,
!                 LP64_ONLY(!UseCompressedOops ? "%s%sclasses_nocoops.jsa":) "%s%sclasses.jsa",
!                 jvm_path, os::file_separator());
    }
    return _default_archive_path;
  }
  
  int CDSConfig::num_archives(const char* archive_path) {
--- 91,19 ---
      os::jvm_path(jvm_path, sizeof(jvm_path));
      char *end = strrchr(jvm_path, *os::file_separator());
      if (end != nullptr) *end = '\0';
      size_t jvm_path_len = strlen(jvm_path);
      size_t file_sep_len = strlen(os::file_separator());
!     const size_t len = jvm_path_len + file_sep_len + strlen("classes_nocoops_valhalla.jsa") + 1;
      _default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
!     LP64_ONLY(bool nocoops = !UseCompressedOops);
!     NOT_LP64(bool nocoops = false);
!     bool valhalla = is_valhalla_preview();
+     jio_snprintf(_default_archive_path, len, "%s%sclasses%s%s.jsa",
+                 jvm_path, os::file_separator(),
+                  nocoops ? "_nocoops" : "",
+                  valhalla ? "_valhalla" : "");
    }
    return _default_archive_path;
  }
  
  int CDSConfig::num_archives(const char* archive_path) {

*** 269,17 ***
  
    // The following properties are checked by Arguments::is_internal_module_property() and cannot be
    // directly specified in the command-line.
    static const char* unsupported_module_properties[] = {
      "jdk.module.limitmods",
!     "jdk.module.upgrade.path",
-     "jdk.module.patch.0"
    };
    static const char* unsupported_module_options[] = {
      "--limit-modules",
!     "--upgrade-module-path",
-     "--patch-module"
    };
  
    assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
    SystemProperty* sp = Arguments::system_properties();
    while (sp != nullptr) {
--- 282,15 ---
  
    // The following properties are checked by Arguments::is_internal_module_property() and cannot be
    // directly specified in the command-line.
    static const char* unsupported_module_properties[] = {
      "jdk.module.limitmods",
!     "jdk.module.upgrade.path"
    };
    static const char* unsupported_module_options[] = {
      "--limit-modules",
!     "--upgrade-module-path"
    };
  
    assert(ARRAY_SIZE(unsupported_module_properties) == ARRAY_SIZE(unsupported_module_options), "must be");
    SystemProperty* sp = Arguments::system_properties();
    while (sp != nullptr) {

*** 298,10 ***
--- 309,16 ---
    assert(is_dumping_archive(), "this function is only used with CDS dump time");
    const char* option = find_any_unsupported_module_option();
    if (option != nullptr) {
      vm_exit_during_initialization("Cannot use the following option when dumping the shared archive", option);
    }
+ 
+   if (module_patching_disables_cds()) {
+     vm_exit_during_initialization(
+             "Cannot use the following option when dumping the shared archive", "--patch-module");
+   }
+ 
    // Check for an exploded module build in use with -Xshare:dump.
    if (!Arguments::has_jimage()) {
      vm_exit_during_initialization("Dumping the shared archive is not supported with an exploded module build");
    }
  }

*** 322,14 ***
      } else {
        log_info(cds)("CDS is disabled when the %s option is specified.", option);
      }
      return true;
    }
    return false;
  }
  
! bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
    if (is_dumping_static_archive()) {
      if (!mode_flag_cmd_line) {
        // By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
        //
        // If your classlist is large and you don't care about deterministic dumping, you can use
--- 339,24 ---
      } else {
        log_info(cds)("CDS is disabled when the %s option is specified.", option);
      }
      return true;
    }
+ 
+   if (module_patching_disables_cds()) {
+     if (RequireSharedSpaces) {
+       warning("CDS is disabled when the %s option is specified.", "--patch-module");
+     } else {
+       log_info(cds)("CDS is disabled when the %s option is specified.", "--patch-module");
+     }
+     return true;
+   }
+ 
    return false;
  }
  
! bool CDSConfig::check_vm_args_consistency(bool mode_flag_cmd_line) {
    if (is_dumping_static_archive()) {
      if (!mode_flag_cmd_line) {
        // By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
        //
        // If your classlist is large and you don't care about deterministic dumping, you can use

*** 370,11 ***
        log_warning(cds)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
        return false;
      }
    }
  
!   if (is_using_archive() && patch_mod_javabase) {
      Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
    }
    if (is_using_archive() && has_unsupported_runtime_module_options()) {
      UseSharedSpaces = false;
    }
--- 397,11 ---
        log_warning(cds)("-XX:+AutoCreateSharedArchive does not work with ArchiveClassesAtExit");
        return false;
      }
    }
  
!   if (is_using_archive() && java_base_module_patching_disables_cds() && module_patching_disables_cds()) {
      Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
    }
    if (is_using_archive() && has_unsupported_runtime_module_options()) {
      UseSharedSpaces = false;
    }

*** 404,10 ***
--- 431,14 ---
    _is_using_full_module_graph = false; // This requires is_using_optimized_module_handling()
  }
  
  #if INCLUDE_CDS_JAVA_HEAP
  bool CDSConfig::is_dumping_heap() {
+   if (is_valhalla_preview()) {
+     // Not working yet -- e.g., HeapShared::oop_hash() needs to be implemented for value oops
+     return false;
+   }
    // heap dump is not supported in dynamic dump
    return is_dumping_static_archive() && HeapShared::can_write();
  }
  
  bool CDSConfig::is_using_full_module_graph() {
< prev index next >