Optimize edata_cmp_summary_compare when __uint128_t is available

This commit is contained in:
Guangli Dai 2024-09-13 15:52:22 -07:00 committed by Qi Wang
parent 734f29ce56
commit 0181aaa495
3 changed files with 34 additions and 0 deletions

View File

@ -562,6 +562,21 @@ AC_CACHE_CHECK([asm volatile support],
if test "x${je_cv_asm_volatile}" = "xyes"; then if test "x${je_cv_asm_volatile}" = "xyes"; then
AC_DEFINE([JEMALLOC_HAVE_ASM_VOLATILE], [ ], [ ]) AC_DEFINE([JEMALLOC_HAVE_ASM_VOLATILE], [ ], [ ])
fi fi
AC_CACHE_CHECK([__int128 support],
[je_cv_int128],
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
]],
[[
__int128 temp = 0;
return temp;
]])],
[je_cv_int128=yes],
[je_cv_int128=no],
[je_cv_int128=no]))
if test "x${je_cv_int128}" = "xyes"; then
AC_DEFINE([JEMALLOC_HAVE_INT128], [ ], [ ])
fi
LD_PRELOAD_VAR="LD_PRELOAD" LD_PRELOAD_VAR="LD_PRELOAD"
so="so" so="so"

View File

@ -666,6 +666,21 @@ edata_cmp_summary_get(const edata_t *edata) {
return result; return result;
} }
#ifdef JEMALLOC_HAVE_INT128
JEMALLOC_ALWAYS_INLINE unsigned __int128
edata_cmp_summary_encode(edata_cmp_summary_t src) {
return ((unsigned __int128)src.sn << 64) | src.addr;
}
static inline int
edata_cmp_summary_comp(edata_cmp_summary_t a, edata_cmp_summary_t b) {
unsigned __int128 a_encoded = edata_cmp_summary_encode(a);
unsigned __int128 b_encoded = edata_cmp_summary_encode(b);
if (a_encoded < b_encoded) return -1;
if (a_encoded == b_encoded) return 0;
return 1;
}
#else
static inline int static inline int
edata_cmp_summary_comp(edata_cmp_summary_t a, edata_cmp_summary_t b) { edata_cmp_summary_comp(edata_cmp_summary_t a, edata_cmp_summary_t b) {
/* /*
@ -683,6 +698,7 @@ edata_cmp_summary_comp(edata_cmp_summary_t a, edata_cmp_summary_t b) {
return (2 * ((a.sn > b.sn) - (a.sn < b.sn))) + return (2 * ((a.sn > b.sn) - (a.sn < b.sn))) +
((a.addr > b.addr) - (a.addr < b.addr)); ((a.addr > b.addr) - (a.addr < b.addr));
} }
#endif
static inline int static inline int
edata_snad_comp(const edata_t *a, const edata_t *b) { edata_snad_comp(const edata_t *a, const edata_t *b) {

View File

@ -454,6 +454,9 @@
*/ */
#undef JEMALLOC_HAVE_RDTSCP #undef JEMALLOC_HAVE_RDTSCP
/* If defined, use __int128 for optimization. */
#undef JEMALLOC_HAVE_INT128
#include "jemalloc/internal/jemalloc_internal_overrides.h" #include "jemalloc/internal/jemalloc_internal_overrides.h"
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ #endif /* JEMALLOC_INTERNAL_DEFS_H_ */