diff --git a/src/snmalloc/aal/aal.h b/src/snmalloc/aal/aal.h index f0d12072d..a584809f1 100644 --- a/src/snmalloc/aal/aal.h +++ b/src/snmalloc/aal/aal.h @@ -173,6 +173,7 @@ namespace snmalloc else { #if __has_builtin(__builtin_readcyclecounter) && !defined(__APPLE__) && \ + !defined(__aarch64__) && !defined(_M_ARM64) && !defined(_M_ARM64EC) && \ !defined(SNMALLOC_NO_AAL_BUILTINS) return __builtin_readcyclecounter(); #else diff --git a/src/snmalloc/aal/aal_arm.h b/src/snmalloc/aal/aal_arm.h index 5a9fdc5eb..cc6abab9a 100644 --- a/src/snmalloc/aal/aal_arm.h +++ b/src/snmalloc/aal/aal_arm.h @@ -4,6 +4,7 @@ # define SNMALLOC_VA_BITS_64 # ifdef _MSC_VER # include +# include # endif #else # define SNMALLOC_VA_BITS_32 @@ -32,7 +33,7 @@ namespace snmalloc * Bitmap of AalFeature flags */ static constexpr uint64_t aal_features = IntegerPointers -#if defined(SNMALLOC_VA_BITS_32) || !defined(__APPLE__) +#if defined(SNMALLOC_VA_BITS_32) | NoCpuCycleCounters #endif #if defined(SNMALLOC_COMPILER_SUPPORT_PACA_PACG) && \ @@ -71,12 +72,18 @@ namespace snmalloc #endif } -#if defined(SNMALLOC_VA_BITS_64) && defined(__APPLE__) +#if defined(SNMALLOC_VA_BITS_64) static inline uint64_t tick() noexcept { +# ifdef _MSC_VER + // ARM64_SYSREG(op0, op1, CRn, CRm, op2) encoding for CNTVCT_EL0. + return static_cast( + _ReadStatusReg(ARM64_SYSREG(3, 3, 14, 0, 2))); +# else uint64_t t; __asm__ volatile("mrs %0, cntvct_el0" : "=r"(t)); return t; +# endif } #endif