src/cpu/mips/vm/vm_version_mips.cpp

changeset 9644
3089aa0aa0ee
parent 9639
38d2ba487173
child 9808
a9451177555c
     1.1 --- a/src/cpu/mips/vm/vm_version_mips.cpp	Mon Jul 22 18:48:55 2019 +0800
     1.2 +++ b/src/cpu/mips/vm/vm_version_mips.cpp	Thu Sep 05 13:07:31 2019 +0800
     1.3 @@ -33,25 +33,258 @@
     1.4  #ifdef TARGET_OS_FAMILY_linux
     1.5  # include "os_linux.inline.hpp"
     1.6  #endif
     1.7 -#ifdef TARGET_OS_FAMILY_solaris
     1.8 -# include "os_solaris.inline.hpp"
     1.9 -#endif
    1.10 -#ifdef TARGET_OS_FAMILY_windows
    1.11 -# include "os_windows.inline.hpp"
    1.12 -#endif
    1.13 -#ifdef TARGET_OS_FAMILY_bsd
    1.14 -# include "os_bsd.inline.hpp"
    1.15 -#endif
    1.16 -int VM_Version::_features = VM_Version::unknown_m;
    1.17 +
    1.18 +int VM_Version::_cpuFeatures;
    1.19  const char* VM_Version::_features_str = "";
    1.20 -void VM_Version::initialize() {
    1.21 +VM_Version::CpuidInfo VM_Version::_cpuid_info   = { 0, };
    1.22 +volatile bool VM_Version::_is_determine_cpucfg_supported_running = false;
    1.23 +bool VM_Version::_is_cpucfg_instruction_supported = true;
    1.24 +bool VM_Version::_cpu_info_is_initialized = false;
    1.25  
    1.26 -  _features = determine_features();
    1.27 -  //no need, Abstract_VM_Version already define it as false
    1.28 +static BufferBlob* stub_blob;
    1.29 +static const int stub_size = 600;
    1.30 +
    1.31 +extern "C" {
    1.32 +  typedef void (*get_cpu_info_stub_t)(void*);
    1.33 +}
    1.34 +static get_cpu_info_stub_t get_cpu_info_stub = NULL;
    1.35 +
    1.36 +
    1.37 +class VM_Version_StubGenerator: public StubCodeGenerator {
    1.38 + public:
    1.39 +
    1.40 +  VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
    1.41 +
    1.42 +  address generate_get_cpu_info() {
    1.43 +    assert(!VM_Version::cpu_info_is_initialized(), "VM_Version should not be initialized");
    1.44 +    StubCodeMark mark(this, "VM_Version", "get_cpu_info_stub");
    1.45 +#   define __ _masm->
    1.46 +
    1.47 +    address start = __ pc();
    1.48 +
    1.49 +    __ enter();
    1.50 +    __ push(AT);
    1.51 +    __ push(V0);
    1.52 +
    1.53 +    __ li(AT, (long)0);
    1.54 +    __ cpucfg(V0, AT);
    1.55 +    __ lw(AT, A0, in_bytes(VM_Version::Loongson_Cpucfg_id0_offset()));
    1.56 +    __ sw(V0, A0, in_bytes(VM_Version::Loongson_Cpucfg_id0_offset()));
    1.57 +
    1.58 +    __ li(AT, 1);
    1.59 +    __ cpucfg(V0, AT);
    1.60 +    __ lw(AT, A0, in_bytes(VM_Version::Loongson_Cpucfg_id1_offset()));
    1.61 +    __ sw(V0, A0, in_bytes(VM_Version::Loongson_Cpucfg_id1_offset()));
    1.62 +
    1.63 +    __ li(AT, 2);
    1.64 +    __ cpucfg(V0, AT);
    1.65 +    __ lw(AT, A0, in_bytes(VM_Version::Loongson_Cpucfg_id2_offset()));
    1.66 +    __ sw(V0, A0, in_bytes(VM_Version::Loongson_Cpucfg_id2_offset()));
    1.67 +
    1.68 +    __ pop(V0);
    1.69 +    __ pop(AT);
    1.70 +    __ leave();
    1.71 +    __ jr(RA);
    1.72 +    __ delayed()->nop();
    1.73 +#   undef __
    1.74 +
    1.75 +    return start;
    1.76 +  };
    1.77 +};
    1.78 +
    1.79 +uint32_t VM_Version::get_feature_flags_by_cpucfg() {
    1.80 +  uint32_t result = 0;
    1.81 +  if (_cpuid_info.cpucfg_info_id1.bits.MMI != 0)
    1.82 +    result |= CPU_MMI;
    1.83 +  if (_cpuid_info.cpucfg_info_id1.bits.MSA1 != 0)
    1.84 +    result |= CPU_MSA1_0;
    1.85 +  if (_cpuid_info.cpucfg_info_id1.bits.MSA2 != 0)
    1.86 +    result |= CPU_MSA2_0;
    1.87 +  if (_cpuid_info.cpucfg_info_id1.bits.CGP != 0)
    1.88 +    result |= CPU_CGP;
    1.89 +  if (_cpuid_info.cpucfg_info_id1.bits.LSX1 != 0)
    1.90 +    result |= CPU_LSX1;
    1.91 +  if (_cpuid_info.cpucfg_info_id1.bits.LSX2 != 0)
    1.92 +    result |= CPU_LSX2;
    1.93 +  if (_cpuid_info.cpucfg_info_id1.bits.LASX != 0)
    1.94 +    result |= CPU_LASX;
    1.95 +  if (_cpuid_info.cpucfg_info_id1.bits.LLSYNC != 0)
    1.96 +    result |= CPU_LLSYNC;
    1.97 +  if (_cpuid_info.cpucfg_info_id1.bits.TGTSYNC != 0)
    1.98 +    result |= CPU_TGTSYNC;
    1.99 +  if (_cpuid_info.cpucfg_info_id1.bits.MUALP != 0)
   1.100 +    result |= CPU_MUALP;
   1.101 +  if (_cpuid_info.cpucfg_info_id2.bits.LEXT1 != 0)
   1.102 +    result |= CPU_LEXT1;
   1.103 +  if (_cpuid_info.cpucfg_info_id2.bits.LEXT2 != 0)
   1.104 +    result |= CPU_LEXT2;
   1.105 +  if (_cpuid_info.cpucfg_info_id2.bits.LEXT3 != 0)
   1.106 +    result |= CPU_LEXT3;
   1.107 +  if (_cpuid_info.cpucfg_info_id2.bits.LAMO != 0)
   1.108 +    result |= CPU_LAMO;
   1.109 +  if (_cpuid_info.cpucfg_info_id2.bits.LPIXU != 0)
   1.110 +    result |= CPU_LPIXU;
   1.111 +
   1.112 +  result |= CPU_ULSYNC;
   1.113 +
   1.114 +  return result;
   1.115 +}
   1.116 +
   1.117 +void read_cpu_info(const char *path, char *result) {
   1.118 +  FILE *ptr;
   1.119 +  char buf[1024];
   1.120 +  int i = 0;
   1.121 +  if((ptr=fopen(path, "r")) != NULL) {
   1.122 +    while(fgets(buf, 1024, ptr)!=NULL) {
   1.123 +      strcat(result,buf);
   1.124 +      i++;
   1.125 +      if (i == 10) break;
   1.126 +    }
   1.127 +    fclose(ptr);
   1.128 +  } else {
   1.129 +    warning("Can't detect CPU info - cannot open %s", path);
   1.130 +  }
   1.131 +}
   1.132 +
   1.133 +void strlwr(char *str) {
   1.134 +  for (; *str!='\0'; str++)
   1.135 +    *str = tolower(*str);
   1.136 +}
   1.137 +
   1.138 +int VM_Version::get_feature_flags_by_cpuinfo(int features) {
   1.139 +  assert(!cpu_info_is_initialized(), "VM_Version should not be initialized");
   1.140 +
   1.141 +  char res[10240];
   1.142 +  int i;
   1.143 +  memset(res, '\0', 10240 * sizeof(char));
   1.144 +  read_cpu_info("/proc/cpuinfo", res);
   1.145 +  // res is converted to lower case
   1.146 +  strlwr(res);
   1.147 +
   1.148 +  if (strstr(res, "loongson")) {
   1.149 +    // Loongson CPU
   1.150 +    features |= CPU_LOONGSON;
   1.151 +
   1.152 +    const struct Loongson_Cpuinfo loongson_cpuinfo[] = {
   1.153 +      {L_3A1000,  "3a1000"},
   1.154 +      {L_3B1500,  "3b1500"},
   1.155 +      {L_3A2000,  "3a2000"},
   1.156 +      {L_3B2000,  "3b2000"},
   1.157 +      {L_3A3000,  "3a3000"},
   1.158 +      {L_3B3000,  "3b3000"},
   1.159 +      {L_2K1000,  "2k1000"},
   1.160 +      {L_UNKNOWN, "unknown"}
   1.161 +    };
   1.162 +
   1.163 +    // Loongson Family
   1.164 +    int detected = 0;
   1.165 +    for (i = 0; i <= L_UNKNOWN; i++) {
   1.166 +      switch (i) {
   1.167 +        // 3A1000 and 3B1500 may use an old kernel and further comparsion is needed
   1.168 +        // test PRID REV in /proc/cpuinfo
   1.169 +        // 3A1000: V0.5, model name: ICT Loongson-3A V0.5  FPU V0.1
   1.170 +        // 3B1500: V0.7, model name: ICT Loongson-3B V0.7  FPU V0.1
   1.171 +        case L_3A1000:
   1.172 +          if (strstr(res, loongson_cpuinfo[i].match_str) || strstr(res, "loongson-3a v0.5")) {
   1.173 +            features |= CPU_LOONGSON_GS464;
   1.174 +            detected++;
   1.175 +            //tty->print_cr("3A1000 platform");
   1.176 +          }
   1.177 +          break;
   1.178 +        case L_3B1500:
   1.179 +          if (strstr(res, loongson_cpuinfo[i].match_str) || strstr(res, "loongson-3b v0.7")) {
   1.180 +            features |= CPU_LOONGSON_GS464;
   1.181 +            detected++;
   1.182 +            //tty->print_cr("3B1500 platform");
   1.183 +          }
   1.184 +          break;
   1.185 +        case L_3A2000:
   1.186 +        case L_3B2000:
   1.187 +        case L_3A3000:
   1.188 +        case L_3B3000:
   1.189 +          if (strstr(res, loongson_cpuinfo[i].match_str)) {
   1.190 +            features |= CPU_LOONGSON_GS464E;
   1.191 +            detected++;
   1.192 +            //tty->print_cr("3A2000/3A3000/3B2000/3B3000 platform");
   1.193 +          }
   1.194 +          break;
   1.195 +        case L_2K1000:
   1.196 +          if (strstr(res, loongson_cpuinfo[i].match_str)) {
   1.197 +            features |= CPU_LOONGSON_GS264;
   1.198 +            detected++;
   1.199 +            //tty->print_cr("2K1000 platform");
   1.200 +          }
   1.201 +          break;
   1.202 +        case L_UNKNOWN:
   1.203 +          if (detected == 0) {
   1.204 +            detected++;
   1.205 +            //tty->print_cr("unknown Loongson platform");
   1.206 +          }
   1.207 +          break;
   1.208 +        default:
   1.209 +          ShouldNotReachHere();
   1.210 +      }
   1.211 +    }
   1.212 +    assert (detected == 1, "one and only one of LOONGSON_CPU_FAMILY should be detected");
   1.213 +  } else { // not Loongson
   1.214 +    // Not Loongson CPU
   1.215 +    //tty->print_cr("MIPS platform");
   1.216 +  }
   1.217 +
   1.218 +  if (features & CPU_LOONGSON_GS264) {
   1.219 +    features |= CPU_LEXT1;
   1.220 +    features |= CPU_LEXT2;
   1.221 +    features |= CPU_TGTSYNC;
   1.222 +    features |= CPU_ULSYNC;
   1.223 +    features |= CPU_MSA1_0;
   1.224 +    features |= CPU_LSX1;
   1.225 +  } else if (features & CPU_LOONGSON_GS464) {
   1.226 +    features |= CPU_LEXT1;
   1.227 +    features |= CPU_LLSYNC;
   1.228 +    features |= CPU_TGTSYNC;
   1.229 +  } else if (features & CPU_LOONGSON_GS464E) {
   1.230 +    features |= CPU_LEXT1;
   1.231 +    features |= CPU_LEXT2;
   1.232 +    features |= CPU_LEXT3;
   1.233 +    features |= CPU_TGTSYNC;
   1.234 +    features |= CPU_ULSYNC;
   1.235 +  } else if (features & CPU_LOONGSON) {
   1.236 +    // unknow loongson
   1.237 +    features |= CPU_LLSYNC;
   1.238 +    features |= CPU_TGTSYNC;
   1.239 +    features |= CPU_ULSYNC;
   1.240 +  }
   1.241 +  VM_Version::_cpu_info_is_initialized = true;
   1.242 +
   1.243 +  return features;
   1.244 +}
   1.245 +
   1.246 +void VM_Version::get_processor_features() {
   1.247 +
   1.248 +  clean_cpuFeatures();
   1.249 +
   1.250 +  // test if cpucfg instruction is supported
   1.251 +  VM_Version::_is_determine_cpucfg_supported_running = true;
   1.252 +  __asm__ __volatile__(
   1.253 +    ".insn \n\t"
   1.254 +    ".word (0xc8080118)\n\t" // cpucfg zero, zero
   1.255 +    :
   1.256 +    :
   1.257 +    :
   1.258 +    );
   1.259 +  VM_Version::_is_determine_cpucfg_supported_running = false;
   1.260 +
   1.261 +  if (supports_cpucfg()) {
   1.262 +    get_cpu_info_stub(&_cpuid_info);
   1.263 +    _cpuFeatures = get_feature_flags_by_cpucfg();
   1.264 +    // Only Loongson CPUs support cpucfg
   1.265 +    _cpuFeatures |= CPU_LOONGSON;
   1.266 +  } else {
   1.267 +    _cpuFeatures = get_feature_flags_by_cpuinfo(0);
   1.268 +  }
   1.269 +
   1.270    _supports_cx8 = true;
   1.271  
   1.272 -  //////////////////////add some other feature here//////////////////
   1.273 -
   1.274    if (UseG1GC && FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
   1.275      FLAG_SET_CMDLINE(uintx, MaxGCPauseMillis, 650);
   1.276    }
   1.277 @@ -64,6 +297,8 @@
   1.278      }
   1.279      if (MaxVectorSize > 0 && supports_ps()) {
   1.280        MaxVectorSize = 8;
   1.281 +    } else {
   1.282 +      MaxVectorSize = 0;
   1.283      }
   1.284    }
   1.285    //
   1.286 @@ -77,49 +312,64 @@
   1.287      MaxVectorSize = 0;
   1.288    }
   1.289  
   1.290 -  if (is_gs464e()) {
   1.291 +#endif
   1.292 +
   1.293 +  if (needs_llsync() && needs_tgtsync() && !needs_ulsync()) {
   1.294 +    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.295 +      FLAG_SET_DEFAULT(UseSyncLevel, 1000);
   1.296 +    }
   1.297 +  } else if (!needs_llsync() && needs_tgtsync() && needs_ulsync()) {
   1.298 +    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.299 +      FLAG_SET_DEFAULT(UseSyncLevel, 2000);
   1.300 +    }
   1.301 +  } else if (needs_llsync() && needs_llsync() && needs_ulsync()) {
   1.302 +    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.303 +      FLAG_SET_DEFAULT(UseSyncLevel, 3000);
   1.304 +    }
   1.305 +  } else if (!needs_llsync() && !needs_llsync() && !needs_ulsync()) {
   1.306 +    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.307 +      FLAG_SET_DEFAULT(UseSyncLevel, 0);
   1.308 +    }
   1.309 +  } else {
   1.310 +    assert(false, "Should Not Reach Here, what is the cpu type?");
   1.311 +  }
   1.312 +
   1.313 +  if (supports_lext1()) {
   1.314 +    if (FLAG_IS_DEFAULT(UseLEXT1)) {
   1.315 +      FLAG_SET_DEFAULT(UseLEXT1, true);
   1.316 +    }
   1.317 +  } else if (UseLEXT1) {
   1.318 +    warning("LEXT1 instructions are not available on this CPU");
   1.319 +    FLAG_SET_DEFAULT(UseLEXT1, false);
   1.320 +  }
   1.321 +
   1.322 +  if (supports_lext2()) {
   1.323 +    if (FLAG_IS_DEFAULT(UseLEXT2)) {
   1.324 +      FLAG_SET_DEFAULT(UseLEXT2, true);
   1.325 +    }
   1.326 +  } else if (UseLEXT2) {
   1.327 +    warning("LEXT2 instructions are not available on this CPU");
   1.328 +    FLAG_SET_DEFAULT(UseLEXT2, false);
   1.329 +  }
   1.330 +
   1.331 +  if (supports_lext3()) {
   1.332 +    if (FLAG_IS_DEFAULT(UseLEXT3)) {
   1.333 +      FLAG_SET_DEFAULT(UseLEXT3, true);
   1.334 +    }
   1.335 +  } else if (UseLEXT3) {
   1.336 +    warning("LEXT3 instructions are not available on this CPU");
   1.337 +    FLAG_SET_DEFAULT(UseLEXT3, false);
   1.338 +  }
   1.339 +
   1.340 +  if (UseLEXT2) {
   1.341      if (FLAG_IS_DEFAULT(UseCountTrailingZerosInstructionMIPS64)) {
   1.342        FLAG_SET_DEFAULT(UseCountTrailingZerosInstructionMIPS64, 1);
   1.343      }
   1.344    } else if (UseCountTrailingZerosInstructionMIPS64) {
   1.345      if (!FLAG_IS_DEFAULT(UseCountTrailingZerosInstructionMIPS64))
   1.346 -      warning("Only 3A2000/3000 CPUs support UseCountTrailingZerosInstructionMIPS64");
   1.347 +      warning("ctz/dctz instructions are not available on this CPU");
   1.348      FLAG_SET_DEFAULT(UseCountTrailingZerosInstructionMIPS64, 0);
   1.349    }
   1.350 -#endif
   1.351 -  UseSSE = 0; // Only on x86 and x64
   1.352 -
   1.353 -  if (is_loongson()) {
   1.354 -    if (FLAG_IS_DEFAULT(UseLoongsonISA)) {
   1.355 -      FLAG_SET_DEFAULT(UseLoongsonISA, 1);
   1.356 -    }
   1.357 -  } else if (UseLoongsonISA) {
   1.358 -    if (!FLAG_IS_DEFAULT(UseLoongsonISA))
   1.359 -      warning("Only Loongson CPUs support LoongISA");
   1.360 -    FLAG_SET_DEFAULT(UseLoongsonISA, 0);
   1.361 -  }
   1.362 -
   1.363 -  if (is_gs464e()) {
   1.364 -    if (FLAG_IS_DEFAULT(Use3A2000)) {
   1.365 -      FLAG_SET_DEFAULT(Use3A2000, 1);
   1.366 -    }
   1.367 -  } else if (Use3A2000) {
   1.368 -    if (!FLAG_IS_DEFAULT(Use3A2000))
   1.369 -      warning("Only 3A2000/3000 CPUs support this option");
   1.370 -    FLAG_SET_DEFAULT(Use3A2000, 0);
   1.371 -  }
   1.372 -
   1.373 -  if (is_gs464()) {
   1.374 -    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.375 -      FLAG_SET_DEFAULT(UseSyncLevel, 1000);
   1.376 -    }
   1.377 -  }
   1.378 -
   1.379 -  if (is_gs464e() || is_gs464v()) {
   1.380 -    if (FLAG_IS_DEFAULT(UseSyncLevel)) {
   1.381 -      FLAG_SET_DEFAULT(UseSyncLevel, 2000);
   1.382 -    }
   1.383 -  }
   1.384  
   1.385    if (TieredCompilation) {
   1.386      if (!FLAG_IS_DEFAULT(TieredCompilation))
   1.387 @@ -128,23 +378,35 @@
   1.388    }
   1.389  
   1.390    char buf[256];
   1.391 -  bool is_unknown_loongson_cpu = is_loongson() && !is_gs464() && !is_gs464e() && !is_gs464v() && !is_gs264();
   1.392 -  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s, UseSyncLevel:%d",
   1.393 -              (has_l2_cache() ?  ", has_l2_cache" : ""),
   1.394 -              (has_16k_page() ?  ", has_16k_page" : ""),
   1.395 -              (is_loongson()  ?  ", MIPS-compatible Loongson CPU"  : "MIPS"),
   1.396 -              (is_gs464()     ?  ", GS464 (3A1000/3B1500)" : ""),
   1.397 -              (is_gs464e()    ?  ", GS464E (3A2000/3A3000/3B2000/3B3000)" : ""),
   1.398 -              (is_gs464v()    ?  ", GS464V (3A4000/3B4000)" : ""),
   1.399 -              (is_gs264()     ?  ", GS264 (2K1000)" : ""),
   1.400 +  bool is_unknown_loongson_cpu = is_loongson() && !is_gs464() && !is_gs464e() && !is_gs264() && !supports_cpucfg();
   1.401 +
   1.402 +  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s, UseSyncLevel:%d",
   1.403 +              (is_loongson()           ?  "MIPS-compatible Loongson CPU"  : "MIPS CPU"),
   1.404 +              (is_gs464()              ?  ", GS464 (3A1000/3B1500)" : ""),
   1.405 +              (is_gs464e()             ?  ", GS464E (3A2000/3A3000/3B2000/3B3000)" : ""),
   1.406 +              (is_gs264()              ?  ", GS264 (2K1000)" : ""),
   1.407                (is_unknown_loongson_cpu ?  ", Unknown Loongson CPU" : ""),
   1.408 -              (UseLoongsonISA ?  ", UseLoongsonISA" : ""),
   1.409 -              (UseCountTrailingZerosInstructionMIPS64 ? ", UseCountTrailingZerosInstructionMIPS64" : ""),
   1.410 -              (Use3A2000      ?  ", Use3A2000" : ""),
   1.411 +              (supports_dsp()          ?  ", dsp" : ""),
   1.412 +              (supports_ps()           ?  ", ps" : ""),
   1.413 +              (supports_3d()           ?  ", 3d" : ""),
   1.414 +              (supports_mmi()          ?  ", mmi" : ""),
   1.415 +              (supports_msa1_0()       ?  ", msa1_0" : ""),
   1.416 +              (supports_msa2_0()       ?  ", msa2_0" : ""),
   1.417 +              (supports_lsx1()         ?  ", lsx1" : ""),
   1.418 +              (supports_lsx2()         ?  ", lsx2" : ""),
   1.419 +              (supports_lasx()         ?  ", lasx" : ""),
   1.420 +              (supports_lext1()        ?  ", lext1" : ""),
   1.421 +              (supports_lext2()        ?  ", lext2" : ""),
   1.422 +              (supports_lext3()        ?  ", lext3" : ""),
   1.423 +              (supports_cgp()          ?  ", aes, crc, sha1, sha256, sha512" : ""),
   1.424 +              (supports_lamo()         ?  ", lamo" : ""),
   1.425 +              (supports_lpixu()        ?  ", lpixu" : ""),
   1.426 +              (needs_llsync()          ?  ", llsync" : ""),
   1.427 +              (needs_tgtsync()         ?  ", tgtsync": ""),
   1.428 +              (needs_ulsync()          ?  ", ulsync": ""),
   1.429 +              (supports_mualp()        ?  ", mualp" : ""),
   1.430                UseSyncLevel);
   1.431 -
   1.432 -  // buf is started with ", " or is empty
   1.433 -  _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
   1.434 +  _features_str = strdup(buf);
   1.435  
   1.436    if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
   1.437      FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
   1.438 @@ -178,6 +440,27 @@
   1.439      FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
   1.440    }
   1.441  
   1.442 +  if (UseAES) {
   1.443 +    if (!FLAG_IS_DEFAULT(UseAES)) {
   1.444 +      warning("AES instructions are not available on this CPU");
   1.445 +      FLAG_SET_DEFAULT(UseAES, false);
   1.446 +    }
   1.447 +  }
   1.448 +
   1.449 +  if (UseCRC32Intrinsics) {
   1.450 +    if (!FLAG_IS_DEFAULT(UseCRC32Intrinsics)) {
   1.451 +      warning("CRC32Intrinsics instructions are not available on this CPU");
   1.452 +      FLAG_SET_DEFAULT(UseCRC32Intrinsics, false);
   1.453 +    }
   1.454 +  }
   1.455 +
   1.456 +  if (UseAESIntrinsics) {
   1.457 +    if (!FLAG_IS_DEFAULT(UseAESIntrinsics)) {
   1.458 +      warning("AES intrinsics are not available on this CPU");
   1.459 +      FLAG_SET_DEFAULT(UseAESIntrinsics, false);
   1.460 +    }
   1.461 +  }
   1.462 +
   1.463    if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
   1.464      UseMontgomeryMultiplyIntrinsic = true;
   1.465    }
   1.466 @@ -185,27 +468,20 @@
   1.467      UseMontgomerySquareIntrinsic = true;
   1.468    }
   1.469  
   1.470 -  NOT_PRODUCT( if (PrintMiscellaneous && Verbose) print_features(); );
   1.471  }
   1.472  
   1.473 -void VM_Version::print_features() {
   1.474 -  tty->print_cr("Version: %s", cpu_features());
   1.475 +void VM_Version::initialize() {
   1.476 +  ResourceMark rm;
   1.477 +  // Making this stub must be FIRST use of assembler
   1.478 +
   1.479 +  stub_blob = BufferBlob::create("get_cpu_info_stub", stub_size);
   1.480 +  if (stub_blob == NULL) {
   1.481 +    vm_exit_during_initialization("Unable to allocate get_cpu_info_stub");
   1.482 +  }
   1.483 +  CodeBuffer c(stub_blob);
   1.484 +  VM_Version_StubGenerator g(&c);
   1.485 +  get_cpu_info_stub = CAST_TO_FN_PTR(get_cpu_info_stub_t,
   1.486 +                                     g.generate_get_cpu_info());
   1.487 +
   1.488 +  get_processor_features();
   1.489  }
   1.490 -
   1.491 -int VM_Version::determine_features() {
   1.492 -  //////////////////////add some other feature here//////////////////
   1.493 -  int features = platform_features(unknown_m);
   1.494 -  //spt_16k_page_m;
   1.495 -  return features;
   1.496 -}
   1.497 -
   1.498 -static int saved_features = 0;
   1.499 -
   1.500 -void VM_Version::allow_all() {
   1.501 -  saved_features = _features;
   1.502 -  _features      = all_features_m;
   1.503 -}
   1.504 -
   1.505 -void VM_Version::revert() {
   1.506 -  _features = saved_features;
   1.507 -}

mercurial