8184323: compile-time guard some UseSharedSpaces-only coding with the INCLUDE_CDS macro
authormbaesken
Tue, 18 Jul 2017 15:46:04 -0400
changeset 46689 59f0972cf342
parent 46687 9843d494abd5
child 46690 a97413340818
8184323: compile-time guard some UseSharedSpaces-only coding with the INCLUDE_CDS macro Reviewed-by: jiangli, shade, simonis
hotspot/src/os/posix/vm/vmError_posix.cpp
hotspot/src/os/windows/vm/vmError_windows.cpp
hotspot/src/share/vm/classfile/systemDictionary.cpp
hotspot/src/share/vm/memory/universe.cpp
hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
--- a/hotspot/src/os/posix/vm/vmError_posix.cpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/hotspot/src/os/posix/vm/vmError_posix.cpp	Tue Jul 18 15:46:04 2017 -0400
@@ -147,6 +147,7 @@
 // Write a hint to the stream in case siginfo relates to a segv/bus error
 // and the offending address points into CDS archive.
 void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
+#if INCLUDE_CDS
   if (siginfo && UseSharedSpaces) {
     const siginfo_t* const si = (siginfo_t*)siginfo;
     if (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) {
@@ -160,5 +161,6 @@
       }
     }
   }
+#endif
 }
 
--- a/hotspot/src/os/windows/vm/vmError_windows.cpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/hotspot/src/os/windows/vm/vmError_windows.cpp	Tue Jul 18 15:46:04 2017 -0400
@@ -51,6 +51,7 @@
 // Write a hint to the stream in case siginfo relates to a segv/bus error
 // and the offending address points into CDS archive.
 void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
+#if INCLUDE_CDS
   if (siginfo && UseSharedSpaces) {
     const EXCEPTION_RECORD* const er = (const EXCEPTION_RECORD*)siginfo;
     if (er->ExceptionCode == EXCEPTION_IN_PAGE_ERROR &&
@@ -61,10 +62,11 @@
         if (mapinfo->is_in_shared_space(fault_addr)) {
           st->print("Error accessing class data sharing archive. "
             "Mapped file inaccessible during execution, possible disk/network problem.");
+        }
       }
     }
-    }
   }
+#endif
 }
 
 // Error reporting cancellation: there is no easy way to implement this on Windows, because we do
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Tue Jul 18 15:46:04 2017 -0400
@@ -2122,12 +2122,15 @@
   // Preload commonly used klasses
   WKID scan = FIRST_WKID;
   // first do Object, then String, Class
+#if INCLUDE_CDS
   if (UseSharedSpaces) {
     initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
     // Initialize the constant pool for the Object_class
     Object_klass()->constants()->restore_unshareable_info(CHECK);
     initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
-  } else {
+  } else
+#endif
+  {
     initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
   }
 
--- a/hotspot/src/share/vm/memory/universe.cpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/hotspot/src/share/vm/memory/universe.cpp	Tue Jul 18 15:46:04 2017 -0400
@@ -267,11 +267,14 @@
 
 void initialize_basic_type_klass(Klass* k, TRAPS) {
   Klass* ok = SystemDictionary::Object_klass();
+#if INCLUDE_CDS
   if (UseSharedSpaces) {
     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
     assert(k->super() == ok, "u3");
     k->restore_unshareable_info(loader_data, Handle(), CHECK);
-  } else {
+  } else
+#endif
+  {
     k->initialize_supers(ok, CHECK);
   }
   k->append_to_sibling_list();
@@ -325,6 +328,7 @@
     _the_null_string            = StringTable::intern("null", CHECK);
     _the_min_jint_string       = StringTable::intern("-2147483648", CHECK);
 
+#if INCLUDE_CDS
     if (UseSharedSpaces) {
       // Verify shared interfaces array.
       assert(_the_array_interfaces_array->at(0) ==
@@ -332,7 +336,9 @@
       assert(_the_array_interfaces_array->at(1) ==
              SystemDictionary::Serializable_klass(), "u3");
       MetaspaceShared::fixup_shared_string_regions();
-    } else {
+    } else
+#endif
+    {
       // Set up shared interfaces array.  (Do this before supers are set up.)
       _the_array_interfaces_array->at_put(0, SystemDictionary::Cloneable_klass());
       _the_array_interfaces_array->at_put(1, SystemDictionary::Serializable_klass());
@@ -670,6 +676,7 @@
   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
   Universe::_do_stack_walk_cache = new LatestMethodCache();
 
+#if INCLUDE_CDS
   if (UseSharedSpaces) {
     // Read the data structures supporting the shared spaces (shared
     // system dictionary, symbol table, etc.).  After that, access to
@@ -678,13 +685,17 @@
     // currently mapped regions.
     MetaspaceShared::initialize_shared_spaces();
     StringTable::create_table();
-  } else {
+  } else
+#endif
+  {
     SymbolTable::create_table();
     StringTable::create_table();
 
+#if INCLUDE_CDS
     if (DumpSharedSpaces) {
       MetaspaceShared::prepare_for_dumping();
     }
+#endif
   }
   if (strlen(VerifySubSet) > 0) {
     Universe::initialize_verify_flags();
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Tue Jul 18 15:46:04 2017 -0400
@@ -175,6 +175,7 @@
 void VM_RedefineClasses::doit() {
   Thread *thread = Thread::current();
 
+#if INCLUDE_CDS
   if (UseSharedSpaces) {
     // Sharing is enabled so we remap the shared readonly space to
     // shared readwrite, private just in case we need to redefine
@@ -186,6 +187,7 @@
       return;
     }
   }
+#endif
 
   // Mark methods seen on stack and everywhere else so old methods are not
   // cleaned up if they're on the stack.