hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
changeset 30429 c980154ed1a3
parent 30225 e9722ea461d4
child 31230 413576d00672
equal deleted inserted replaced
30412:8ffdeabc7c2b 30429:c980154ed1a3
    57 #define HWCAP_CRC32 (1<<7)
    57 #define HWCAP_CRC32 (1<<7)
    58 #endif
    58 #endif
    59 
    59 
    60 int VM_Version::_cpu;
    60 int VM_Version::_cpu;
    61 int VM_Version::_model;
    61 int VM_Version::_model;
       
    62 int VM_Version::_model2;
       
    63 int VM_Version::_variant;
       
    64 int VM_Version::_revision;
    62 int VM_Version::_stepping;
    65 int VM_Version::_stepping;
    63 int VM_Version::_cpuFeatures;
    66 int VM_Version::_cpuFeatures;
    64 const char*           VM_Version::_features_str = "";
    67 const char*           VM_Version::_features_str = "";
    65 
    68 
    66 static BufferBlob* stub_blob;
    69 static BufferBlob* stub_blob;
   120 
   123 
   121   unsigned long auxv = getauxval(AT_HWCAP);
   124   unsigned long auxv = getauxval(AT_HWCAP);
   122 
   125 
   123   char buf[512];
   126   char buf[512];
   124 
   127 
   125   strcpy(buf, "simd");
   128   _cpuFeatures = auxv;
       
   129 
       
   130   int cpu_lines = 0;
       
   131   if (FILE *f = fopen("/proc/cpuinfo", "r")) {
       
   132     char buf[128], *p;
       
   133     while (fgets(buf, sizeof (buf), f) != NULL) {
       
   134       if (p = strchr(buf, ':')) {
       
   135         long v = strtol(p+1, NULL, 0);
       
   136         if (strncmp(buf, "CPU implementer", sizeof "CPU implementer" - 1) == 0) {
       
   137           _cpu = v;
       
   138           cpu_lines++;
       
   139         } else if (strncmp(buf, "CPU variant", sizeof "CPU variant" - 1) == 0) {
       
   140           _variant = v;
       
   141         } else if (strncmp(buf, "CPU part", sizeof "CPU part" - 1) == 0) {
       
   142           if (_model != v)  _model2 = _model;
       
   143           _model = v;
       
   144         } else if (strncmp(buf, "CPU revision", sizeof "CPU revision" - 1) == 0) {
       
   145           _revision = v;
       
   146         }
       
   147       }
       
   148     }
       
   149     fclose(f);
       
   150   }
       
   151 
       
   152   // Enable vendor specific features
       
   153   if (_cpu == CPU_CAVIUM && _variant == 0) _cpuFeatures |= CPU_DMB_ATOMICS;
       
   154   if (_cpu == CPU_ARM && (_model == 0xd03 || _model2 == 0xd03)) _cpuFeatures |= CPU_A53MAC;
       
   155   // If an olde style /proc/cpuinfo (cpu_lines == 1) then if _model is an A57 (0xd07)
       
   156   // we assume the worst and assume we could be on a big little system and have
       
   157   // undisclosed A53 cores which we could be swapped to at any stage
       
   158   if (_cpu == CPU_ARM && cpu_lines == 1 && _model == 0xd07) _cpuFeatures |= CPU_A53MAC;
       
   159 
       
   160   sprintf(buf, "0x%02x:0x%x:0x%03x:%d", _cpu, _variant, _model, _revision);
       
   161   if (_model2) sprintf(buf+strlen(buf), "(0x%03x)", _model2);
       
   162   if (auxv & HWCAP_ASIMD) strcat(buf, ", simd");
   126   if (auxv & HWCAP_CRC32) strcat(buf, ", crc");
   163   if (auxv & HWCAP_CRC32) strcat(buf, ", crc");
   127   if (auxv & HWCAP_AES)   strcat(buf, ", aes");
   164   if (auxv & HWCAP_AES)   strcat(buf, ", aes");
   128   if (auxv & HWCAP_SHA1)  strcat(buf, ", sha1");
   165   if (auxv & HWCAP_SHA1)  strcat(buf, ", sha1");
   129   if (auxv & HWCAP_SHA2)  strcat(buf, ", sha256");
   166   if (auxv & HWCAP_SHA2)  strcat(buf, ", sha256");
   130 
   167 
   131   _features_str = strdup(buf);
   168   _features_str = os::strdup(buf);
   132 
   169 
   133   if (FLAG_IS_DEFAULT(UseCRC32)) {
   170   if (FLAG_IS_DEFAULT(UseCRC32)) {
   134     UseCRC32 = (auxv & HWCAP_CRC32) != 0;
   171     UseCRC32 = (auxv & HWCAP_CRC32) != 0;
   135   }
   172   }
   136   if (UseCRC32 && (auxv & HWCAP_CRC32) == 0) {
   173   if (UseCRC32 && (auxv & HWCAP_CRC32) == 0) {
   200 
   237 
   201   if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
   238   if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
   202     UseMultiplyToLenIntrinsic = true;
   239     UseMultiplyToLenIntrinsic = true;
   203   }
   240   }
   204 
   241 
       
   242   if (FLAG_IS_DEFAULT(UseBarriersForVolatile)) {
       
   243     UseBarriersForVolatile = (_cpuFeatures & CPU_DMB_ATOMICS) != 0;
       
   244   }
       
   245 
   205 #ifdef COMPILER2
   246 #ifdef COMPILER2
   206   if (FLAG_IS_DEFAULT(OptoScheduling)) {
   247   if (FLAG_IS_DEFAULT(OptoScheduling)) {
   207     OptoScheduling = true;
   248     OptoScheduling = true;
   208   }
   249   }
   209 #endif
   250 #endif