Skip to content

tenzr::JitCache

Process-wide cache of compiled executables keyed by namespaced structural hashes.

#include <jit_cache.h>

Public Functions

Name
JitCache & Instance()
Access the singleton cache.
uint64_t DomainKey(uint64_t domain, uint64_t hash)
Combine a domain tag with a structural hash to form a namespaced cache key.
JitCache() =default
~JitCache()
Drop every cached executable on shutdown.
JitCache(const JitCache & ) =delete
JitCache & operator=(const JitCache & ) =delete
std::shared_ptr< CachedExecutable > Get(uint64_t hash)
Look up an executable by hash, returning null on a miss.
void Put(uint64_t hash, std::shared_ptr< CachedExecutable > exec)
Insert or replace the executable stored for a hash.
bool Contains(uint64_t hash) const
Whether an executable exists for a hash.
size_t Size() const
Number of cached executables.
void Clear()
Drop every cached executable.

Public Attributes

Name
constexpr uint64_t kEagerKeyDomain
Domain tags keep eager-AST and JIT-signature keys in disjoint namespaces.
constexpr uint64_t kJitKeyDomain

Public Functions Documentation

function Instance

static JitCache & Instance()

Access the singleton cache.

Return: Reference to the singleton JitCache.

Get the process-wide JIT executable cache.

function DomainKey

static inline uint64_t DomainKey(
    uint64_t domain,
    uint64_t hash
)

Combine a domain tag with a structural hash to form a namespaced cache key.

function JitCache

JitCache() =default

function ~JitCache

~JitCache()

Drop every cached executable on shutdown.

function JitCache

JitCache(
    const JitCache & 
) =delete

function operator=

JitCache & operator=(
    const JitCache & 
) =delete

function Get

std::shared_ptr< CachedExecutable > Get(
    uint64_t hash
)

Look up an executable by hash, returning null on a miss.

Parameters:

  • hash Structural AST hash.

Return: The cached executable, or nullptr on a miss.

Look up a cached executable by graph hash.

function Put

void Put(
    uint64_t hash,
    std::shared_ptr< CachedExecutable > exec
)

Insert or replace the executable stored for a hash.

Parameters:

  • hash Structural AST hash.
  • exec Compiled executable to cache.

Insert or replace the executable stored under hash.

function Contains

bool Contains(
    uint64_t hash
) const

Whether an executable exists for a hash.

Parameters:

  • hash Structural AST hash.

Return: true when present.

Test whether an executable is cached for hash.

function Size

size_t Size() const

Number of cached executables.

Return: Cache entry count.

Number of executables currently cached.

function Clear

void Clear()

Drop every cached executable.

Remove every cached executable.

Public Attributes Documentation

variable kEagerKeyDomain

static constexpr uint64_t kEagerKeyDomain = 0xA57D0C0DE5EEDULL;

Domain tags keep eager-AST and JIT-signature keys in disjoint namespaces.

variable kJitKeyDomain

static constexpr uint64_t kJitKeyDomain = 0x117C0DE5EED0ULL;