23 */ |
23 */ |
24 |
24 |
25 #ifndef CPU_X86_VM_VERSION_X86_HPP |
25 #ifndef CPU_X86_VM_VERSION_X86_HPP |
26 #define CPU_X86_VM_VERSION_X86_HPP |
26 #define CPU_X86_VM_VERSION_X86_HPP |
27 |
27 |
|
28 #include "memory/universe.hpp" |
28 #include "runtime/globals_extension.hpp" |
29 #include "runtime/globals_extension.hpp" |
29 #include "runtime/vm_version.hpp" |
30 #include "runtime/vm_version.hpp" |
30 |
31 |
31 class VM_Version : public Abstract_VM_Version { |
32 class VM_Version : public Abstract_VM_Version { |
32 friend class VMStructs; |
33 friend class VMStructs; |
336 #define CPU_AVX512_VPOPCNTDQ ((uint64_t)UCONST64(0x2000000000)) // Vector popcount |
340 #define CPU_AVX512_VPOPCNTDQ ((uint64_t)UCONST64(0x2000000000)) // Vector popcount |
337 #define CPU_VPCLMULQDQ ((uint64_t)UCONST64(0x4000000000)) //Vector carryless multiplication |
341 #define CPU_VPCLMULQDQ ((uint64_t)UCONST64(0x4000000000)) //Vector carryless multiplication |
338 #define CPU_VAES ((uint64_t)UCONST64(0x8000000000)) // Vector AES instructions |
342 #define CPU_VAES ((uint64_t)UCONST64(0x8000000000)) // Vector AES instructions |
339 #define CPU_VNNI ((uint64_t)UCONST64(0x10000000000)) // Vector Neural Network Instructions |
343 #define CPU_VNNI ((uint64_t)UCONST64(0x10000000000)) // Vector Neural Network Instructions |
340 |
344 |
341 enum Extended_Family { |
345 #define CPU_FLUSH ((uint64_t)UCONST64(0x20000000000)) // flush instruction |
|
346 #define CPU_FLUSHOPT ((uint64_t)UCONST64(0x40000000000)) // flushopt instruction |
|
347 #define CPU_CLWB ((uint64_t)UCONST64(0x80000000000)) // clwb instruction |
|
348 |
|
349 enum Extended_Family { |
342 // AMD |
350 // AMD |
343 CPU_FAMILY_AMD_11H = 0x11, |
351 CPU_FAMILY_AMD_11H = 0x11, |
344 // ZX |
352 // ZX |
345 CPU_FAMILY_ZX_CORE_F6 = 6, |
353 CPU_FAMILY_ZX_CORE_F6 = 6, |
346 CPU_FAMILY_ZX_CORE_F7 = 7, |
354 CPU_FAMILY_ZX_CORE_F7 = 7, |
356 CPU_MODEL_SANDYBRIDGE_EP = 0x2d, |
364 CPU_MODEL_SANDYBRIDGE_EP = 0x2d, |
357 CPU_MODEL_IVYBRIDGE_EP = 0x3a, |
365 CPU_MODEL_IVYBRIDGE_EP = 0x3a, |
358 CPU_MODEL_HASWELL_E3 = 0x3c, |
366 CPU_MODEL_HASWELL_E3 = 0x3c, |
359 CPU_MODEL_HASWELL_E7 = 0x3f, |
367 CPU_MODEL_HASWELL_E7 = 0x3f, |
360 CPU_MODEL_BROADWELL = 0x3d, |
368 CPU_MODEL_BROADWELL = 0x3d, |
361 CPU_MODEL_SKYLAKE = CPU_MODEL_HASWELL_E3 |
369 CPU_MODEL_SKYLAKE = 0x55 |
362 }; |
370 }; |
363 |
371 |
364 // cpuid information block. All info derived from executing cpuid with |
372 // cpuid information block. All info derived from executing cpuid with |
365 // various function numbers is stored here. Intel and AMD info is |
373 // various function numbers is stored here. Intel and AMD info is |
366 // merged in this block: accessor methods disentangle it. |
374 // merged in this block: accessor methods disentangle it. |
493 uint64_t result = 0; |
501 uint64_t result = 0; |
494 if (_cpuid_info.std_cpuid1_edx.bits.cmpxchg8 != 0) |
502 if (_cpuid_info.std_cpuid1_edx.bits.cmpxchg8 != 0) |
495 result |= CPU_CX8; |
503 result |= CPU_CX8; |
496 if (_cpuid_info.std_cpuid1_edx.bits.cmov != 0) |
504 if (_cpuid_info.std_cpuid1_edx.bits.cmov != 0) |
497 result |= CPU_CMOV; |
505 result |= CPU_CMOV; |
|
506 if (_cpuid_info.std_cpuid1_edx.bits.clflush != 0) |
|
507 result |= CPU_FLUSH; |
|
508 #ifdef _LP64 |
|
509 // clflush should always be available on x86_64 |
|
510 // if not we are in real trouble because we rely on it |
|
511 // to flush the code cache. |
|
512 assert ((result & CPU_FLUSH) != 0, "clflush should be available"); |
|
513 #endif |
498 if (_cpuid_info.std_cpuid1_edx.bits.fxsr != 0 || (is_amd_family() && |
514 if (_cpuid_info.std_cpuid1_edx.bits.fxsr != 0 || (is_amd_family() && |
499 _cpuid_info.ext_cpuid1_edx.bits.fxsr != 0)) |
515 _cpuid_info.ext_cpuid1_edx.bits.fxsr != 0)) |
500 result |= CPU_FXSR; |
516 result |= CPU_FXSR; |
501 // HT flag is set for multi-core processors also. |
517 // HT flag is set for multi-core processors also. |
502 if (threads_per_core() > 1) |
518 if (threads_per_core() > 1) |
573 result |= CPU_BMI2; |
589 result |= CPU_BMI2; |
574 if (_cpuid_info.sef_cpuid7_ebx.bits.sha != 0) |
590 if (_cpuid_info.sef_cpuid7_ebx.bits.sha != 0) |
575 result |= CPU_SHA; |
591 result |= CPU_SHA; |
576 if (_cpuid_info.std_cpuid1_ecx.bits.fma != 0) |
592 if (_cpuid_info.std_cpuid1_ecx.bits.fma != 0) |
577 result |= CPU_FMA; |
593 result |= CPU_FMA; |
|
594 if (_cpuid_info.sef_cpuid7_ebx.bits.clflushopt != 0) |
|
595 result |= CPU_FLUSHOPT; |
578 |
596 |
579 // AMD|Hygon features. |
597 // AMD|Hygon features. |
580 if (is_amd_family()) { |
598 if (is_amd_family()) { |
581 if ((_cpuid_info.ext_cpuid1_edx.bits.tdnow != 0) || |
599 if ((_cpuid_info.ext_cpuid1_edx.bits.tdnow != 0) || |
582 (_cpuid_info.ext_cpuid1_ecx.bits.prefetchw != 0)) |
600 (_cpuid_info.ext_cpuid1_ecx.bits.prefetchw != 0)) |
934 // SSE2 and later processors implement a 'pause' instruction |
955 // SSE2 and later processors implement a 'pause' instruction |
935 // that can be used for efficient implementation of |
956 // that can be used for efficient implementation of |
936 // the intrinsic for java.lang.Thread.onSpinWait() |
957 // the intrinsic for java.lang.Thread.onSpinWait() |
937 static bool supports_on_spin_wait() { return supports_sse2(); } |
958 static bool supports_on_spin_wait() { return supports_sse2(); } |
938 |
959 |
|
960 // x86_64 supports fast class initialization checks for static methods. |
|
961 static bool supports_fast_class_init_checks() { |
|
962 return LP64_ONLY(true) NOT_LP64(false); // not implemented on x86_32 |
|
963 } |
|
964 |
|
965 // there are several insns to force cache line sync to memory which |
|
966 // we can use to ensure mapped non-volatile memory is up to date with |
|
967 // pending in-cache changes. |
|
968 // |
|
969 // 64 bit cpus always support clflush which writes back and evicts |
|
970 // on 32 bit cpus support is recorded via a feature flag |
|
971 // |
|
972 // clflushopt is optional and acts like clflush except it does |
|
973 // not synchronize with other memory ops. it needs a preceding |
|
974 // and trailing StoreStore fence |
|
975 // |
|
976 // clwb is an optional, intel-specific instruction optional which |
|
977 // writes back without evicting the line. it also does not |
|
978 // synchronize with other memory ops. so, it also needs a preceding |
|
979 // and trailing StoreStore fence. |
|
980 |
|
981 #ifdef _LP64 |
|
982 static bool supports_clflush() { |
|
983 // clflush should always be available on x86_64 |
|
984 // if not we are in real trouble because we rely on it |
|
985 // to flush the code cache. |
|
986 // Unfortunately, Assembler::clflush is currently called as part |
|
987 // of generation of the code cache flush routine. This happens |
|
988 // under Universe::init before the processor features are set |
|
989 // up. Assembler::flush calls this routine to check that clflush |
|
990 // is allowed. So, we give the caller a free pass if Universe init |
|
991 // is still in progress. |
|
992 assert ((!Universe::is_fully_initialized() || (_features & CPU_FLUSH) != 0), "clflush should be available"); |
|
993 return true; |
|
994 } |
|
995 static bool supports_clflushopt() { return ((_features & CPU_FLUSHOPT) != 0); } |
|
996 static bool supports_clwb() { return ((_features & CPU_CLWB) != 0); } |
|
997 #else |
|
998 static bool supports_clflush() { return ((_features & CPU_FLUSH) != 0); } |
|
999 static bool supports_clflushopt() { return false; } |
|
1000 static bool supports_clwb() { return false; } |
|
1001 #endif // _LP64 |
|
1002 |
939 // support functions for virtualization detection |
1003 // support functions for virtualization detection |
940 private: |
1004 private: |
941 static void check_virt_cpuid(uint32_t idx, uint32_t *regs); |
1005 static void check_virt_cpuid(uint32_t idx, uint32_t *regs); |
942 static void check_virtualizations(); |
1006 static void check_virtualizations(); |
943 }; |
1007 }; |