412 icache_line_size_(kUnknownCacheLineSize),
413 dcache_line_size_(kUnknownCacheLineSize),
414 num_virtual_address_bits_(kUnknownNumVirtualAddressBits),
426 has_intel_jcc_erratum_(false),
430 has_avx_vnni_(false),
431 has_avx_vnni_int8_(false),
443 has_vfp3_d32_(false),
445 has_dot_prod_(false),
451 is_fp64_mode_(false),
452 has_non_stop_time_stamp_counter_(false),
453 is_running_in_vm_(false),
462#if defined(V8_OS_STARBOARD)
463 if (StarboardDetectCPU()) {
468#if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
478 __cpuid(cpu_info, 0);
479 unsigned num_ids = cpu_info[0];
480 std::swap(cpu_info[2], cpu_info[3]);
481 memcpy(
vendor_, cpu_info + 1, 12);
486 __cpuid(cpu_info, 1);
488 int cpu_info70[4] = {0};
489 int cpu_info71[4] = {0};
491 __cpuid(cpu_info70, 7);
493 if (cpu_info70[0] >= 1) {
494 __cpuidex(cpu_info71, 7, 1);
499 model_ = ((cpu_info[0] >> 4) & 0xF) + ((cpu_info[0] >> 12) & 0xF0);
500 family_ = (cpu_info[0] >> 8) & 0xF;
501 type_ = (cpu_info[0] >> 12) & 0x3;
504 has_fpu_ = (cpu_info[3] & 0x00000001) != 0;
505 has_cmov_ = (cpu_info[3] & 0x00008000) != 0;
506 has_mmx_ = (cpu_info[3] & 0x00800000) != 0;
507 has_sse_ = (cpu_info[3] & 0x02000000) != 0;
508 has_sse2_ = (cpu_info[3] & 0x04000000) != 0;
509 has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
515 has_avx_ = (cpu_info[2] & 0x10000000) != 0;
516 has_avx2_ = (cpu_info70[1] & 0x00000020) != 0;
519 has_fma3_ = (cpu_info[2] & 0x00001000) != 0;
520 has_f16c_ = (cpu_info[2] & 0x20000000) != 0;
523 has_cetss_ = (cpu_info70[2] & 0x00000080) != 0;
578 __cpuid(cpu_info, 7);
579 has_bmi1_ = (cpu_info[1] & 0x00000008) != 0;
580 has_bmi2_ = (cpu_info[1] & 0x00000100) != 0;
584 __cpuid(cpu_info, 0x80000000);
585 unsigned num_ext_ids = cpu_info[0];
588 if (num_ext_ids > 0x80000000) {
589 __cpuid(cpu_info, 0x80000001);
592 has_sahf_ = (cpu_info[2] & 0x00000001) != 0;
596 const unsigned parameter_containing_non_stop_time_stamp_counter = 0x80000007;
597 if (num_ext_ids >= parameter_containing_non_stop_time_stamp_counter) {
598 __cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter);
602 const unsigned virtual_physical_address_bits = 0x80000008;
603 if (num_ext_ids >= virtual_physical_address_bits) {
604 __cpuid(cpu_info, virtual_physical_address_bits);
610 int cpu_info_hv[4] = {};
611 __cpuid(cpu_info_hv, 0x40000000);
612 if (cpu_info_hv[1] == 0x7263694D &&
613 cpu_info_hv[2] == 0x666F736F &&
614 cpu_info_hv[3] == 0x76482074) {
625#elif V8_HOST_ARCH_ARM
632 char*
implementer = cpu_info.ExtractField(
"CPU implementer");
642 char*
variant = cpu_info.ExtractField(
"CPU variant");
653 char*
part = cpu_info.ExtractField(
"CPU part");
654 if (
part !=
nullptr) {
669 char* architecture = cpu_info.ExtractField(
"CPU architecture");
670 if (architecture !=
nullptr) {
673 if (
end == architecture) {
675 if (strcmp(architecture,
"AArch64") == 0) {
694 char* processor = cpu_info.ExtractField(
"Processor");
695 if (HasListItem(processor,
"(v6l)")) {
703 char* processor = cpu_info.ExtractField(
"model name");
704 if (HasListItem(processor,
"(v6l)")) {
712 uint32_t hwcaps, hwcaps2;
713 std::tie(hwcaps, hwcaps2) = ReadELFHWCaps();
717 has_vfp_ = (hwcaps & HWCAP_VFP) != 0;
718 has_vfp3_ = (hwcaps & (HWCAP_VFPv3 | HWCAP_VFPv3D16 | HWCAP_VFPv4)) != 0;
720 (hwcaps & HWCAP_VFPD32) != 0));
723 char* features = cpu_info.ExtractField(
"Features");
725 has_neon_ = HasListItem(features,
"neon");
727 has_vfp_ = HasListItem(features,
"vfp");
728 if (HasListItem(features,
"vfpv3d16")) {
730 }
else if (HasListItem(features,
"vfpv3")) {
765 uint32_t cpu_flags = SYSPAGE_ENTRY(cpuinfo)->flags;
766 if (cpu_flags & ARM_CPU_FLAG_V7) {
769 }
else if (cpu_flags & ARM_CPU_FLAG_V6) {
775 has_fpu_ = (cpu_flags & CPU_FLAG_FPU) != 0;
777 if (cpu_flags & ARM_CPU_FLAG_NEON) {
780#ifdef ARM_CPU_FLAG_VFP_D32
784 has_idiva_ = (cpu_flags & ARM_CPU_FLAG_IDIV) != 0;
788#elif V8_HOST_ARCH_MIPS64
796 char* cpu_model = cpu_info.ExtractField(
"cpu model");
797 has_fpu_ = HasListItem(cpu_model,
"FPU");
798 char* ASEs = cpu_info.ExtractField(
"ASEs implemented");
799 has_msa_ = HasListItem(ASEs,
"msa");
803#elif V8_HOST_ARCH_ARM64
811#if !defined(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE)
812 constexpr int PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE = 44;
814#if !defined(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)
815 constexpr int PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE = 43;
817#if !defined(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE)
818 constexpr int PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE = 34;
820#if !defined(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)
821 constexpr int PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE = 30;
825 IsProcessorFeaturePresent(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE);
827 IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE);
829 IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE);
831 IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
835 uint32_t hwcaps, hwcaps2;
836 std::tie(hwcaps, hwcaps2) = ReadELFHWCaps();
837 has_mte_ = (hwcaps2 & HWCAP2_MTE) != 0;
841 has_lse_ = (hwcaps & HWCAP_ATOMICS) != 0;
848 char* features = cpu_info.ExtractField(
"Features");
851 has_lse_ = HasListItem(features,
"atomics");
853 has_fp16_ = HasListItem(features,
"half");
854 has_sha3_ = HasListItem(features,
"sha3");
859 int64_t feat_jscvt = 0;
860 size_t feat_jscvt_size =
sizeof(feat_jscvt);
861 if (sysctlbyname(
"hw.optional.arm.FEAT_JSCVT", &feat_jscvt, &feat_jscvt_size,
867 int64_t feat_dot_prod = 0;
868 size_t feat_dot_prod_size =
sizeof(feat_dot_prod);
869 if (sysctlbyname(
"hw.optional.arm.FEAT_DotProd", &feat_dot_prod,
870 &feat_dot_prod_size,
nullptr, 0) == -1) {
875 int64_t feat_lse = 0;
876 size_t feat_lse_size =
sizeof(feat_lse);
877 if (sysctlbyname(
"hw.optional.arm.FEAT_LSE", &feat_lse, &feat_lse_size,
883 int64_t feat_pmull = 0;
884 size_t feat_pmull_size =
sizeof(feat_pmull);
885 if (sysctlbyname(
"hw.optional.arm.FEAT_PMULL", &feat_pmull, &feat_pmull_size,
892 size_t fp16_size =
sizeof(fp16);
893 if (sysctlbyname(
"hw.optional.arm.FEAT_FP16", &fp16, &fp16_size,
nullptr,
899 int64_t feat_sha3 = 0;
900 size_t feat_sha3_size =
sizeof(feat_sha3);
901 if (sysctlbyname(
"hw.optional.arm.FEAT_SHA3", &feat_sha3, &feat_sha3_size,
918#elif V8_HOST_ARCH_PPC64
923 char* auxv_cpu_type =
nullptr;
928 size_t n = fread(&entry,
sizeof(entry), 1, fp);
929 if (n == 0 || entry.a_type == AT_NULL) {
932 switch (entry.a_type) {
934 auxv_cpu_type =
reinterpret_cast<char*
>(entry.a_un.a_val);
949 if (strcmp(auxv_cpu_type,
"power10") == 0) {
951 }
else if (strcmp(auxv_cpu_type,
"power9") == 0) {
953 }
else if (strcmp(auxv_cpu_type,
"power8") == 0) {
959 switch (_system_configuration.implementation) {
973#elif V8_HOST_ARCH_RISCV64
976#if (V8_GLIBC_PREREQ(2, 39))
977#include <asm/hwprobe.h>
978#include <asm/unistd.h>
979 riscv_hwprobe
pairs[] = {{RISCV_HWPROBE_KEY_IMA_EXT_0, 0}};
980 if (!syscall(__NR_riscv_hwprobe, &
pairs,
981 sizeof(
pairs) /
sizeof(riscv_hwprobe), 0,
nullptr, 0)) {
982 if (
pairs[0].value & RISCV_HWPROBE_IMA_V) {
985 if (
pairs[0].value & RISCV_HWPROBE_IMA_FD) {
988 if (
pairs[0].value & RISCV_HWPROBE_EXT_ZBA) {
991 if (
pairs[0].value & RISCV_HWPROBE_EXT_ZBB) {
994 if (
pairs[0].value & RISCV_HWPROBE_EXT_ZBS) {
999 char* features = cpu_info.ExtractField(
"isa");
1001 if (HasListItem(features,
"rv64imafdc")) {
1004 if (HasListItem(features,
"rv64imafdcv")) {
1010 char* mmu = cpu_info.ExtractField(
"mmu");
1011 if (HasListItem(mmu,
"sv48")) {
1014 if (HasListItem(mmu,
"sv39")) {
1017 if (HasListItem(mmu,
"sv57")) {