comparison src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp @ 22840:ec3982ff3fed

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 a0ea36509b7b
children 7985a33bac9c
comparison
equal deleted inserted replaced
22839:490b4cb2c0b5 22840:ec3982ff3fed
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "runtime/os.hpp" 26 #include "runtime/os.hpp"
27 #include "vm_version_sparc.hpp" 27 #include "vm_version_sparc.hpp"
28 28
29 static bool detect_niagara() { 29 static bool cpuinfo_field_contains(const char* field, const char* value) {
30 char cpu[128]; 30 char line[1024];
31 bool rv = false; 31 bool rv = false;
32 32
33 FILE* fp = fopen("/proc/cpuinfo", "r"); 33 FILE* fp = fopen("/proc/cpuinfo", "r");
34 if (fp == NULL) { 34 if (fp == NULL) {
35 return rv; 35 return rv;
36 } 36 }
37 37
38 while (!feof(fp)) { 38 while (fgets(line, sizeof(line), fp) != NULL) {
39 if (fscanf(fp, "cpu\t\t: %100[^\n]", &cpu) == 1) { 39 assert(strlen(line) < sizeof(line) - 1, "buffer line[1024] is too small.");
40 if (strstr(cpu, "Niagara") != NULL) { 40 if (strncmp(line, field, strlen(field)) == 0) {
41 if (strstr(line, value) != NULL) {
41 rv = true; 42 rv = true;
42 } 43 }
43 break; 44 break;
44 } 45 }
45 } 46 }
46 47
47 fclose(fp); 48 fclose(fp);
49 return rv;
50 }
48 51
49 return rv; 52 static bool detect_niagara() {
53 return cpuinfo_field_contains("cpu", "Niagara");
54 }
55
56 static bool detect_blkinit() {
57 return cpuinfo_field_contains("cpucaps", "blkinit");
50 } 58 }
51 59
52 int VM_Version::platform_features(int features) { 60 int VM_Version::platform_features(int features) {
53 // Default to generic v9 61 // Default to generic v9
54 features = generic_v9_m; 62 features = generic_v9_m;
56 if (detect_niagara()) { 64 if (detect_niagara()) {
57 NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Linux on Niagara");) 65 NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Linux on Niagara");)
58 features = niagara1_m | T_family_m; 66 features = niagara1_m | T_family_m;
59 } 67 }
60 68
69 if (detect_blkinit()) {
70 features |= blk_init_instructions_m;
71 }
72
61 return features; 73 return features;
62 } 74 }