src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8043913 Sdiff src/os_cpu/solaris_sparc/vm

src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp

Print this page




  47 
  48   // All SI defines used below must be supported.
  49   guarantee(bufsize != -1, "must be supported");
  50 
  51   char* buf = (char*) malloc(bufsize);
  52 
  53   if (buf == NULL)
  54     return;
  55 
  56   if (sysinfo(si, buf, bufsize) == bufsize) {
  57     // Compare the string.
  58     if (strcmp(buf, string) == 0) {
  59       *features |= mask;
  60     }
  61   }
  62 
  63   free(buf);
  64 }
  65 
  66 int VM_Version::platform_features(int features) {
  67   // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
  68   // supported on Solaris 10 and later.
  69   if (os::Solaris::supports_getisax()) {
  70 
  71     // Check 32-bit architecture.
  72     do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
  73 
  74     // Check 64-bit architecture.
  75     do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
  76 
  77     // Extract valid instruction set extensions.
  78     uint_t avs[2];
  79     uint_t avn = os::Solaris::getisax(avs, 2);
  80     assert(avn <= 2, "should return two or less av's");
  81     uint_t av = avs[0];
  82 
  83 #ifndef PRODUCT
  84     if (PrintMiscellaneous && Verbose) {
  85       tty->print("getisax(2) returned: " PTR32_FORMAT, av);
  86       if (avn > 1) {
  87         tty->print(", " PTR32_FORMAT, avs[1]);
  88       }
  89       tty->cr();
  90     }
  91 #endif
  92 
  93     if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
  94     if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
  95     if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
  96     if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
  97     if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
  98     if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
  99     if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
 100     if (avn > 1) {
 101       uint_t av2 = avs[1];
 102 #ifndef AV2_SPARC_SPARC5
 103 #define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
 104 #endif
 105       if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
 106     }
 107 
 108     // Next values are not defined before Solaris 10
 109     // but Solaris 8 is used for jdk6 update builds.

 110 #ifndef AV_SPARC_ASI_BLK_INIT
 111 #define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
 112 #endif
 113     if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
 114 
 115 #ifndef AV_SPARC_FMAF
 116 #define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
 117 #endif
 118     if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
 119 
 120 #ifndef AV_SPARC_FMAU
 121 #define    AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
 122 #endif
 123     if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
 124 
 125 #ifndef AV_SPARC_VIS3
 126 #define    AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
 127 #endif
 128     if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
 129 


 135 #ifndef AV_SPARC_AES
 136 #define AV_SPARC_AES 0x00020000  /* aes instrs supported */
 137 #endif
 138     if (av & AV_SPARC_AES)       features |= aes_instructions_m;
 139 
 140 #ifndef AV_SPARC_SHA1
 141 #define AV_SPARC_SHA1   0x00400000  /* sha1 instruction supported */
 142 #endif
 143     if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
 144 
 145 #ifndef AV_SPARC_SHA256
 146 #define AV_SPARC_SHA256 0x00800000  /* sha256 instruction supported */
 147 #endif
 148     if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
 149 
 150 #ifndef AV_SPARC_SHA512
 151 #define AV_SPARC_SHA512 0x01000000  /* sha512 instruction supported */
 152 #endif
 153     if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
 154 
 155   } else {
 156     // getisax(2) failed, use the old legacy code.
 157 #ifndef PRODUCT
 158     if (PrintMiscellaneous && Verbose)
 159       tty->print_cr("getisax(2) is not supported.");
 160 #endif
 161 
 162     char   tmp;
 163     size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
 164     char*  buf     = (char*) malloc(bufsize);
 165 
 166     if (buf != NULL) {
 167       if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
 168         // Figure out what kind of sparc we have
 169         char *sparc_string = strstr(buf, "sparc");
 170         if (sparc_string != NULL) {              features |= v8_instructions_m;
 171           if (sparc_string[5] == 'v') {
 172             if (sparc_string[6] == '8') {
 173               if (sparc_string[7] == '-') {      features |= hardware_mul32_m;
 174                                                  features |= hardware_div32_m;
 175               } else if (sparc_string[7] == 'p') features |= generic_v9_m;
 176               else                               features |= generic_v8_m;
 177             } else if (sparc_string[6] == '9')   features |= generic_v9_m;
 178           }
 179         }
 180 
 181         // Check for visualization instructions
 182         char *vis = strstr(buf, "vis");
 183         if (vis != NULL) {                       features |= vis1_instructions_m;
 184           if (vis[3] == '2')                     features |= vis2_instructions_m;
 185         }
 186       }
 187       free(buf);
 188     }
 189   }
 190 
 191   // Determine the machine type.
 192   do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
 193 
 194   {
 195     // Using kstat to determine the machine type.
 196     kstat_ctl_t* kc = kstat_open();
 197     kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
 198     const char* implementation = "UNKNOWN";
 199     if (ksp != NULL) {
 200       if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
 201         kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
 202         for (int i = 0; i < ksp->ks_ndata; i++) {
 203           if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
 204 #ifndef KSTAT_DATA_STRING
 205 #define KSTAT_DATA_STRING   9
 206 #endif
 207             if (knm[i].data_type == KSTAT_DATA_CHAR) {
 208               // VM is running on Solaris 8 which does not have value.str.
 209               implementation = &(knm[i].value.c[0]);
 210             } else if (knm[i].data_type == KSTAT_DATA_STRING) {
 211               // VM is running on Solaris 10.
 212 #ifndef KSTAT_NAMED_STR_PTR
 213               // Solaris 8 was used to build VM, define the structure it misses.
 214               struct str_t {
 215                 union {
 216                   char *ptr;     /* NULL-term string */
 217                   char __pad[8]; /* 64-bit padding */
 218                 } addr;
 219                 uint32_t len;    /* # bytes for strlen + '\0' */
 220               };
 221 #define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
 222 #endif
 223               implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
 224             }
 225 #ifndef PRODUCT
 226             if (PrintMiscellaneous && Verbose) {
 227               tty->print_cr("cpu_info.implementation: %s", implementation);
 228             }
 229 #endif
 230             // Convert to UPPER case before compare.
 231             char* impl = strdup(implementation);
 232 
 233             for (int i = 0; impl[i] != 0; i++)
 234               impl[i] = (char)toupper((uint)impl[i]);

 235             if (strstr(impl, "SPARC64") != NULL) {
 236               features |= sparc64_family_m;
 237             } else if (strstr(impl, "SPARC-M") != NULL) {
 238               // M-series SPARC is based on T-series.
 239               features |= (M_family_m | T_family_m);
 240             } else if (strstr(impl, "SPARC-T") != NULL) {
 241               features |= T_family_m;
 242               if (strstr(impl, "SPARC-T1") != NULL) {
 243                 features |= T1_model_m;
 244               }
 245             } else {
 246               if (strstr(impl, "SPARC") == NULL) {
 247 #ifndef PRODUCT
 248                 // kstat on Solaris 8 virtual machines (branded zones)
 249                 // returns "(unsupported)" implementation.
 250                 warning("kstat cpu_info implementation = '%s', should contain SPARC", impl);


 251 #endif
 252                 implementation = "SPARC";
 253               }
 254             }
 255             free((void*)impl);
 256             break;
 257           }
 258         } // for(
 259       }
 260     }
 261     assert(strcmp(implementation, "UNKNOWN") != 0,
 262            "unknown cpu info (changed kstat interface?)");
 263     kstat_close(kc);
 264   }
 265 
 266   return features;
 267 }


  47 
  48   // All SI defines used below must be supported.
  49   guarantee(bufsize != -1, "must be supported");
  50 
  51   char* buf = (char*) malloc(bufsize);
  52 
  53   if (buf == NULL)
  54     return;
  55 
  56   if (sysinfo(si, buf, bufsize) == bufsize) {
  57     // Compare the string.
  58     if (strcmp(buf, string) == 0) {
  59       *features |= mask;
  60     }
  61   }
  62 
  63   free(buf);
  64 }
  65 
  66 int VM_Version::platform_features(int features) {




  67   // Check 32-bit architecture.
  68   do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
  69 
  70   // Check 64-bit architecture.
  71   do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
  72 
  73   // Extract valid instruction set extensions.
  74   uint_t avs[2];
  75   uint_t avn = os::Solaris::getisax(avs, 2);
  76   assert(avn <= 2, "should return two or less av's");
  77   uint_t av = avs[0];
  78 
  79 #ifndef PRODUCT
  80   if (PrintMiscellaneous && Verbose) {
  81     tty->print("getisax(2) returned: " PTR32_FORMAT, av);
  82     if (avn > 1) {
  83       tty->print(", " PTR32_FORMAT, avs[1]);
  84     }
  85     tty->cr();
  86   }
  87 #endif
  88 
  89   if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
  90   if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
  91   if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
  92   if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
  93   if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
  94   if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
  95   if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
  96   if (avn > 1) {
  97     uint_t av2 = avs[1];
  98 #ifndef AV2_SPARC_SPARC5
  99 #define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
 100 #endif
 101     if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
 102   }
 103 
 104   // We only build on Solaris 10 and up, but some of the values below
 105   // are not defined on all versions of Solaris 10, so we define them,
 106   // if necessary.
 107 #ifndef AV_SPARC_ASI_BLK_INIT
 108 #define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
 109 #endif
 110   if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
 111 
 112 #ifndef AV_SPARC_FMAF
 113 #define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
 114 #endif
 115   if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
 116 
 117 #ifndef AV_SPARC_FMAU
 118 #define AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
 119 #endif
 120   if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
 121 
 122 #ifndef AV_SPARC_VIS3
 123 #define AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
 124 #endif
 125   if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
 126 


 132 #ifndef AV_SPARC_AES
 133 #define AV_SPARC_AES 0x00020000  /* aes instrs supported */
 134 #endif
 135   if (av & AV_SPARC_AES)       features |= aes_instructions_m;
 136 
 137 #ifndef AV_SPARC_SHA1
 138 #define AV_SPARC_SHA1   0x00400000  /* sha1 instruction supported */
 139 #endif
 140   if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
 141 
 142 #ifndef AV_SPARC_SHA256
 143 #define AV_SPARC_SHA256 0x00800000  /* sha256 instruction supported */
 144 #endif
 145   if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
 146 
 147 #ifndef AV_SPARC_SHA512
 148 #define AV_SPARC_SHA512 0x01000000  /* sha512 instruction supported */
 149 #endif
 150   if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
 151 




































 152   // Determine the machine type.
 153   do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
 154 
 155   {
 156     // Using kstat to determine the machine type.
 157     kstat_ctl_t* kc = kstat_open();
 158     kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
 159     const char* implementation = "UNKNOWN";
 160     if (ksp != NULL) {
 161       if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
 162         kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
 163         for (int i = 0; i < ksp->ks_ndata; i++) {
 164           if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {



















 165             implementation = KSTAT_NAMED_STR_PTR(&knm[i]);

 166 #ifndef PRODUCT
 167             if (PrintMiscellaneous && Verbose) {
 168               tty->print_cr("cpu_info.implementation: %s", implementation);
 169             }
 170 #endif
 171             // Convert to UPPER case before compare.
 172             char* impl = strdup(implementation);
 173 
 174             for (int i = 0; impl[i] != 0; i++)
 175               impl[i] = (char)toupper((uint)impl[i]);
 176 
 177             if (strstr(impl, "SPARC64") != NULL) {
 178               features |= sparc64_family_m;
 179             } else if (strstr(impl, "SPARC-M") != NULL) {
 180               // M-series SPARC is based on T-series.
 181               features |= (M_family_m | T_family_m);
 182             } else if (strstr(impl, "SPARC-T") != NULL) {
 183               features |= T_family_m;
 184               if (strstr(impl, "SPARC-T1") != NULL) {
 185                 features |= T1_model_m;
 186               }
 187             } else {
 188               if (strstr(impl, "SPARC") == NULL) {
 189 #ifndef PRODUCT
 190                 // kstat on Solaris 8 virtual machines (branded zones)
 191                 // returns "(unsupported)" implementation. Solaris 8 is not
 192                 // supported anymore, but include this check to be on the
 193                 // safe side.
 194                 warning("kstat cpu_info implementation = '%s', assume generic SPARC", impl);
 195 #endif
 196                 implementation = "SPARC";
 197               }
 198             }
 199             free((void*)impl);
 200             break;
 201           }
 202         } // for(
 203       }
 204     }
 205     assert(strcmp(implementation, "UNKNOWN") != 0,
 206            "unknown cpu info (changed kstat interface?)");
 207     kstat_close(kc);
 208   }
 209 
 210   return features;
 211 }
src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File