changeset 7533:4b1d7d4be6dc

Merge
author jwilhelm
date Thu, 11 Dec 2014 20:39:25 +0100
parents d66b82f39c6e 35e222a277ba
children a80fbdc110cb
files
diffstat 10 files changed, 229 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.cpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/os/windows/vm/os_windows.cpp	Thu Dec 11 20:39:25 2014 +0100
@@ -3074,7 +3074,7 @@
 char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
   assert((size_t)addr % os::vm_allocation_granularity() == 0,
          "reserve alignment");
-  assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
+  assert(bytes % os::vm_page_size() == 0, "reserve page size");
   char* res;
   // note that if UseLargePages is on, all the areas that require interleaving
   // will go thru reserve_memory_special rather than thru here.
--- a/src/share/vm/memory/filemap.cpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/share/vm/memory/filemap.cpp	Thu Dec 11 20:39:25 2014 +0100
@@ -98,11 +98,11 @@
         tty->print_cr("UseSharedSpaces: %s", msg);
       }
     }
+    UseSharedSpaces = false;
+    assert(current_info() != NULL, "singleton must be registered");
+    current_info()->close();
   }
   va_end(ap);
-  UseSharedSpaces = false;
-  assert(current_info() != NULL, "singleton must be registered");
-  current_info()->close();
 }
 
 // Fill in the fileMapInfo structure with data about this VM instance.
--- a/src/share/vm/memory/metaspace.cpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/share/vm/memory/metaspace.cpp	Thu Dec 11 20:39:25 2014 +0100
@@ -3158,7 +3158,25 @@
     SharedMiscDataSize  = align_size_up(SharedMiscDataSize,  max_alignment);
     SharedMiscCodeSize  = align_size_up(SharedMiscCodeSize,  max_alignment);
 
-    // the min_misc_code_size estimate is based on MetaspaceShared::generate_vtable_methods()
+    // make sure SharedReadOnlySize and SharedReadWriteSize are not less than
+    // the minimum values.
+    if (SharedReadOnlySize < MetaspaceShared::min_ro_size){
+      report_out_of_shared_space(SharedReadOnly);
+    }
+
+    if (SharedReadWriteSize < MetaspaceShared::min_rw_size){
+      report_out_of_shared_space(SharedReadWrite);
+    }
+
+    // the min_misc_data_size and min_misc_code_size estimates are based on
+    // MetaspaceShared::generate_vtable_methods()
+    uint min_misc_data_size = align_size_up(
+      MetaspaceShared::num_virtuals * MetaspaceShared::vtbl_list_size * sizeof(void*), max_alignment);
+
+    if (SharedMiscDataSize < min_misc_data_size) {
+      report_out_of_shared_space(SharedMiscData);
+    }
+
     uintx min_misc_code_size = align_size_up(
       (MetaspaceShared::num_virtuals * MetaspaceShared::vtbl_list_size) *
         (sizeof(void*) + MetaspaceShared::vtbl_method_size) + MetaspaceShared::vtbl_common_code_size,
--- a/src/share/vm/memory/metaspaceShared.cpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/share/vm/memory/metaspaceShared.cpp	Thu Dec 11 20:39:25 2014 +0100
@@ -969,7 +969,7 @@
 #endif
     // If -Xshare:on is specified, print out the error message and exit VM,
     // otherwise, set UseSharedSpaces to false and continue.
-    if (RequireSharedSpaces) {
+    if (RequireSharedSpaces || PrintSharedArchiveAndExit) {
       vm_exit_during_initialization("Unable to use shared archive.", "Failed map_region for using -Xshare:on.");
     } else {
       FLAG_SET_DEFAULT(UseSharedSpaces, false);
--- a/src/share/vm/memory/metaspaceShared.hpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/share/vm/memory/metaspaceShared.hpp	Thu Dec 11 20:39:25 2014 +0100
@@ -70,6 +70,11 @@
   };
 
   enum {
+    min_ro_size = NOT_LP64(8*M) LP64_ONLY(9*M), // minimum ro and rw regions sizes based on dumping
+    min_rw_size = NOT_LP64(7*M) LP64_ONLY(12*M) // of a shared archive using the default classlist
+  };
+
+  enum {
     ro = 0,  // read-only shared space in the heap
     rw = 1,  // read-write shared space in the heap
     md = 2,  // miscellaneous data for initializing tables, etc.
--- a/src/share/vm/oops/cpCache.cpp	Thu Dec 11 02:43:50 2014 +0100
+++ b/src/share/vm/oops/cpCache.cpp	Thu Dec 11 20:39:25 2014 +0100
@@ -287,9 +287,13 @@
   // the lock, so that when the losing writer returns, he can use the linked
   // cache entry.
 
-  // Use the lock from the metaspace for this, which cannot stop for safepoint.
-  Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
-  MutexLockerEx ml(metaspace_lock,  Mutex::_no_safepoint_check_flag);
+  objArrayHandle resolved_references = cpool->resolved_references();
+  // Use the resolved_references() lock for this cpCache entry.
+  // resolved_references are created for all classes with Invokedynamic, MethodHandle
+  // or MethodType constant pool cache entries.
+  assert(resolved_references() != NULL,
+         "a resolved_references array should have been created for this class");
+  ObjectLocker ol(resolved_references, Thread::current());
   if (!is_f1_null()) {
     return;
   }
@@ -336,7 +340,6 @@
   // This allows us to create fewer Methods, while keeping type safety.
   //
 
-  objArrayHandle resolved_references = cpool->resolved_references();
   // Store appendix, if any.
   if (has_appendix) {
     const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset;
--- a/test/Makefile	Thu Dec 11 02:43:50 2014 +0100
+++ b/test/Makefile	Thu Dec 11 20:39:25 2014 +0100
@@ -275,6 +275,9 @@
 # Ignore tests are not run and completely silent about it
 JTREG_IGNORE_OPTION = -ignore:quiet
 JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
+# Multiply by 4 the timeout factor
+JTREG_TIMEOUT_OPTION =  -timeoutFactor:4
+JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
 # Add any extra options
 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Set other vm and test options
--- a/test/runtime/SharedArchiveFile/LimitSharedSizes.java	Thu Dec 11 02:43:50 2014 +0100
+++ b/test/runtime/SharedArchiveFile/LimitSharedSizes.java	Thu Dec 11 20:39:25 2014 +0100
@@ -30,40 +30,96 @@
 import com.oracle.java.testlibrary.*;
 
 public class LimitSharedSizes {
+    static enum Region {
+        RO, RW, MD, MC
+    }
+
     private static class SharedSizeTestData {
         public String optionName;
         public String optionValue;
         public String expectedErrorMsg;
 
-        public SharedSizeTestData(String name, String value, String msg) {
-            optionName = name;
+        public SharedSizeTestData(Region region, String value, String msg) {
+            optionName = getName(region);
             optionValue = value;
             expectedErrorMsg = msg;
         }
+
+        public SharedSizeTestData(Region region, String msg) {
+            optionName = getName(region);
+            optionValue = getValue(region);
+            expectedErrorMsg = msg;
+        }
+
+        private String getName(Region region) {
+            String name;
+            switch (region) {
+                case RO:
+                    name = "-XX:SharedReadOnlySize";
+                    break;
+                case RW:
+                    name = "-XX:SharedReadWriteSize";
+                    break;
+                case MD:
+                    name = "-XX:SharedMiscDataSize";
+                    break;
+                case MC:
+                    name = "-XX:SharedMiscCodeSize";
+                    break;
+                default:
+                    name = "Unknown";
+                    break;
+            }
+            return name;
+        }
+
+        private String getValue(Region region) {
+            String value;
+            switch (region) {
+                case RO:
+                    value = Platform.is64bit() ? "9M" : "8M";
+                    break;
+                case RW:
+                    value = Platform.is64bit() ? "12M" : "7M";
+                    break;
+                case MD:
+                    value = Platform.is64bit() ? "4M" : "2M";
+                    break;
+                case MC:
+                    value = "120k";
+                    break;
+                default:
+                    value = "0M";
+                    break;
+            }
+            return value;
+        }
     }
 
     private static final SharedSizeTestData[] testTable = {
-        // values in this part of the test table should cause failure
-        // (shared space sizes are deliberately too small)
-        new SharedSizeTestData("-XX:SharedReadOnlySize", "4M",      "read only"),
-        new SharedSizeTestData("-XX:SharedReadWriteSize","4M",      "read write"),
-
-        // Known issue, JDK-8038422 (assert() on Windows)
-        // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k",    "miscellaneous data"),
-
-        // Too small of a misc code size should not cause a vm crash.
-        // It should result in the following error message:
+        // Too small of a region size should not cause a vm crash.
+        // It should result in an error message like the following:
         // The shared miscellaneous code space is not large enough
         // to preload requested classes. Use -XX:SharedMiscCodeSize=
         // to increase the initial size of shared miscellaneous code space.
-        new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k",     "miscellaneous code"),
+        new SharedSizeTestData(Region.RO, "4M",   "read only"),
+        new SharedSizeTestData(Region.RW, "4M",   "read write"),
+        new SharedSizeTestData(Region.MD, "50k",  "miscellaneous data"),
+        new SharedSizeTestData(Region.MC, "20k",  "miscellaneous code"),
 
         // these values are larger than default ones, but should
         // be acceptable and not cause failure
-        new SharedSizeTestData("-XX:SharedReadOnlySize",    "20M", null),
-        new SharedSizeTestData("-XX:SharedReadWriteSize",   "20M", null),
-        new SharedSizeTestData("-XX:SharedMiscDataSize",    "20M", null),
-        new SharedSizeTestData("-XX:SharedMiscCodeSize",    "20M", null)
+        new SharedSizeTestData(Region.RO, "20M", null),
+        new SharedSizeTestData(Region.RW, "20M", null),
+        new SharedSizeTestData(Region.MD, "20M", null),
+        new SharedSizeTestData(Region.MC, "20M", null),
+
+        // test with sizes which just meet the minimum required sizes
+        // the following tests also attempt to use the shared archive
+        new SharedSizeTestData(Region.RO, "UseArchive"),
+        new SharedSizeTestData(Region.RW, "UseArchive"),
+        new SharedSizeTestData(Region.MD, "UseArchive"),
+        new SharedSizeTestData(Region.MC, "UseArchive")
     };
 
     public static void main(String[] args) throws Exception {
@@ -82,10 +138,39 @@
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 
             if (td.expectedErrorMsg != null) {
-                output.shouldContain("The shared " + td.expectedErrorMsg
-                    + " space is not large enough");
+                if (!td.expectedErrorMsg.equals("UseArchive")) {
+                    output.shouldContain("The shared " + td.expectedErrorMsg
+                        + " space is not large enough");
 
-                output.shouldHaveExitValue(2);
+                    output.shouldHaveExitValue(2);
+                } else {
+                    output.shouldNotContain("space is not large enough");
+                    output.shouldHaveExitValue(0);
+
+                    // try to use the archive
+                    pb = ProcessTools.createJavaProcessBuilder(
+                       "-XX:+UnlockDiagnosticVMOptions",
+                       "-XX:SharedArchiveFile=./" + fileName,
+                       "-XX:+PrintSharedArchiveAndExit",
+                       "-version");
+
+                    try {
+                        output = new OutputAnalyzer(pb.start());
+                        output.shouldContain("archive is valid");
+                    } catch (RuntimeException e) {
+                        // if sharing failed due to ASLR or similar reasons,
+                        // check whether sharing was attempted at all (UseSharedSpaces)
+                        if ((output.getOutput().contains("Unable to use shared archive") ||
+                             output.getOutput().contains("Unable to map ReadOnly shared space at required address.") ||
+                             output.getOutput().contains("Unable to map ReadWrite shared space at required address.") ||
+                             output.getOutput().contains("Unable to reserve shared space at required address")) &&
+                             output.getExitValue() == 1) {
+                             System.out.println("Unable to use shared archive: test not executed; assumed passed");
+                             return;
+                        }
+                    }
+                    output.shouldHaveExitValue(0);
+                }
             } else {
                 output.shouldNotContain("space is not large enough");
                 output.shouldHaveExitValue(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Thu Dec 11 20:39:25 2014 +0100
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8066670
+ * @summary Testing -XX:+PrintSharedArchiveAndExit option
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class PrintSharedArchiveAndExit {
+  public static void main(String[] args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    try {
+      output.shouldContain("Loading classes to share");
+      output.shouldHaveExitValue(0);
+
+      // (1) With a valid archive
+      pb = ProcessTools.createJavaProcessBuilder(
+          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+          "-XX:+PrintSharedArchiveAndExit", "-version");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldContain("archive is valid");
+      output.shouldNotContain("java version");     // Should not print JVM version
+      output.shouldHaveExitValue(0);               // Should report success in error code.
+
+      pb = ProcessTools.createJavaProcessBuilder(
+          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+          "-XX:+PrintSharedArchiveAndExit");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldContain("archive is valid");
+      output.shouldNotContain("Usage:");           // Should not print JVM help message
+      output.shouldHaveExitValue(0);               // Should report success in error code.
+
+      // (2) With an invalid archive (boot class path has been prepended)
+      pb = ProcessTools.createJavaProcessBuilder(
+          "-Xbootclasspath/p:foo.jar",
+          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+          "-XX:+PrintSharedArchiveAndExit", "-version");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldContain("archive is invalid");
+      output.shouldNotContain("java version");     // Should not print JVM version
+      output.shouldHaveExitValue(1);               // Should report failure in error code.
+
+      pb = ProcessTools.createJavaProcessBuilder(
+          "-Xbootclasspath/p:foo.jar",
+          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+          "-XX:+PrintSharedArchiveAndExit");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldContain("archive is invalid");
+      output.shouldNotContain("Usage:");           // Should not print JVM help message
+      output.shouldHaveExitValue(1);               // Should report failure in error code.
+    } catch (RuntimeException e) {
+      e.printStackTrace();
+      output.shouldContain("Unable to use shared archive");
+      output.shouldHaveExitValue(1);
+    }
+  }
+}
--- a/test/serviceability/sa/jmap-hashcode/Test8028623.java	Thu Dec 11 02:43:50 2014 +0100
+++ b/test/serviceability/sa/jmap-hashcode/Test8028623.java	Thu Dec 11 20:39:25 2014 +0100
@@ -41,12 +41,12 @@
 
 public class Test8028623 {
 
-  public static int à = 1;
+  public static int \u00CB = 1;
   public static String dumpFile = "heap.out";
 
   public static void main (String[] args) {
 
-    System.out.println(Ã);
+    System.out.println(\u00CB);
 
     try {
         if (!Platform.shouldSAAttach()) {