24#define CACHE_BUCKETS 1021
31#define CACHE_MAX_ENTRIES INFIX_CACHE_MAX_ENTRIES
87static uint64_t
_cache_hash(
const char * sig,
void * target_fn,
bool is_safe) {
91 h = ((h << 5) + h) + c;
92 h ^= (uint64_t)(uintptr_t)target_fn;
94 h ^= 0x123456789ABCDEF0ULL;
104 uint64_t h =
_cache_hash(signature, target_fn, is_safe);
109 if (entry->trampoline->target_fn == target_fn && entry->trampoline->is_safe == is_safe &&
110 strcmp(entry->trampoline->signature, signature) == 0) {
114 entry->trampoline->ref_count++;
116 return entry->trampoline;
char * p
Definition 904_registry_benchmark.c:25
#define CACHE_MAX_ENTRIES
Definition cache.c:31
void _infix_cache_release(infix_forward_t *trampoline)
Definition cache.c:258
static size_t g_cache_count
Definition cache.c:48
static bool _cache_remove_no_lock(infix_forward_t *trampoline)
Definition cache.c:220
static infix_mutex_t g_cache_mutex
Definition cache.c:50
static _cache_entry_t * g_cache_lru_tail
Definition cache.c:46
#define CACHE_BUCKETS
Definition cache.c:24
void _infix_cache_clear(void)
Definition cache.c:183
static void _cache_lru_push_front(_cache_entry_t *entry)
Definition cache.c:73
static _cache_entry_t * g_cache_lru_head
Definition cache.c:44
bool _infix_cache_remove(infix_forward_t *trampoline)
Definition cache.c:247
static void _cache_lru_unlink(_cache_entry_t *entry)
Definition cache.c:56
static _cache_entry_t * g_trampoline_cache[CACHE_BUCKETS]
Definition cache.c:42
static uint64_t _cache_hash(const char *sig, void *target_fn, bool is_safe)
Definition cache.c:87
infix_forward_t * _infix_cache_lookup(const char *signature, void *target_fn, bool is_safe)
Definition cache.c:103
size_t _infix_cache_count(void)
Definition cache.c:206
void _infix_cache_insert(infix_forward_t *trampoline)
Definition cache.c:136
#define infix_free(ptr)
A macro that can be defined to override infix's allocator at compile time.
Definition infix.h:435
#define infix_malloc(n)
A macro that can be defined to override infix's allocator at compile time.
Definition infix.h:423
Internal data structures, function prototypes, and constants.
pthread_mutex_t infix_mutex_t
Definition infix_internals.h:161
#define INFIX_MUTEX_INITIALIZER
Definition infix_internals.h:162
#define INFIX_MUTEX_UNLOCK(m)
Definition infix_internals.h:164
INFIX_INTERNAL void _infix_forward_destroy_internal(infix_forward_t *trampoline)
Definition trampoline.c:712
#define INFIX_MUTEX_LOCK(m)
Definition infix_internals.h:163
struct _cache_entry_t * lru_prev
Definition cache.c:37
infix_forward_t * trampoline
Definition cache.c:35
struct _cache_entry_t * next
Definition cache.c:36
struct _cache_entry_t * lru_next
Definition cache.c:38
Internal definition of a forward trampoline handle.
Definition infix_internals.h:90
void * target_fn
Definition infix_internals.h:99
size_t ref_count
Definition infix_internals.h:102
bool is_safe
Definition infix_internals.h:101
char * signature
Definition infix_internals.h:103