< prev index next >

src/hotspot/cpu/x86/vm_version_ext_x86.cpp

Print this page


   1 /*
   2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  26 #include "jvm.h"
  27 #include "utilities/macros.hpp"
  28 #include "asm/macroAssembler.hpp"
  29 #include "asm/macroAssembler.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/stubCodeGenerator.hpp"
  34 #include "vm_version_ext_x86.hpp"
  35 
  36 typedef enum {
  37    CPU_FAMILY_8086_8088  = 0,
  38    CPU_FAMILY_INTEL_286  = 2,
  39    CPU_FAMILY_INTEL_386  = 3,
  40    CPU_FAMILY_INTEL_486  = 4,
  41    CPU_FAMILY_PENTIUM    = 5,
  42    CPU_FAMILY_PENTIUMPRO = 6,    // Same family several models
  43    CPU_FAMILY_PENTIUM_4  = 0xF
  44 } FamilyFlag;
  45 
  46 typedef enum {
  47   RDTSCP_FLAG  = 0x08000000, // bit 27
  48   INTEL64_FLAG = 0x20000000  // bit 29
  49 } _featureExtendedEdxFlag;
  50 
  51 #define CPUID_STANDARD_FN   0x0
  52 #define CPUID_STANDARD_FN_1 0x1
  53 #define CPUID_STANDARD_FN_4 0x4
  54 #define CPUID_STANDARD_FN_B 0xb
  55 
  56 #define CPUID_EXTENDED_FN   0x80000000
  57 #define CPUID_EXTENDED_FN_1 0x80000001
  58 #define CPUID_EXTENDED_FN_2 0x80000002
  59 #define CPUID_EXTENDED_FN_3 0x80000003
  60 #define CPUID_EXTENDED_FN_4 0x80000004
  61 #define CPUID_EXTENDED_FN_7 0x80000007
  62 #define CPUID_EXTENDED_FN_8 0x80000008
  63 
  64 typedef enum {
  65    FPU_FLAG     = 0x00000001,
  66    VME_FLAG     = 0x00000002,
  67    DE_FLAG      = 0x00000004,
  68    PSE_FLAG     = 0x00000008,
  69    TSC_FLAG     = 0x00000010,


 323   return ((_cpuid_info.ext_cpuid1_edx.value & INTEL64_FLAG) == INTEL64_FLAG);
 324 }
 325 
 326 bool VM_Version_Ext::is_netburst(void) {
 327   return (is_intel() && (extended_cpu_family() == CPU_FAMILY_PENTIUM_4));
 328 }
 329 
 330 bool VM_Version_Ext::supports_tscinv_ext(void) {
 331   if (!supports_tscinv_bit()) {
 332     return false;
 333   }
 334 
 335   if (is_intel()) {
 336     return true;
 337   }
 338 
 339   if (is_amd()) {
 340     return !is_amd_Barcelona();
 341   }
 342 
 343   if (is_hygon()) {
 344     return true;
 345   }
 346 
 347   return false;
 348 }
 349 
 350 void VM_Version_Ext::resolve_cpu_information_details(void) {
 351 
 352   // in future we want to base this information on proper cpu
 353   // and cache topology enumeration such as:
 354   // Intel 64 Architecture Processor Topology Enumeration
 355   // which supports system cpu and cache topology enumeration
 356   // either using 2xAPICIDs or initial APICIDs
 357 
 358   // currently only rough cpu information estimates
 359   // which will not necessarily reflect the exact configuration of the system
 360 
 361   // this is the number of logical hardware threads
 362   // visible to the operating system
 363   _no_of_threads = os::processor_count();
 364 
 365   // find out number of threads per cpu package
 366   int threads_per_package = threads_per_core() * cores_per_cpu();


 386   return _no_of_threads;
 387 }
 388 
 389 int VM_Version_Ext::number_of_cores(void) {
 390   if (_no_of_cores == 0) {
 391     resolve_cpu_information_details();
 392   }
 393   return _no_of_cores;
 394 }
 395 
 396 int VM_Version_Ext::number_of_sockets(void) {
 397   if (_no_of_packages == 0) {
 398     resolve_cpu_information_details();
 399   }
 400   return _no_of_packages;
 401 }
 402 
 403 const char* VM_Version_Ext::cpu_family_description(void) {
 404   int cpu_family_id = extended_cpu_family();
 405   if (is_amd()) {
 406     if (cpu_family_id < ExtendedFamilyIdLength_AMD) {
 407       return _family_id_amd[cpu_family_id];
 408     }
 409   }
 410   if (is_intel()) {
 411     if (cpu_family_id == CPU_FAMILY_PENTIUMPRO) {
 412       return cpu_model_description();
 413     }
 414     if (cpu_family_id < ExtendedFamilyIdLength_INTEL) {
 415       return _family_id_intel[cpu_family_id];
 416     }
 417   }
 418   if (is_hygon()) {
 419     return "Dhyana";
 420   }
 421   return "Unknown x86";
 422 }
 423 
 424 int VM_Version_Ext::cpu_type_description(char* const buf, size_t buf_len) {
 425   assert(buf != NULL, "buffer is NULL!");
 426   assert(buf_len >= CPU_TYPE_DESC_BUF_SIZE, "buffer len should at least be == CPU_TYPE_DESC_BUF_SIZE!");
 427 
 428   const char* cpu_type = NULL;
 429   const char* x64 = NULL;
 430 
 431   if (is_intel()) {
 432     cpu_type = "Intel";
 433     x64 = cpu_is_em64t() ? " Intel64" : "";
 434   } else if (is_amd()) {
 435     cpu_type = "AMD";
 436     x64 = cpu_is_em64t() ? " AMD64" : "";
 437   } else if (is_hygon()) {
 438     cpu_type = "Hygon";
 439     x64 = cpu_is_em64t() ? " AMD64" : "";
 440   } else {
 441     cpu_type = "Unknown x86";
 442     x64 = cpu_is_em64t() ? " x86_64" : "";
 443   }
 444 
 445   jio_snprintf(buf, buf_len, "%s %s%s SSE SSE2%s%s%s%s%s%s%s%s",
 446     cpu_type,
 447     cpu_family_description(),
 448     supports_ht() ? " (HT)" : "",
 449     supports_sse3() ? " SSE3" : "",
 450     supports_ssse3() ? " SSSE3" : "",
 451     supports_sse4_1() ? " SSE4.1" : "",
 452     supports_sse4_2() ? " SSE4.2" : "",
 453     supports_sse4a() ? " SSE4A" : "",
 454     is_netburst() ? " Netburst" : "",
 455     is_intel_family_core() ? " Core" : "",
 456     x64);
 457 
 458   return OS_OK;
 459 }


 691       frequency += (jlong)(*(Hz_location - 2) - '0') * (multiplier / 100);
 692     } else { // format is "xxxx"
 693       frequency =  (jlong)(*(Hz_location - 5) - '0') * 1000;
 694       frequency += (jlong)(*(Hz_location - 4) - '0') * 100;
 695       frequency += (jlong)(*(Hz_location - 3) - '0') * 10;
 696       frequency += (jlong)(*(Hz_location - 2) - '0');
 697       frequency *= multiplier;
 698     }
 699   }
 700   return frequency;
 701 }
 702 
 703 
 704 jlong VM_Version_Ext::maximum_qualified_cpu_frequency(void) {
 705   if (_max_qualified_cpu_frequency == 0) {
 706     _max_qualified_cpu_frequency = max_qualified_cpu_freq_from_brand_string();
 707   }
 708   return _max_qualified_cpu_frequency;
 709 }
 710 
 711 const char* const VM_Version_Ext::_family_id_intel[ExtendedFamilyIdLength_INTEL] = {
 712   "8086/8088",
 713   "",
 714   "286",
 715   "386",
 716   "486",
 717   "Pentium",
 718   "Pentium Pro",   //or Pentium-M/Woodcrest depeding on model
 719   "",
 720   "",
 721   "",
 722   "",
 723   "",
 724   "",
 725   "",
 726   "",
 727   "Pentium 4"
 728 };
 729 
 730 const char* const VM_Version_Ext::_family_id_amd[ExtendedFamilyIdLength_AMD] = {
 731   "",
 732   "",
 733   "",
 734   "",
 735   "5x86",
 736   "K5/K6",
 737   "Athlon/AthlonXP",
 738   "",
 739   "",
 740   "",
 741   "",
 742   "",
 743   "",
 744   "",
 745   "",
 746   "Opteron/Athlon64",
 747   "Opteron QC/Phenom"  // Barcelona et.al.
 748   "",
 749   "",
 750   "",
 751   "",
 752   "",
 753   "",
 754   "Zen"
 755 };
 756 // Partially from Intel 64 and IA-32 Architecture Software Developer's Manual,
 757 // September 2013, Vol 3C Table 35-1
 758 const char* const VM_Version_Ext::_model_id_pentium_pro[] = {
 759   "",
 760   "Pentium Pro",
 761   "",
 762   "Pentium II model 3",
 763   "",
 764   "Pentium II model 5/Xeon/Celeron",
 765   "Celeron",
 766   "Pentium III/Pentium III Xeon",
 767   "Pentium III/Pentium III Xeon",
 768   "Pentium M model 9",    // Yonah
 769   "Pentium III, model A",
 770   "Pentium III, model B",
 771   "",
 772   "Pentium M model D",    // Dothan
 773   "",
 774   "Core 2",               // 0xf Woodcrest/Conroe/Merom/Kentsfield/Clovertown


   1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  26 #include "jvm.h"
  27 #include "utilities/macros.hpp"
  28 #include "asm/macroAssembler.hpp"
  29 #include "asm/macroAssembler.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/stubCodeGenerator.hpp"
  34 #include "vm_version_ext_x86.hpp"
  35 
  36 typedef enum {
  37    CPU_FAMILY_8086_8088  = 0,
  38    CPU_FAMILY_INTEL_286  = 2,
  39    CPU_FAMILY_INTEL_386  = 3,
  40    CPU_FAMILY_INTEL_486  = 4,
  41    CPU_FAMILY_PENTIUM    = 5,
  42    CPU_FAMILY_PENTIUMPRO = 6,    // Same family several models
  43    CPU_FAMILY_PENTIUM_4  = 0xF
  44 } FamilyFlag;
  45 
  46  typedef enum {
  47     RDTSCP_FLAG  = 0x08000000, // bit 27
  48     INTEL64_FLAG = 0x20000000  // bit 29
  49   } _featureExtendedEdxFlag;
  50 
  51 #define CPUID_STANDARD_FN   0x0
  52 #define CPUID_STANDARD_FN_1 0x1
  53 #define CPUID_STANDARD_FN_4 0x4
  54 #define CPUID_STANDARD_FN_B 0xb
  55 
  56 #define CPUID_EXTENDED_FN   0x80000000
  57 #define CPUID_EXTENDED_FN_1 0x80000001
  58 #define CPUID_EXTENDED_FN_2 0x80000002
  59 #define CPUID_EXTENDED_FN_3 0x80000003
  60 #define CPUID_EXTENDED_FN_4 0x80000004
  61 #define CPUID_EXTENDED_FN_7 0x80000007
  62 #define CPUID_EXTENDED_FN_8 0x80000008
  63 
  64 typedef enum {
  65    FPU_FLAG     = 0x00000001,
  66    VME_FLAG     = 0x00000002,
  67    DE_FLAG      = 0x00000004,
  68    PSE_FLAG     = 0x00000008,
  69    TSC_FLAG     = 0x00000010,


 323   return ((_cpuid_info.ext_cpuid1_edx.value & INTEL64_FLAG) == INTEL64_FLAG);
 324 }
 325 
 326 bool VM_Version_Ext::is_netburst(void) {
 327   return (is_intel() && (extended_cpu_family() == CPU_FAMILY_PENTIUM_4));
 328 }
 329 
 330 bool VM_Version_Ext::supports_tscinv_ext(void) {
 331   if (!supports_tscinv_bit()) {
 332     return false;
 333   }
 334 
 335   if (is_intel()) {
 336     return true;
 337   }
 338 
 339   if (is_amd()) {
 340     return !is_amd_Barcelona();
 341   }
 342 




 343   return false;
 344 }
 345 
 346 void VM_Version_Ext::resolve_cpu_information_details(void) {
 347 
 348   // in future we want to base this information on proper cpu
 349   // and cache topology enumeration such as:
 350   // Intel 64 Architecture Processor Topology Enumeration
 351   // which supports system cpu and cache topology enumeration
 352   // either using 2xAPICIDs or initial APICIDs
 353 
 354   // currently only rough cpu information estimates
 355   // which will not necessarily reflect the exact configuration of the system
 356 
 357   // this is the number of logical hardware threads
 358   // visible to the operating system
 359   _no_of_threads = os::processor_count();
 360 
 361   // find out number of threads per cpu package
 362   int threads_per_package = threads_per_core() * cores_per_cpu();


 382   return _no_of_threads;
 383 }
 384 
 385 int VM_Version_Ext::number_of_cores(void) {
 386   if (_no_of_cores == 0) {
 387     resolve_cpu_information_details();
 388   }
 389   return _no_of_cores;
 390 }
 391 
 392 int VM_Version_Ext::number_of_sockets(void) {
 393   if (_no_of_packages == 0) {
 394     resolve_cpu_information_details();
 395   }
 396   return _no_of_packages;
 397 }
 398 
 399 const char* VM_Version_Ext::cpu_family_description(void) {
 400   int cpu_family_id = extended_cpu_family();
 401   if (is_amd()) {
 402     return _family_id_amd[cpu_family_id];


 403   }
 404   if (is_intel()) {
 405     if (cpu_family_id == CPU_FAMILY_PENTIUMPRO) {
 406       return cpu_model_description();
 407     }
 408     return _family_id_intel[cpu_family_id];





 409   }
 410   return "Unknown x86";
 411 }
 412 
 413 int VM_Version_Ext::cpu_type_description(char* const buf, size_t buf_len) {
 414   assert(buf != NULL, "buffer is NULL!");
 415   assert(buf_len >= CPU_TYPE_DESC_BUF_SIZE, "buffer len should at least be == CPU_TYPE_DESC_BUF_SIZE!");
 416 
 417   const char* cpu_type = NULL;
 418   const char* x64 = NULL;
 419 
 420   if (is_intel()) {
 421     cpu_type = "Intel";
 422     x64 = cpu_is_em64t() ? " Intel64" : "";
 423   } else if (is_amd()) {
 424     cpu_type = "AMD";
 425     x64 = cpu_is_em64t() ? " AMD64" : "";



 426   } else {
 427     cpu_type = "Unknown x86";
 428     x64 = cpu_is_em64t() ? " x86_64" : "";
 429   }
 430 
 431   jio_snprintf(buf, buf_len, "%s %s%s SSE SSE2%s%s%s%s%s%s%s%s",
 432     cpu_type,
 433     cpu_family_description(),
 434     supports_ht() ? " (HT)" : "",
 435     supports_sse3() ? " SSE3" : "",
 436     supports_ssse3() ? " SSSE3" : "",
 437     supports_sse4_1() ? " SSE4.1" : "",
 438     supports_sse4_2() ? " SSE4.2" : "",
 439     supports_sse4a() ? " SSE4A" : "",
 440     is_netburst() ? " Netburst" : "",
 441     is_intel_family_core() ? " Core" : "",
 442     x64);
 443 
 444   return OS_OK;
 445 }


 677       frequency += (jlong)(*(Hz_location - 2) - '0') * (multiplier / 100);
 678     } else { // format is "xxxx"
 679       frequency =  (jlong)(*(Hz_location - 5) - '0') * 1000;
 680       frequency += (jlong)(*(Hz_location - 4) - '0') * 100;
 681       frequency += (jlong)(*(Hz_location - 3) - '0') * 10;
 682       frequency += (jlong)(*(Hz_location - 2) - '0');
 683       frequency *= multiplier;
 684     }
 685   }
 686   return frequency;
 687 }
 688 
 689 
 690 jlong VM_Version_Ext::maximum_qualified_cpu_frequency(void) {
 691   if (_max_qualified_cpu_frequency == 0) {
 692     _max_qualified_cpu_frequency = max_qualified_cpu_freq_from_brand_string();
 693   }
 694   return _max_qualified_cpu_frequency;
 695 }
 696 
 697 const char* const VM_Version_Ext::_family_id_intel[] = {
 698   "8086/8088",
 699   "",
 700   "286",
 701   "386",
 702   "486",
 703   "Pentium",
 704   "Pentium Pro",   //or Pentium-M/Woodcrest depeding on model
 705   "",
 706   "",
 707   "",
 708   "",
 709   "",
 710   "",
 711   "",
 712   "",
 713   "Pentium 4"
 714 };
 715 
 716 const char* const VM_Version_Ext::_family_id_amd[] = {
 717   "",
 718   "",
 719   "",
 720   "",
 721   "5x86",
 722   "K5/K6",
 723   "Athlon/AthlonXP",
 724   "",
 725   "",
 726   "",
 727   "",
 728   "",
 729   "",
 730   "",
 731   "",
 732   "Opteron/Athlon64",
 733   "Opteron QC/Phenom"  // Barcelona et.al.







 734 };
 735 // Partially from Intel 64 and IA-32 Architecture Software Developer's Manual,
 736 // September 2013, Vol 3C Table 35-1
 737 const char* const VM_Version_Ext::_model_id_pentium_pro[] = {
 738   "",
 739   "Pentium Pro",
 740   "",
 741   "Pentium II model 3",
 742   "",
 743   "Pentium II model 5/Xeon/Celeron",
 744   "Celeron",
 745   "Pentium III/Pentium III Xeon",
 746   "Pentium III/Pentium III Xeon",
 747   "Pentium M model 9",    // Yonah
 748   "Pentium III, model A",
 749   "Pentium III, model B",
 750   "",
 751   "Pentium M model D",    // Dothan
 752   "",
 753   "Core 2",               // 0xf Woodcrest/Conroe/Merom/Kentsfield/Clovertown


< prev index next >