8075533: Zero JVM segfaults for -version after JDK-8074552
authorsgehwolf
Mon, 23 Mar 2015 13:53:44 +0100
changeset 30110 20d4dc1409a6
parent 30109 366660027ab5
child 30112 ea1dbf32c865
8075533: Zero JVM segfaults for -version after JDK-8074552 Summary: Remove SafeFetchXX Zero implementations and guard test with CanUseSafeFetchXX Reviewed-by: simonis, coleenp
hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
hotspot/src/share/vm/runtime/stubRoutines.cpp
hotspot/test/compiler/startup/NumCompilerThreadsCheck.java
hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java
hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java
hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
--- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	Mon Mar 23 13:53:44 2015 +0100
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2007, 2008, 2010 Red Hat, Inc.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -176,19 +176,6 @@
       StubRoutines::_oop_arraycopy;
   }
 
-  static int SafeFetch32(int *adr, int errValue) {
-    int value = errValue;
-    value = *adr;
-    return value;
-  }
-
-  static intptr_t SafeFetchN(intptr_t *adr, intptr_t errValue) {
-    intptr_t value = errValue;
-    value = *adr;
-    return value;
-  }
-
-
   void generate_initial() {
     // Generates all stubs and initializes the entry points
 
@@ -241,11 +228,11 @@
     generate_arraycopy_stubs();
 
     // Safefetch stubs.
-    StubRoutines::_safefetch32_entry = CAST_FROM_FN_PTR(address, StubGenerator::SafeFetch32);
+    StubRoutines::_safefetch32_entry = NULL;
     StubRoutines::_safefetch32_fault_pc = NULL;
     StubRoutines::_safefetch32_continuation_pc = NULL;
 
-    StubRoutines::_safefetchN_entry = CAST_FROM_FN_PTR(address, StubGenerator::SafeFetchN);
+    StubRoutines::_safefetchN_entry = NULL;
     StubRoutines::_safefetchN_fault_pc = NULL;
     StubRoutines::_safefetchN_continuation_pc = NULL;
   }
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp	Mon Mar 23 13:53:44 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -213,31 +213,35 @@
 
 // simple test for SafeFetch32
 static void test_safefetch32() {
-  int dummy = 17;
-  int* const p_invalid = (int*) get_segfault_address();
-  int* const p_valid = &dummy;
-  int result_invalid = SafeFetch32(p_invalid, 0xABC);
-  assert(result_invalid == 0xABC, "SafeFetch32 error");
-  int result_valid = SafeFetch32(p_valid, 0xABC);
-  assert(result_valid == 17, "SafeFetch32 error");
+  if (CanUseSafeFetch32()) {
+    int dummy = 17;
+    int* const p_invalid = (int*) get_segfault_address();
+    int* const p_valid = &dummy;
+    int result_invalid = SafeFetch32(p_invalid, 0xABC);
+    assert(result_invalid == 0xABC, "SafeFetch32 error");
+    int result_valid = SafeFetch32(p_valid, 0xABC);
+    assert(result_valid == 17, "SafeFetch32 error");
+  }
 }
 
 // simple test for SafeFetchN
 static void test_safefetchN() {
+  if (CanUseSafeFetchN()) {
 #ifdef _LP64
-  const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
-  const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
+    const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
+    const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
 #else
-  const intptr_t v1 = 0xABCDABCD;
-  const intptr_t v2 = 0xDEFDDEFD;
+    const intptr_t v1 = 0xABCDABCD;
+    const intptr_t v2 = 0xDEFDDEFD;
 #endif
-  intptr_t dummy = v1;
-  intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
-  intptr_t* const p_valid = &dummy;
-  intptr_t result_invalid = SafeFetchN(p_invalid, v2);
-  assert(result_invalid == v2, "SafeFetchN error");
-  intptr_t result_valid = SafeFetchN(p_valid, v2);
-  assert(result_valid == v1, "SafeFetchN error");
+    intptr_t dummy = v1;
+    intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
+    intptr_t* const p_valid = &dummy;
+    intptr_t result_invalid = SafeFetchN(p_invalid, v2);
+    assert(result_invalid == v2, "SafeFetchN error");
+    intptr_t result_valid = SafeFetchN(p_valid, v2);
+    assert(result_valid == v1, "SafeFetchN error");
+  }
 }
 #endif
 
--- a/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java	Mon Mar 23 13:53:44 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -38,20 +38,10 @@
     String expectedOutput = "CICompilerCount of -1 is invalid";
     out.shouldContain(expectedOutput);
 
-    if (isZeroVm()) {
+    if (Platform.isZero()) {
       String expectedLowWaterMarkText = "must be at least 0";
       out.shouldContain(expectedLowWaterMarkText);
     }
   }
 
-  private static boolean isZeroVm() {
-    String vmName = System.getProperty("java.vm.name");
-    if (vmName == null) {
-      throw new RuntimeException("No VM name");
-    }
-    if (vmName.toLowerCase().contains("zero")) {
-      return true;
-    }
-    return false;
-  }
 }
--- a/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java	Mon Mar 23 13:53:44 2015 +0100
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -21,7 +44,7 @@
 
   public static void main(String[] args) throws Exception {
 
-    if (!Platform.isDebugBuild()) {
+    if (!Platform.isDebugBuild() || Platform.isZero()) {
       return;
     }
 
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Mon Mar 23 13:53:44 2015 +0100
@@ -48,6 +48,10 @@
         return vmName.endsWith(" Graal VM");
     }
 
+    public static boolean isZero() {
+        return vmName.endsWith(" Zero VM");
+    }
+
     public static boolean isMinimal() {
         return vmName.endsWith(" Minimal VM");
     }
--- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Fri Mar 20 15:19:30 2015 -0700
+++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Mon Mar 23 13:53:44 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -46,7 +46,7 @@
         ARCH("isARM", "isPPC", "isSparc", "isX86", "isX64"),
         BITNESS("is32bit", "is64bit"),
         OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"),
-        VM_TYPE("isClient", "isServer", "isGraal", "isMinimal"),
+        VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero"),
         IGNORED("isEmbedded", "isDebugBuild", "shouldSAAttach",
                 "canPtraceAttachLinux", "canAttachOSX", "isTieredSupported");