changeset 5456:cf56d85a1712

8062672: JVM crashes during GC on various asserts which checks that HeapWord ptr is an oop Summary: Crashes were caused by not disabling UseMemSetInBOT as should be done on sparc. Added support for picking up blkinit as a platform feature if available on Linux sparc. This is needed to avoid enabling UseMemSetInBOT when running on this platform. Reviewed-by: jmasa, brutisso
author sjohanss
date Thu, 11 Dec 2014 09:56:57 +0100
parents 5fe5dd92998b
children 318d0a0b46da
files src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp	Fri Dec 05 16:22:36 2014 -0800
+++ b/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp	Thu Dec 11 09:56:57 2014 +0100
@@ -26,8 +26,8 @@
 #include "runtime/os.hpp"
 #include "vm_version_sparc.hpp"
 
-static bool detect_niagara() {
-  char cpu[128];
+static bool cpuinfo_field_contains(const char* field, const char* value) {
+  char line[1024];
   bool rv = false;
 
   FILE* fp = fopen("/proc/cpuinfo", "r");
@@ -35,9 +35,10 @@
     return rv;
   }
 
-  while (!feof(fp)) {
-    if (fscanf(fp, "cpu\t\t: %100[^\n]", &cpu) == 1) {
-      if (strstr(cpu, "Niagara") != NULL) {
+  while (fgets(line, sizeof(line), fp) != NULL) {
+    assert(strlen(line) < sizeof(line) - 1, "buffer line[1024] is too small.");
+    if (strncmp(line, field, strlen(field)) == 0) {
+      if (strstr(line, value) != NULL) {
         rv = true;
       }
       break;
@@ -45,8 +46,15 @@
   }
 
   fclose(fp);
+  return rv;
+}
 
-  return rv;
+static bool detect_niagara() {
+  return cpuinfo_field_contains("cpu", "Niagara");
+}
+
+static bool detect_blkinit() {
+  return cpuinfo_field_contains("cpucaps", "blkinit");
 }
 
 int VM_Version::platform_features(int features) {
@@ -58,5 +66,9 @@
     features = niagara1_m | T_family_m;
   }
 
+  if (detect_blkinit()) {
+    features |= blk_init_instructions_m;
+  }
+
   return features;
 }