Wed, 13 Aug 2014 10:44:50 +0200
8043913: remove legacy code in SPARC's VM_Version::platform_features
Summary: Kept only getisax(2) to determine platform features
Reviewed-by: kvn, roland
Contributed-by: Zoltan Majo <zoltan.majo@oracle.com>
src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Mar 29 09:20:08 2017 +0200 1.2 +++ b/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Aug 13 10:44:50 2014 +0200 1.3 @@ -293,129 +293,92 @@ 1.4 } 1.5 1.6 int VM_Version::platform_features(int features) { 1.7 - // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are 1.8 - // supported on Solaris 10 and later. 1.9 - if (os::Solaris::supports_getisax()) { 1.10 + assert(os::Solaris::supports_getisax(), "getisax() must be available"); 1.11 1.12 - // Check 32-bit architecture. 1.13 - do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m); 1.14 + // Check 32-bit architecture. 1.15 + do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m); 1.16 1.17 - // Check 64-bit architecture. 1.18 - do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m); 1.19 + // Check 64-bit architecture. 1.20 + do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m); 1.21 1.22 - // Extract valid instruction set extensions. 1.23 - uint_t avs[2]; 1.24 - uint_t avn = os::Solaris::getisax(avs, 2); 1.25 - assert(avn <= 2, "should return two or less av's"); 1.26 - uint_t av = avs[0]; 1.27 + // Extract valid instruction set extensions. 1.28 + uint_t avs[2]; 1.29 + uint_t avn = os::Solaris::getisax(avs, 2); 1.30 + assert(avn <= 2, "should return two or less av's"); 1.31 + uint_t av = avs[0]; 1.32 1.33 #ifndef PRODUCT 1.34 - if (PrintMiscellaneous && Verbose) { 1.35 - tty->print("getisax(2) returned: " PTR32_FORMAT, av); 1.36 - if (avn > 1) { 1.37 - tty->print(", " PTR32_FORMAT, avs[1]); 1.38 - } 1.39 - tty->cr(); 1.40 + if (PrintMiscellaneous && Verbose) { 1.41 + tty->print("getisax(2) returned: " PTR32_FORMAT, av); 1.42 + if (avn > 1) { 1.43 + tty->print(", " PTR32_FORMAT, avs[1]); 1.44 } 1.45 + tty->cr(); 1.46 + } 1.47 #endif 1.48 1.49 - if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; 1.50 - if (av & AV_SPARC_DIV32) features |= hardware_div32_m; 1.51 - if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; 1.52 - if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m; 1.53 - if (av & AV_SPARC_POPC) features |= hardware_popc_m; 1.54 - if (av & AV_SPARC_VIS) features |= vis1_instructions_m; 1.55 - if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; 1.56 - if (avn > 1) { 1.57 - uint_t av2 = avs[1]; 1.58 + if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; 1.59 + if (av & AV_SPARC_DIV32) features |= hardware_div32_m; 1.60 + if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; 1.61 + if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m; 1.62 + if (av & AV_SPARC_POPC) features |= hardware_popc_m; 1.63 + if (av & AV_SPARC_VIS) features |= vis1_instructions_m; 1.64 + if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; 1.65 + if (avn > 1) { 1.66 + uint_t av2 = avs[1]; 1.67 #ifndef AV2_SPARC_SPARC5 1.68 #define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ 1.69 #endif 1.70 - if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; 1.71 - } 1.72 + if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; 1.73 + } 1.74 1.75 - // Next values are not defined before Solaris 10 1.76 - // but Solaris 8 is used for jdk6 update builds. 1.77 + // We only build on Solaris 10 and up, but some of the values below 1.78 + // are not defined on all versions of Solaris 10, so we define them, 1.79 + // if necessary. 1.80 #ifndef AV_SPARC_ASI_BLK_INIT 1.81 #define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */ 1.82 #endif 1.83 - if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; 1.84 + if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; 1.85 1.86 #ifndef AV_SPARC_FMAF 1.87 #define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */ 1.88 #endif 1.89 - if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m; 1.90 + if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m; 1.91 1.92 #ifndef AV_SPARC_FMAU 1.93 -#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */ 1.94 +#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */ 1.95 #endif 1.96 - if (av & AV_SPARC_FMAU) features |= fmau_instructions_m; 1.97 + if (av & AV_SPARC_FMAU) features |= fmau_instructions_m; 1.98 1.99 #ifndef AV_SPARC_VIS3 1.100 -#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */ 1.101 +#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */ 1.102 #endif 1.103 - if (av & AV_SPARC_VIS3) features |= vis3_instructions_m; 1.104 + if (av & AV_SPARC_VIS3) features |= vis3_instructions_m; 1.105 1.106 #ifndef AV_SPARC_CBCOND 1.107 #define AV_SPARC_CBCOND 0x10000000 /* compare and branch instrs supported */ 1.108 #endif 1.109 - if (av & AV_SPARC_CBCOND) features |= cbcond_instructions_m; 1.110 + if (av & AV_SPARC_CBCOND) features |= cbcond_instructions_m; 1.111 1.112 #ifndef AV_SPARC_AES 1.113 #define AV_SPARC_AES 0x00020000 /* aes instrs supported */ 1.114 #endif 1.115 - if (av & AV_SPARC_AES) features |= aes_instructions_m; 1.116 + if (av & AV_SPARC_AES) features |= aes_instructions_m; 1.117 1.118 #ifndef AV_SPARC_SHA1 1.119 #define AV_SPARC_SHA1 0x00400000 /* sha1 instruction supported */ 1.120 #endif 1.121 - if (av & AV_SPARC_SHA1) features |= sha1_instruction_m; 1.122 + if (av & AV_SPARC_SHA1) features |= sha1_instruction_m; 1.123 1.124 #ifndef AV_SPARC_SHA256 1.125 #define AV_SPARC_SHA256 0x00800000 /* sha256 instruction supported */ 1.126 #endif 1.127 - if (av & AV_SPARC_SHA256) features |= sha256_instruction_m; 1.128 + if (av & AV_SPARC_SHA256) features |= sha256_instruction_m; 1.129 1.130 #ifndef AV_SPARC_SHA512 1.131 #define AV_SPARC_SHA512 0x01000000 /* sha512 instruction supported */ 1.132 #endif 1.133 - if (av & AV_SPARC_SHA512) features |= sha512_instruction_m; 1.134 - 1.135 - } else { 1.136 - // getisax(2) failed, use the old legacy code. 1.137 -#ifndef PRODUCT 1.138 - if (PrintMiscellaneous && Verbose) 1.139 - tty->print_cr("getisax(2) is not supported."); 1.140 -#endif 1.141 - 1.142 - char tmp; 1.143 - size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1); 1.144 - char* buf = (char*) malloc(bufsize); 1.145 - 1.146 - if (buf != NULL) { 1.147 - if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) { 1.148 - // Figure out what kind of sparc we have 1.149 - char *sparc_string = strstr(buf, "sparc"); 1.150 - if (sparc_string != NULL) { features |= v8_instructions_m; 1.151 - if (sparc_string[5] == 'v') { 1.152 - if (sparc_string[6] == '8') { 1.153 - if (sparc_string[7] == '-') { features |= hardware_mul32_m; 1.154 - features |= hardware_div32_m; 1.155 - } else if (sparc_string[7] == 'p') features |= generic_v9_m; 1.156 - else features |= generic_v8_m; 1.157 - } else if (sparc_string[6] == '9') features |= generic_v9_m; 1.158 - } 1.159 - } 1.160 - 1.161 - // Check for visualization instructions 1.162 - char *vis = strstr(buf, "vis"); 1.163 - if (vis != NULL) { features |= vis1_instructions_m; 1.164 - if (vis[3] == '2') features |= vis2_instructions_m; 1.165 - } 1.166 - } 1.167 - free(buf); 1.168 - } 1.169 - } 1.170 + if (av & AV_SPARC_SHA512) features |= sha512_instruction_m; 1.171 1.172 // Determine the machine type. 1.173 do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m); 1.174 @@ -430,27 +393,7 @@ 1.175 kstat_named_t* knm = (kstat_named_t *)ksp->ks_data; 1.176 for (int i = 0; i < ksp->ks_ndata; i++) { 1.177 if (strcmp((const char*)&(knm[i].name),"implementation") == 0) { 1.178 -#ifndef KSTAT_DATA_STRING 1.179 -#define KSTAT_DATA_STRING 9 1.180 -#endif 1.181 - if (knm[i].data_type == KSTAT_DATA_CHAR) { 1.182 - // VM is running on Solaris 8 which does not have value.str. 1.183 - implementation = &(knm[i].value.c[0]); 1.184 - } else if (knm[i].data_type == KSTAT_DATA_STRING) { 1.185 - // VM is running on Solaris 10. 1.186 -#ifndef KSTAT_NAMED_STR_PTR 1.187 - // Solaris 8 was used to build VM, define the structure it misses. 1.188 - struct str_t { 1.189 - union { 1.190 - char *ptr; /* NULL-term string */ 1.191 - char __pad[8]; /* 64-bit padding */ 1.192 - } addr; 1.193 - uint32_t len; /* # bytes for strlen + '\0' */ 1.194 - }; 1.195 -#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr) 1.196 -#endif 1.197 - implementation = KSTAT_NAMED_STR_PTR(&knm[i]); 1.198 - } 1.199 + implementation = KSTAT_NAMED_STR_PTR(&knm[i]); 1.200 #ifndef PRODUCT 1.201 if (PrintMiscellaneous && Verbose) { 1.202 tty->print_cr("cpu_info.implementation: %s", implementation); 1.203 @@ -461,6 +404,7 @@ 1.204 1.205 for (int i = 0; impl[i] != 0; i++) 1.206 impl[i] = (char)toupper((uint)impl[i]); 1.207 + 1.208 if (strstr(impl, "SPARC64") != NULL) { 1.209 features |= sparc64_family_m; 1.210 } else if (strstr(impl, "SPARC-M") != NULL) { 1.211 @@ -475,8 +419,10 @@ 1.212 if (strstr(impl, "SPARC") == NULL) { 1.213 #ifndef PRODUCT 1.214 // kstat on Solaris 8 virtual machines (branded zones) 1.215 - // returns "(unsupported)" implementation. 1.216 - warning("kstat cpu_info implementation = '%s', should contain SPARC", impl); 1.217 + // returns "(unsupported)" implementation. Solaris 8 is not 1.218 + // supported anymore, but include this check to be on the 1.219 + // safe side. 1.220 + warning("kstat cpu_info implementation = '%s', assume generic SPARC", impl); 1.221 #endif 1.222 implementation = "SPARC"; 1.223 }