abla/runtime/platform/host
Generated from source.
Source module; follow its importing module's re-export links.
Source: abla/runtime/platform/host.ab
malloc (extern)
trusted noescape extern:"c" fun malloc(size: int): i64*
Returns a native allocation or null on failure.
free (extern)
trusted noescape extern:"c" fun free(pointer: i64*): void
Releases a C allocator pointer.
calloc (extern)
trusted noescape extern:"c" fun calloc(count: int, size: int): i64*
Returns zeroed memory for the requested elements or null on failure.
realloc (extern)
trusted noescape extern:"c" fun realloc(pointer: i64*, size: int): i64*
Resizes a native allocation and returns its address or null on failure.
write (extern)
trusted noescape extern:"c" fun write(
descriptor: int,
data: i64*,
length: int
): int
Writes bytes to the descriptor and returns the count or -1 on failure.
ablaSimdTargetArch (extern)
trusted noescape extern:"intrinsic" fun ablaSimdTargetArch(): int
The target's architecture, as abla/simd/target declares it (the runtime does not import it). The system calls are in host_os.ab.
_exit (extern)
trusted noescape extern:"c" fun _exit(status: int): void
Terminates the process with the supplied status.
_longjmp (extern)
trusted noescape extern:"c" fun _longjmp(buffer: i64*, value: int): void
Restores the saved C jump context with the given return value.
ablaLinuxEnvironmentPointer (extern)
trusted noescape extern:"intrinsic" fun ablaLinuxEnvironmentPointer(): i64*
The environment block main received (abla_runtime_set_arguments stores it first thing), so the runtime reads its own variables without libc getenv.
pthread_mutex_init (extern)
trusted noescape extern:"c" fun pthread_mutex_init(
mutex: i64*,
attributes: i64*
): int
Initializes the mutex and returns zero on success.
pthread_mutex_lock (extern)
trusted noescape extern:"c" fun pthread_mutex_lock(mutex: i64*): int
Acquires the mutex and returns zero on success.
pthread_mutex_unlock (extern)
trusted noescape extern:"c" fun pthread_mutex_unlock(mutex: i64*): int
Releases the mutex and returns zero on success.
pthread_mutex_destroy (extern)
trusted noescape extern:"c" fun pthread_mutex_destroy(mutex: i64*): int
Destroys the mutex and returns zero on success.
pthread_create (extern)
trusted noescape extern:"c" fun pthread_create(
handle: i64*,
attributes: i64*,
entry: i64*,
argument: i64*
): int
Starts the specified thread, writes its handle and returns zero on success.
pthread_join (extern)
trusted noescape extern:"c" fun pthread_join(
handle: int,
result: i64*
): int
Waits for the thread and returns zero on success, optionally writing its result.
pthread_cond_init (extern)
trusted noescape extern:"c" fun pthread_cond_init(
condition: i64*,
attributes: i64*
): int
Initializes the condition variable and returns zero on success.
pthread_cond_wait (extern)
trusted noescape extern:"c" fun pthread_cond_wait(
condition: i64*,
mutex: i64*
): int
Waits on the condition while releasing and reacquiring the mutex, returning zero on success.
pthread_cond_broadcast (extern)
trusted noescape extern:"c" fun pthread_cond_broadcast(condition: i64*): int
Wakes all condition waiters and returns zero on success.
abla_stm_invoke (extern)
trusted noescape extern:"c" fun abla_stm_invoke(
closure: i64*,
output: i64*,
slot: i64*
): int
Generated with the module when transactions are reached (the backend's bootstrapLlvmDefineStmInvoke): one attempt of a transaction's body.
__ablaRuntimePlatformMutexBytes (fun)
@inline
trusted fun __ablaRuntimePlatformMutexBytes(): int
Bytes reserved for one pthread_mutex_t: 40 on Linux, 64 on Darwin. Every runtime mutex slot (the heap lock, Shared/Mutex control blocks) is sized from this; init/lock/unlock write the whole native struct. On x86-64 Linux the slot's first eight bytes are a futex word instead (__ablaRuntimeFutexLock).
__ablaRuntimeHostValgrind (fun)
@inline
trusted fun __ablaRuntimeHostValgrind(): bool
---- valgrind (#1217) ----------------------------------------------------------------------------------------------- A build for valgrind (ABLA_VALGRIND=1) tells memcheck about the heap, which it cannot see otherwise: the runtime takes its memory from the system, not from a malloc valgrind replaces. Each object is a malloc-like block from its allocation to its free (the payload; the header before it stays the allocator's), so a read or write of a freed object, or past an object's end, is reported where it happens. Any other build leaves every request out: the build swaps __ablaRuntimeHostValgrindOn's body into __ablaRuntimeHostValgrind (bootstrapValgrindParse), which is false here.
__ablaRuntimeHostValgrindOn (fun)
trusted fun __ablaRuntimeHostValgrindOn(): bool
What a build for valgrind makes __ablaRuntimeHostValgrind answer.
__ablaRuntimeHostValgrindRequest (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindRequest(request: int, first: int, second: int, third: int): int
Sends one client request with up to three arguments and returns valgrind's answer, 0 without valgrind.
__ablaRuntimeHostValgrindWords (fun)
@inline
trusted fun __ablaRuntimeHostValgrindWords(): int
The six words of a request, per thread (requests come from every thread that allocates).
__ablaRuntimeHostValgrindAllocated (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindAllocated(payload: int, size: int): void
Tells valgrind that size bytes at payload are an allocated object, their contents not yet written.
__ablaRuntimeHostValgrindFreed (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindFreed(payload: int): void
Tells valgrind that the object at payload is freed: any access to it from now on is reported.
__ablaRuntimeHostValgrindInternal (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindInternal(address: int, size: int, defined: bool): void
Tells valgrind that size bytes at address, the runtime's own memory (not an object), are addressable: written (defined, a calloc's zeroes or a realloc's copy) or not yet.
__ablaRuntimeHostValgrindHeapChunk (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindHeapChunk(address: int): void
Tells valgrind that the heap chunk at address, being returned to the runtime's heap, is the heap's again: the whole chunk with its own size word and the next chunk's, as a block's split, merge and free lists write them. A freed object's payload inside it stops being reported from here on; one kept on a small list (never returned) still is. The size word first (it may lie in a freed payload), then the extent it gives: a mapping of its own (bit 1, the length from 16 bytes before the address) or a chunk of the size classes.
__ablaRuntimeHostValgrindHeader (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindHeader(header: int, width: int): void
Tells valgrind that the width header bytes at header are the allocator's to write, wherever they lie.
__ablaRuntimeFutexExchange (fun)
trusted fun __ablaRuntimeFutexExchange(address: int, value: int): int
Atomically replaces the futex word and returns its previous value.
__ablaRuntimeFutexLock (fun)
trusted fun __ablaRuntimeFutexLock(address: int): void
A mutex of one word: 0 free, 1 held, 2 held and maybe waited for (Drepper, "Futexes Are Tricky", mutex 2). Not recursive, like the default pthread_mutex_t it replaces. The atomics are sequentially consistent, so lock acquires and unlock releases.
__ablaRuntimeFutexUnlock (fun)
trusted fun __ablaRuntimeFutexUnlock(address: int): void
Releases the futex mutex, waking a waiter if it was contested.
__ablaRuntimePlatformMutexInitialize (fun)
trusted fun __ablaRuntimePlatformMutexInitialize(address: int): void
Initializes a mutex in caller-provided storage, trapping if initialization fails.
__ablaRuntimePlatformMutexLock (fun)
trusted fun __ablaRuntimePlatformMutexLock(address: int): void
Acquires the runtime mutex and traps for an invalid address or host lock failure.
__ablaRuntimePlatformMutexLockBlocking (fun)
trusted fun __ablaRuntimePlatformMutexLockBlocking(address: int): void
A lock a user's code can hold across safe points (a Shared payload): a thread that waits for it waits in native state (stopped for a collection, its roots stable) and comes back through the stop's check. Not for the short locks the collector itself may take while it holds the stop.
__ablaRuntimePlatformMutexUnlock (fun)
trusted fun __ablaRuntimePlatformMutexUnlock(address: int): void
Releases the runtime mutex and traps if the host unlock fails.
__ablaRuntimePlatformMutexDestroy (fun)
trusted fun __ablaRuntimePlatformMutexDestroy(address: int): void
Destroys the runtime mutex and traps if the host reports failure.
__ablaRuntimeHostHeapClasses (val)
val __ablaRuntimeHostHeapClasses: int
--- the heap's allocator ----------------------------------------------------------------------- x86-64 Linux allocates without libc: blocks come from anonymous mappings (mmap, munmap, mremap and madvise as raw system calls). Every other host (macOS, AArch64 Linux) keeps libc's malloc family.
Blocks have glibc's geometry. A block starts at a 16-byte aligned payload p, is t bytes long (a multiple of 16, at least 32) and has a header word at p - 8: t, bit 0 "the block before this one is in use", bit 1 "a mapping of its own", and (small blocks) the block's size class in bits 40-47. The next block's payload is p + t, so its header is the last word of this block, which is why a block holds t - 8 bytes. A block that is truly free keeps two list links at p and p + 8 and its t in its last word before that header (the next block's "previous size", read only when bit 0 of the next block's header says the block before it is free). A block that is in use, or parked on a size class's list, has the bit set in the next header: freeing is a push on the list of its class and allocating a pop, nothing else.
Parked blocks are merged now and then (when allocation finds neither a parked block of its class nor a free block that fits, and a good amount is parked; or when a great deal is): each is joined to the free blocks around it, a merged block next to the unused tail of the current chunk goes back into the tail, a chunk that is entirely free is unmapped, a large merged block gives its pages back (madvise), and the rest wait in bins by size to serve any class, split. So a program that frees one kind of block and asks for another keeps its heap's size, which lists by class alone could not do.
Size classes: 16-byte steps to 1 KiB, then eight a doubling (1152, 1280, ... 2048, 2304, ...) to 128 KiB. Past that a request is a mapping of its own (16 bytes of header, rounded to pages): freeing it unmaps it, and realloc grows and shrinks it with mremap, which moves pages, not bytes. Small blocks are cut from 1 MiB chunks, the tail of the newest one (the "top") by a cursor.
One lock covers it all, taken only once a second thread can exist (an Abla thread or the background-free helper started): a program with one thread pays nothing for it. The lock is a futex word of its own (below), so the heap names no pthread function. State, one static block: +0 the 120 list heads of the parked blocks, +960 the 121 free-block bins (the last for blocks past 128 KiB), +1928 a bitmap of the bins with something in them (3 words), +1952 the lock word (and 56 spare bytes).
__ablaRuntimeHostHeapBins (val)
val __ablaRuntimeHostHeapBins: int
Gives the number of segregated free lists in the native heap.
__ablaRuntimeHostHeapSmallMaximum (val)
val __ablaRuntimeHostHeapSmallMaximum: int
Caps the payload size handled by the native heap's small bins.
__ablaRuntimeHostHeapChunk (val)
val __ablaRuntimeHostHeapChunk: int
Sets the ordinary byte size of native heap mappings.
__ablaRuntimeHostHeapSizeMask (val)
val __ablaRuntimeHostHeapSizeMask: int
Selects the size field of the packed heap block header.
__ablaRuntimeHostHeapCursor (var)
var __ablaRuntimeHostHeapCursor: int
Holds the next allocation address within the current heap span.
__ablaRuntimeHostHeapEnd (var)
var __ablaRuntimeHostHeapEnd: int
Holds the exclusive end of the current heap span.
__ablaRuntimeHostHeapClean (var)
var __ablaRuntimeHostHeapClean: int
The chunk's addresses from here up have never been written (a fresh block there is zero already).
__ablaRuntimeHostHeapShared (var)
var __ablaRuntimeHostHeapShared: bool
Indicates that the native heap is shared between threads.
__ablaRuntimeHostHeapTrimming (var)
var __ablaRuntimeHostHeapTrimming: bool
Set while __ablaRuntimeHostHeapTrim runs: nothing is kept.
__ablaRuntimeHostHeapParked (var)
var __ablaRuntimeHostHeapParked: int
Bytes of the blocks parked on the class lists, and of the chunks mapped.
__ablaRuntimeHostHeapMapped (var)
var __ablaRuntimeHostHeapMapped: int
Counts bytes mapped into the native heap.
__ablaRuntimeHostHeapBinned (var)
var __ablaRuntimeHostHeapBinned: int
Bytes of the free blocks in the bins.
__ablaRuntimeHostHeapTrigger (var)
var __ablaRuntimeHostHeapTrigger: int
The parked bytes at which a free merges them: four times __ablaRuntimeHostHeapMergeAt, kept here so that a free compares one word (set again whenever the chunks mapped change). It was twice: a collection's sweep parks much and the merge that followed was split again by the next allocations (compiler self-build 12.2 s -> 11.1 s of CPU, an editor edit loop 24.6 s -> 22.7 s, the resident peaks unchanged; an allocation that finds nothing to take still merges at __ablaRuntimeHostHeapMergeAt; with nothing freed that is later allocated, up to a quarter of the chunks can stay parked).
__ablaRuntimeHostHeapCached (var)
var __ablaRuntimeHostHeapCached: int
Bytes of the large mappings kept after their free (the cache of 16 slots at +2016), for the next large request.
__ablaRuntimeHostHeapCacheEach (val)
val __ablaRuntimeHostHeapCacheEach: int
Caps the byte size of one mapped block retained for reuse.
__ablaRuntimeHostHeapCacheTotal (val)
val __ablaRuntimeHostHeapCacheTotal: int
Caps the total bytes of mapped blocks retained for reuse.
__ablaRuntimeHostHeapNative (fun)
@inline
trusted fun __ablaRuntimeHostHeapNative(): bool
Whether this host's heap is the one below: x86-64 and AArch64 Linux, and macOS (not iOS) over its BSD system calls and ulock locks (#811) (a constant the backend folds, so the other hosts keep libc's functions and this target none).
__ablaRuntimeHostHeapState (fun)
@inline
trusted fun __ablaRuntimeHostHeapState(): int
Returns the address of the allocator's statically reserved state.
__ablaRuntimeHostHeapLockAddress (fun)
@inline
trusted fun __ablaRuntimeHostHeapLockAddress(): int
Returns the address of the allocator's internal futex word.
__ablaRuntimeHostHeapStat (fun)
trusted fun __ablaRuntimeHostHeapStat(which: int): int
What the heap holds, for tests and diagnostics: 0 the bytes of chunks mapped, 1 the bytes parked on the class lists.
__ablaRuntimeHostHeapClassBytes (fun)
@inline
trusted fun __ablaRuntimeHostHeapClassBytes(sizeClass: int): int
Bytes of a size class's block, the next block's header word included.
__ablaRuntimeHostHeapClassOf (fun)
@inline
trusted fun __ablaRuntimeHostHeapClassOf(total: int): int
The smallest class whose block holds total bytes (32 to 131072).
__ablaRuntimeHostHeapClassBelow (fun)
trusted fun __ablaRuntimeHostHeapClassBelow(t: int): int
The largest class whose block fits in t bytes (t from 32 to 131072).
__ablaRuntimeHostHeapBinOf (fun)
@inline
trusted fun __ablaRuntimeHostHeapBinOf(t: int): int
The bin of a free block of t bytes.
__ablaRuntimeHostHeapExtent (fun)
trusted fun __ablaRuntimeHostHeapExtent(): int
Bounds of the mappings acquired by the native heap. Publish the bounds before returning a mapping and leave them wide after unmap, so recycled blocks and interior pointers are always covered.
__ablaRuntimeHostHeapTrackMapping (fun)
trusted fun __ablaRuntimeHostHeapTrackMapping(address: int, bytes: int): void
Atomically extends the tracked heap address bounds to include this mapping.
__ablaRuntimeHostMapFailErrno (var)
var __ablaRuntimeHostMapFailErrno: int
The last mapping the system refused, kept for the out-of-memory report (the errno, the bytes asked): a macOS heap that is refused memory says why instead of leaving a guess.
__ablaRuntimeHostMapFailBytes (var)
var __ablaRuntimeHostMapFailBytes: int
Records the requested byte count of the last failed native mapping.
__ablaRuntimeHostHeapMap (fun)
trusted fun __ablaRuntimeHostHeapMap(bytes: int): int
Anonymous zeroed pages, or 0.
__ablaRuntimeHostHeapUnmap (fun)
trusted fun __ablaRuntimeHostHeapUnmap(address: int, bytes: int): void
Asks the host to unmap the given page range.
__ablaRuntimeHostHeapRemapCopy (fun)
trusted fun __ablaRuntimeHostHeapRemapCopy(base: int, before: int, after: int): int
A mapping resized where there is no mremap: new pages, the smaller of the two lengths copied, the old pages unmapped. The new base, or a negative errno.
__ablaRuntimeHostHeapRemap (fun)
trusted fun __ablaRuntimeHostHeapRemap(base: int, before: int, after: int): int
A mapping resized to after bytes: MREMAP_MAYMOVE where there is mremap; macOS has none (a new mapping, the old bytes copied, the old one unmapped). The new base, or a negative errno.
__ablaRuntimeHostHeapCacheTake (fun)
trusted fun __ablaRuntimeHostHeapCacheTake(mapped: int): int
A cached mapping that holds mapped bytes (its base), or 0. The smallest that fits is taken. The lock is held.
__ablaRuntimeHostHeapCachePut (fun)
trusted fun __ablaRuntimeHostHeapCachePut(base: int, length: int): bool
Keeps a freed mapping for the next request: in an empty slot, or in place of the smallest kept one when that is smaller (which is unmapped). False when it is not kept. The lock is held.
__ablaRuntimeHostForkCheck (fun)
@inline
trusted fun __ablaRuntimeHostForkCheck(): void
Repairs inherited runtime locks when the fork marker indicates a child process.
__ablaRuntimeHostHeapAcquire (fun)
@inline
trusted fun __ablaRuntimeHostHeapAcquire(): void
The heap's lock: a futex mutex of its own, one word in the static state (the same one the runtime's mutexes are, above), so that the heap needs no pthread function nor libc. The holder is never preempted for long, but a collection's merge can take a while: a waiter sleeps.
__ablaRuntimeHostHeapLetGo (fun)
@inline
trusted fun __ablaRuntimeHostHeapLetGo(): void
Releases the allocator's internal futex lock.
__ablaRuntimeHostHeapZero (fun)
trusted fun __ablaRuntimeHostHeapZero(address: int, size: int): void
Zeroes size bytes at a block's payload, by whole words (a block holds a multiple of 8 bytes). Written out, not memset: a --fast build lowers a memset to the C library's.
__ablaRuntimeHostHeapPoison (fun)
trusted fun __ablaRuntimeHostHeapPoison(address: int, size: int): void
Under ABLA_GC_STRESS=1 or ABLA_GC_POISON=1 the sweep fills each block it frees with 0xDB bytes first, so a use after free reads garbage at once, not the old bytes a block keeps until it is reused (a C string, a path: #829). A build for valgrind fills nothing: valgrind reports the use itself, and the whole words reach past an object whose size is not a multiple of 8, which it reports as writes outside the object.
__ablaRuntimeHostForkPage (var)
var __ablaRuntimeHostForkPage: int
A fork leaves only the forking thread in the child, so a lock another thread held stays held for ever (#812). No fork hook is needed, and no system call on the allocation path: one page of its own holds a 1, and MADV_WIPEONFORK (Linux 4.14) makes the kernel zero it in the child. The first lock the child takes looks at that word, finds a 0, and repairs what the vanished threads may have left (below). Without the advice (an older kernel) the word is never wiped and a fork with a lock held is not detected.
__ablaRuntimeHostHeapNoMerge (var)
var __ablaRuntimeHostHeapNoMerge: bool
Set in a child that found the heap's lock held: nothing parked or merged before the fork is trusted, so no merge ever consults a block's header from before it (a free block's links may be half written).
__ablaRuntimeHostForkNoCollect (var)
var __ablaRuntimeHostForkNoCollect: bool
Set in a child that found the runtime mutex or the heap lock held: a thread that did not survive may have been in the middle of registering an allocation, so the collector never walks the registry in that child.
__ablaRuntimeHostForkArm (fun)
trusted fun __ablaRuntimeHostForkArm(): void
Attempts to install the memory marker that identifies a Linux child after fork.
__ablaRuntimeHostForkRepair (fun)
@noinline
trusted fun __ablaRuntimeHostForkRepair(): void
In the child, by the first thread to take a runtime lock. Nothing else runs, so nothing here is locked.
__ablaRuntimeHostHeapShare (fun)
trusted fun __ablaRuntimeHostHeapShare(): void
From now on the heap is locked (once a second thread can touch it).
__ablaRuntimeHostHeapBinInsert (fun)
trusted fun __ablaRuntimeHostHeapBinInsert(block: int, t: int): void
A free block at block, t bytes, into its bin (links, bitmap bit).
__ablaRuntimeHostHeapBinRemove (fun)
trusted fun __ablaRuntimeHostHeapBinRemove(block: int): void
A free block out of its bin.
__ablaRuntimeHostHeapBinFrom (fun)
trusted fun __ablaRuntimeHostHeapBinFrom(first: int): int
The first bin from first up that holds a block, or -1.
__ablaRuntimeHostHeapFromBins (fun)
trusted fun __ablaRuntimeHostHeapFromBins(sizeClass: int, t: int): int
A block of at least t bytes (the class's size) out of the bins, split when much is left over, its header made that of a block in use; 0 when none fits.
__ablaRuntimeHostHeapKeep (fun)
@inline
trusted fun __ablaRuntimeHostHeapKeep(): int
How much free memory the bins keep before whole chunks and large blocks are given back to the system: a program that frees much and allocates again (a collector's cycle) would otherwise pay the system for the same pages every time.
__ablaRuntimeHostHeapRelease (fun)
trusted fun __ablaRuntimeHostHeapRelease(start: int, end: int): void
A merged free block [start, end) goes back: into the top, unmapped (a whole chunk), or into a bin.
__ablaRuntimeHostHeapMerge (fun)
trusted fun __ablaRuntimeHostHeapMerge(block: int): void
One parked block, block, truly free now: merged with a free block before it and one after it.
__ablaRuntimeHostHeapPage (var)
var __ablaRuntimeHostHeapPage: int
The host's page size: 16 KiB on macOS (Apple Silicon's; Intel's 4 KiB pages are also covered by it), on Linux the auxiliary vector's AT_PAGESZ (6), which follows the environment vector's NULL (4 KiB on x86-64, 4, 16 or 64 KiB on AArch64; read only where the program owns its start, so the vector is where the environment ends). Elsewhere the largest, 64 KiB: rounding inward to more than the page only gives back less. Kept after the first call.
__ablaRuntimeHostHeapPageSize (fun)
trusted fun __ablaRuntimeHostHeapPageSize(): int
Returns the host allocator's page size in bytes.
__ablaRuntimeHostHeapDiscard (fun)
trusted fun __ablaRuntimeHostHeapDiscard(from: int, to: int): void
Gives back the whole pages inside [from, to): rounded inward to the host's page (16 KiB on Apple Silicon). Darwin's madvise rounds the start down and the end up to its page, so a range only 4 KiB aligned would also discard the live data around it (the free block's own header and links, the block before it): the intermittent heap corruption behind the arm64 macOS compiler hangs of v0.2.59.
__ablaRuntimeHostHeapGiveBack (fun)
@noinline
trusted fun __ablaRuntimeHostHeapGiveBack(): void
The large free blocks (bin 120) give their pages back, keeping each one's header, links and footer, all but the first ones (the newest, the likeliest to be wanted next) that make up what the bins are meant to keep.
__ablaRuntimeHostHeapConsolidate (fun)
@noinline
trusted fun __ablaRuntimeHostHeapConsolidate(): void
Merges every parked block.
__ablaRuntimeHostHeapSetTrigger (fun)
trusted fun __ablaRuntimeHostHeapSetTrigger(): void
Updates the native allocator's reclaim threshold from its current state.
__ablaRuntimeHostHeapMergeAt (fun)
@inline
trusted fun __ablaRuntimeHostHeapMergeAt(): int
How much parked memory is worth a merge when allocation has nothing else: a sixteenth of the chunks, at least 4 MiB.
__ablaRuntimeHostHeapRefill (fun)
@noinline
trusted fun __ablaRuntimeHostHeapRefill(): bool
The unused tail of the newest chunk becomes a free block and a new chunk is the top. False when the system has no more.
__ablaRuntimeHostHeapBump (fun)
trusted fun __ablaRuntimeHostHeapBump(sizeClass: int, t: int): int
A block of t bytes cut from the top; 0 when the system has no more memory. Its address is above the clean mark when no one has ever written there.
__ablaRuntimeHostHeapAllocate (fun)
trusted fun __ablaRuntimeHostHeapAllocate(size: int, zero: bool): int
A block of size bytes, or 0. zero: its first size bytes are zero.
__ablaRuntimeHostHeapFreeLocked (fun)
trusted fun __ablaRuntimeHostHeapFreeLocked(address: int): void
Free with the heap's lock held by the caller (a batch of frees takes it once): the body of __ablaRuntimeHostHeapFree.
__ablaRuntimeHostHeapFree (fun)
trusted fun __ablaRuntimeHostHeapFree(address: int): void
Returns an allocation to the native heap or unmaps it as appropriate.
__ablaRuntimeHostHeapResize (fun)
trusted fun __ablaRuntimeHostHeapResize(address: int, size: int): int
The block resized to size bytes, its contents kept up to the smaller size; 0 (the old block untouched) when memory is short.
__ablaRuntimeHostMalloc (fun)
@inline
trusted fun __ablaRuntimeHostMalloc(size: int): i64*
Returns an uninitialized native allocation or null on failure.
__ablaRuntimeHostMallocPlain (fun)
@inline
trusted fun __ablaRuntimeHostMallocPlain(size: int): i64*
The host allocation itself: the runtime's own heap, or the C library's where the host has one.
__ablaRuntimeHostValgrindMalloc (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindMalloc(size: int): i64*
A build for valgrind's allocation: the runtime's heap hands out memory a freed object had (valgrind still holds it freed), which is the runtime's now.
__ablaRuntimePlatformMemoryRelease (fun)
trusted fun __ablaRuntimePlatformMemoryRelease(): void
The platform's release of free memory to the system (runtimeMemoryRelease): this heap's Trim. Other hosts have libc's allocator, which a caller trims with malloc_trim itself (the compiler does).
__ablaRuntimeHostHeapTrim (fun)
@noinline
trusted fun __ablaRuntimeHostHeapTrim(): void
Gives everything back that can go: parked blocks merged, whole free chunks and the cached large mappings unmapped, the pages of the remaining large free blocks released. (malloc_trim for this heap.)
__ablaRuntimeHostHeapVerify (fun)
trusted fun __ablaRuntimeHostHeapVerify(): int
Checks the lists and bins against each other and against the boundary tags (for tests): 0 when they agree, else the number of the check that failed. Nothing may allocate or free meanwhile.
__ablaRuntimeHostHeapCallocate (fun)
trusted fun __ablaRuntimeHostHeapCallocate(count: int, size: int): i64*
Returns a zeroed native allocation or null if the size overflows or allocation fails.
__ablaRuntimeHostCalloc (fun)
trusted fun __ablaRuntimeHostCalloc(count: int, size: int): i64*
The libc functions are named only behind a test of the host that the backend folds to a constant, nested as in these four (a test through __ablaRuntimeHostHeapNative() is not folded, and a --fast build would keep the imports): an x86-64 Linux program then names none of them, release or --fast.
__ablaRuntimeHostCallocPlain (fun)
@inline
trusted fun __ablaRuntimeHostCallocPlain(count: int, size: int): i64*
The host's zeroed allocation itself.
__ablaRuntimeHostValgrindCalloc (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindCalloc(count: int, size: int): i64*
A build for valgrind's zeroed allocation: written (zeroes), and the runtime's.
__ablaRuntimeHostRealloc (fun)
trusted fun __ablaRuntimeHostRealloc(pointer: i64*, size: int): i64*
Resizes an existing native allocation and returns its possibly moved address or null on failure.
__ablaRuntimeHostReallocPlain (fun)
@inline
trusted fun __ablaRuntimeHostReallocPlain(pointer: i64*, size: int): i64*
The host's resize itself.
__ablaRuntimeHostValgrindRealloc (fun)
@noinline
trusted fun __ablaRuntimeHostValgrindRealloc(pointer: i64*, size: int): i64*
A build for valgrind's resize: written (what it holds was copied from the old block), and the runtime's.
__ablaRuntimeHostFree (fun)
@inline
trusted fun __ablaRuntimeHostFree(pointer: i64*): void
Releases a pointer allocated from the runtime's native heap or the selected host allocator.
__ablaRuntimeHostSignalStackBytes (val)
val __ablaRuntimeHostSignalStackBytes
A thread's own alternate signal stack, for a thread that has none: a stack overflow's SIGSEGV has no room on the overflowed stack, so without one the kernel ends the whole process before any handler runs. The main thread's is the stack guard's (debug.ab), and an x86-64 Linux libc-free thread gets one from abla_clone_create; a libpthread thread (a hosted program, or a # site's thread inside the compiler, #831) has none. Enter installs 64 KiB and returns it (0 when the thread had one, or the host has no such call); Leave, before the thread ends, takes it down and frees it. sigaltstack is 131 on x86-64 Linux (and in an AArch64 build whose system calls are translated), 132 on AArch64, 53 on Darwin, whose stack_t has its flags after the size (and SS_DISABLE 4, not 2). The signal stack is a mapping of its own (mmap and munmap by system call, as the heap maps its large blocks), and the stack_t each call passes lives in its first bytes: the kernel copies a stack_t when sigaltstack is called, so it may sit in the stack it describes. Enter and Leave take nothing from the heap, so they read none of the thread's thread-locals (the heap's, the emulated ones): where they run relative to the thread-end hook doesn't matter.
__ablaRuntimePlatformThreadSignalStackEnter (fun)
trusted fun __ablaRuntimePlatformThreadSignalStackEnter(): int
Installs a signal stack for the current thread and returns its token or zero if unavailable.
__ablaRuntimePlatformThreadSignalStackLeave (fun)
trusted fun __ablaRuntimePlatformThreadSignalStackLeave(stack: int): void
Removes the thread signal stack represented by the token.
__ablaRuntimeHostHeapMutex (var)
var __ablaRuntimeHostHeapMutex: int
The tracked heap stays lock-free until a program actually starts an Abla thread. Thread creation happens before the worker can run, so this one-time transition does not add a synchronization branch to initialization.
__ablaRuntimeHostActiveThreads (var)
var __ablaRuntimeHostActiveThreads: int
Counts started threads that still need to be joined.
__ablaRuntimePlatformThreadsEnable (fun)
trusted fun __ablaRuntimePlatformThreadsEnable(): void
Enables runtime synchronization for multithreaded execution.
__ablaRuntimeHostThreadsShare (fun)
trusted fun __ablaRuntimeHostThreadsShare(): void
Marks the allocator as shared and prepares it for competing threads.
__ablaRuntimeHostExportInside (fun)
trusted fun __ablaRuntimeHostExportInside(): int
How many threads are inside the library's exports now (0 in a program that has none).
__ablaRuntimeExportEnter (fun)
trusted fun __ablaRuntimeExportEnter(): int
Enters a runtime call from outside and returns zero.
__ablaRuntimeExportLeave (fun)
trusted fun __ablaRuntimeExportLeave(): int
Leaves a runtime call made from outside and returns zero.
__ablaRuntimeLiveEnter (fun)
trusted fun __ablaRuntimeLiveEnter(): int
ablac run --live: a reload's new variables are initialized by a thread that may not be the program's (the --watch thread) or that is inside the compiler's reload (native code): it enters as an export's caller does (src/backend/llvm/live_globals.ab). Plain runtime functions: the export bridges exist only in a library.
__ablaRuntimeLiveLeave (fun)
trusted fun __ablaRuntimeLiveLeave(): int
Leaves a live JIT runtime call and returns zero.
__ablaRuntimeExportInitBegin (fun)
trusted fun __ablaRuntimeExportInitBegin(): int
1 when the caller is to initialize the globals, 0 when they are initialized or the caller is the thread doing it.
__ablaRuntimeExportInitEnd (fun)
trusted fun __ablaRuntimeExportInitEnd(): int
Completes exported-global initialization and returns zero.
__ablaRuntimeHostGcTrace (var)
var __ablaRuntimeHostGcTrace: bool
Controls host collector tracing.
__ablaRuntimeHostGcTraceConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcTraceConfigured(): bool
Returns whether the startup environment enables collector tracing.
__ablaRuntimePlatformThreadRegister (fun)
trusted fun __ablaRuntimePlatformThreadRegister(): void
The thread joins the registry; nested registrations (an export called from an export) count.
__ablaRuntimePlatformThreadUnregister (fun)
trusted fun __ablaRuntimePlatformThreadUnregister(): void
The outermost leave: the record leaves the registry. Frames still on the thread's chain are permanent (the static frame of an export's globals, never popped): they move to the registry's own chain, which every collection marks.
__ablaRuntimePlatformNativeEnter (fun)
trusted fun __ablaRuntimePlatformNativeEnter(): void
In native code that blocks (a join) the thread counts as parked: its chain is stable. Coming back it waits out a stop that claimed it.
__ablaRuntimePlatformNativeLeaveIfIn (fun)
trusted fun __ablaRuntimePlatformNativeLeaveIfIn(): bool
Leaves native code only when the thread is in it: true when it was, and the caller enters it again before going back (a compiler export a JIT-compiled program calls from a thread the compiler marked native, runtimeNativeLeave).
__ablaRuntimePlatformNativeLeave (fun)
trusted fun __ablaRuntimePlatformNativeLeave(): void
Returns the calling thread from a native boundary to runtime-managed execution.
__ablaRuntimeHostStwStop (fun)
@noinline
trusted fun __ablaRuntimeHostStwStop(): int
0: the thread was parked for another's collection, or the stop was abandoned, or it may not collect: it does not collect. 1: every other thread is parked, the registry stays locked until __ablaRuntimeHostStwRelease. 2: no other thread can exist (the runtime never shared), no stop is needed.
__ablaRuntimeHostStwRelease (fun)
trusted fun __ablaRuntimeHostStwRelease(restore: bool): void
The collecting thread lets the others go (its registry lock too). restore: the threshold the stop found goes back (a collection that sets its own threshold afterwards passes false).
__ablaRuntimeHostStwDone (fun)
@inline
trusted fun __ablaRuntimeHostStwDone(stopped: int): void
The end of a collection that Stop let run: the pressure collection keeps the stop until it has set its threshold.
__ablaRuntimeHostStwPressureBegin (fun)
trusted fun __ablaRuntimeHostStwPressureBegin(): void
What a pressure collection tells the stop: it keeps the stop (1), and whether it parked for another's (read back).
__ablaRuntimeHostStwPressureEnd (fun)
trusted fun __ablaRuntimeHostStwPressureEnd(): bool
True when the thread parked for another's collection, which sets the threshold itself.
__ablaRuntimePlatformMemoryDebugHold (fun)
trusted fun __ablaRuntimePlatformMemoryDebugHold(mode: int): int
The test hook (memoryDebugHold): the word at +136 of the stop's block is 0 (off), 1 (armed) or 2 (a thread holds).
__ablaRuntimeHostStwStat (fun)
trusted fun __ablaRuntimeHostStwStat(which: int): int
Stops abandoned and collections that stopped threads (memoryHeapStat 8 and 7).
__ablaRuntimeHostStwForkReset (fun)
trusted fun __ablaRuntimeHostStwForkReset(): void
In a forked child only the forking thread exists: the registry is that thread's record alone, no stop under way.
__ablaRuntimePlatformUnalignedWords (fun)
@inline
trusted fun __ablaRuntimePlatformUnalignedWords(): bool
Whether a thread was ever started: shared runtime structures (a rope's flat copy) publish with fences from then on. Set before the first worker runs. Whether 4- and 8-byte loads at any address are fine: user-mode x86-64 and AArch64 (Linux, macOS, iOS, Android); not Xtensa, and a freestanding AArch64 with device memory would need its own answer.
__ablaRuntimePlatformThreadsEnabled (fun)
@inline
trusted fun __ablaRuntimePlatformThreadsEnabled(): bool
Returns whether runtime heap synchronization is enabled.
__ablaRuntimeHostHeapLock (fun)
@inline
trusted fun __ablaRuntimeHostHeapLock(): int
Acquires the runtime heap mutex if enabled and returns its address or zero.
__ablaRuntimeHostHeapUnlock (fun)
@inline
trusted fun __ablaRuntimeHostHeapUnlock(mutex: int): void
Releases the heap mutex represented by a nonzero token.
__ablaRuntimePlatformThreadCreate (fun)
trusted fun __ablaRuntimePlatformThreadCreate(
handle: int,
entry: int,
argument: int
): bool
Starts a thread and records the handle, returning false and rolling back tracking if creation fails.
__ablaRuntimePlatformThreadJoin (fun)
trusted fun __ablaRuntimePlatformThreadJoin(handle: int): bool
Waits for a tracked thread and returns whether it joined successfully.
__ablaRuntimePlatformConditionBytes (fun)
@inline
trusted fun __ablaRuntimePlatformConditionBytes(): int
Bytes reserved for one pthread_cond_t: 48 on Linux and Darwin.
__ablaRuntimePlatformConditionInitialize (fun)
trusted fun __ablaRuntimePlatformConditionInitialize(address: int): void
On x86-64 Linux a condition is a sequence word: a waiter reads it, unlocks and sleeps while it is unchanged; a broadcast advances it and wakes every sleeper. Spurious wakeups are allowed, as with pthread_cond_wait.
__ablaRuntimePlatformConditionWait (fun)
trusted fun __ablaRuntimePlatformConditionWait(condition: int, mutex: int): void
Releases the mutex while waiting, reacquires it on return and traps for a host error.
__ablaRuntimePlatformConditionBroadcast (fun)
trusted fun __ablaRuntimePlatformConditionBroadcast(condition: int): void
Wakes all condition waiters, trapping if the host operation fails.
__ablaRuntimePlatformRawAllocate (fun)
trusted fun __ablaRuntimePlatformRawAllocate(size: int): int
Zeroed memory the collector neither tracks nor frees.
__ablaRuntimePlatformRawFree (fun)
trusted fun __ablaRuntimePlatformRawFree(address: int): void
Releases a native buffer and charges the release to the pressure budget.
__ablaRuntimePlatformOnlyThread (fun)
@inline
trusted fun __ablaRuntimePlatformOnlyThread(): bool
No other thread runs: none can start except from this one.
__ablaRuntimeHostStmCell (fun)
@inline
trusted fun __ablaRuntimeHostStmCell(): int
The calling thread's transaction descriptor (0 before its first transaction).
__ablaRuntimePlatformStmDescriptor (fun)
@inline
trusted fun __ablaRuntimePlatformStmDescriptor(): int
Returns the calling thread's transaction descriptor or zero if unset.
__ablaRuntimePlatformStmSetDescriptor (fun)
trusted fun __ablaRuntimePlatformStmSetDescriptor(descriptor: int): void
Sets the transaction descriptor for the calling thread.
__ablaRuntimePlatformGlobalLock (fun)
@inline
trusted fun __ablaRuntimePlatformGlobalLock(): int
A lock over rare runtime-wide changes (the heap's own; held without allocating).
__ablaRuntimePlatformGlobalUnlock (fun)
@inline
trusted fun __ablaRuntimePlatformGlobalUnlock(lock: int): void
Releases the runtime heap mutex represented by the token.
__ablaRuntimePlatformRootBytes (fun)
@inline
trusted fun __ablaRuntimePlatformRootBytes(): int
A root frame's array holds 8-byte value addresses; this points a pushed frame at another array and count.
__ablaRuntimePlatformRootStore (fun)
@inline
trusted fun __ablaRuntimePlatformRootStore(roots: int, index: int, value: int): void
Writes a native value address into a root list slot.
__ablaRuntimePlatformRootsSet (fun)
@inline
trusted fun __ablaRuntimePlatformRootsSet(frame: int, roots: int, count: int): void
Updates a root frame's value-address array and count.
__ablaRuntimePlatformAttempt (fun)
trusted fun __ablaRuntimePlatformAttempt(closure: int, output: int, slot: int): bool
One attempt of a transaction's body, the closure at closure, its result to output. True when the attempt was abandoned (__ablaRuntimePlatformAbandon).
__ablaRuntimePlatformAbandon (fun)
trusted fun __ablaRuntimePlatformAbandon(slot: int): never
Leaves the attempt whose jmp_buf slot holds, from any depth of its body.
__ablaRuntimePlatformUnwindSave (fun)
trusted fun __ablaRuntimePlatformUnwindSave(at: int): void
The thread's root frames and region, saved before an attempt and restored when it is abandoned: what its body pushed is left with its stack.
__ablaRuntimePlatformUnwindRestore (fun)
trusted fun __ablaRuntimePlatformUnwindRestore(at: int): void
Restores the calling thread's root frame chain and active region after an unwind.
__ablaRuntimeHostRegistry (var)
var __ablaRuntimeHostRegistry: int
Host allocations are registered in allocation order: an array of their headers, each header holding its slot (its first word). A freed allocation leaves an empty slot, which the next collection compacts away; trailing empty slots are dropped at once, so the last slot is always the latest allocation still held. Checkpoints are registry positions, so a region or compiler phase can release its complete allocation suffix in one bounded walk without involving the LLVM backend. A collection reads the registry in order instead of chasing links through the whole heap. An entry is the header's address, plus 1 for an allocation too large for the collection's page directory (header and payload past CollectionSmallBytes): the directory is built from the registry alone, without reading a header.
__ablaRuntimeHostRegistrySlots (var)
var __ablaRuntimeHostRegistrySlots: int
Counts occupied and vacant registry slots in use.
__ablaRuntimeHostRegistryCapacity (var)
var __ablaRuntimeHostRegistryCapacity: int
Holds the number of allocated registry slots.
__ablaRuntimeHostLiveBytes (var)
var __ablaRuntimeHostLiveBytes: int
Counts live tracked payload bytes.
__ablaRuntimeHostLimit (var)
var __ablaRuntimeHostLimit: int
Holds the configured tracked-memory limit in bytes.
__ablaRuntimeHostRegionCache (var)
var __ablaRuntimeHostRegionCache: int
Holds the free list of cached region descriptors.
__ablaRuntimeHostRegionCacheCount (var)
var __ablaRuntimeHostRegionCacheCount: int
Counts region descriptors held for reuse.
__ablaRuntimeHostRegionPageCache (var)
var __ablaRuntimeHostRegionPageCache: int
Holds the free list of cached region pages.
__ablaRuntimeHostRegionPageCacheCount (var)
var __ablaRuntimeHostRegionPageCacheCount: int
Counts region pages held for reuse.
__ablaRuntimeHostCollectionEnabled (var)
var __ablaRuntimeHostCollectionEnabled: bool
Hosted programs collect under allocation pressure from the start; only the functions the compiler made safe points (every allocating one, unless the program opted out with memorySetManualCollection) ever check this.
__ablaRuntimeHostGcFloor (val)
val __ablaRuntimeHostGcFloor: int
Sets the minimum adaptive post-collection growth budget in bytes.
__ablaRuntimeHostGcCap (val)
val __ablaRuntimeHostGcCap: int
Caps the adaptive post-collection growth budget in bytes.
__ablaRuntimeHostCollectionThreshold (var)
var __ablaRuntimeHostCollectionThreshold: int
A negative threshold compares the full pressure footprint. A positive one compares payload alone, so explicit pacing keeps its single hot comparison. Zero remains the stop-the-world and stress sentinel.
__ablaRuntimeHostCollectionGrowth (var)
var __ablaRuntimeHostCollectionGrowth: int
Zero selects adaptive pacing. An explicit growth setting uses the payload step that tuned callers (including the compiler) have always configured.
__ablaRuntimeHostNativePressure (fun)
@inline
trusted fun __ablaRuntimeHostNativePressure(): int
Raw allocations and native buffers freed between safepoints still represent allocation work. Clear their charge once a collection finishes. Tracked buffers still in use are already included in LiveBytes.
__ablaRuntimeHostTrackedPressure (fun)
@inline
trusted fun __ablaRuntimeHostTrackedPressure(): int
Returns live tracked payload bytes plus estimated registry overhead.
__ablaRuntimeHostGrowthEstimate (var)
var __ablaRuntimeHostGrowthEstimate: int
The smoothed working-set estimate for the next adaptive growth budget.
__ablaRuntimeHostCollectionKept (var)
var __ablaRuntimeHostCollectionKept: int
The live bytes the last collection kept (memoryHeapStat(13)); 0 before the first.
__ablaRuntimeHostCollections (var)
var __ablaRuntimeHostCollections: int
Foreground collections finished, serial or parallel (memoryHeapStat(14)).
__ablaRuntimeHostGcStress (var)
var __ablaRuntimeHostGcStress: bool
ABLA_GC_STRESS=1 (read once, at startup): every safe point collects, which makes a missing root fail at once. Set here, it zeroes the threshold; the safe point's check is the same compare either way.
__ablaRuntimeHostGcPoison (var)
var __ablaRuntimeHostGcPoison: bool
ABLA_GC_POISON=1 (read once, at startup): the sweeps poison what they free, as under stress, while collections come no more often than usual (docs/debugging.md). Stress poisons either way.
__ablaRuntimeHostCollectionCount (var)
var __ablaRuntimeHostCollectionCount: int
Counts registry slots considered by the current collection.
__ablaRuntimeHostCollected (var)
var __ablaRuntimeHostCollected: bool
Whether a collection has run (memorySetCollectionGrowth moves the first one only).
__ablaRuntimeHostCollectionMinimum (var)
var __ablaRuntimeHostCollectionMinimum: int
Holds the lower address bound of allocations considered by the collection.
__ablaRuntimeHostCollectionMaximum (var)
var __ablaRuntimeHostCollectionMaximum: int
Holds the upper address bound of allocations considered by the collection.
__ablaRuntimeHostCollectionWorklist (var)
var __ablaRuntimeHostCollectionWorklist: int
Holds the serial mark worklist address.
__ablaRuntimeHostCollectionWorklistCount (var)
var __ablaRuntimeHostCollectionWorklistCount: int
Counts pending payload addresses in the serial mark worklist.
__ablaRuntimeHostCollectionRanges (var)
var __ablaRuntimeHostCollectionRanges: int
For each 64 KiB page holding the start of a small allocation's payload, the directory has a bitmap with one bit per 16 bytes. Page entries hold the page number plus one and its bitmap. The allocation behind a pointer is a probe and a scan back through at most two pages' bitmaps; no allocation needs sorting. The larger allocations, few, are kept apart in address order (Ranges, LargeCount).
__ablaRuntimeHostCollectionLargeCount (var)
var __ablaRuntimeHostCollectionLargeCount: int
Counts the large allocation ranges used for interior-pointer lookup.
__ablaRuntimeHostCollectionPages (var)
var __ablaRuntimeHostCollectionPages: int
Holds the address of the collector's page directory.
__ablaRuntimeHostCollectionPageMask (var)
var __ablaRuntimeHostCollectionPageMask: int
Masks a page key to its initial index in the collector's page table.
__ablaRuntimeHostCollectionBitmaps (var)
var __ablaRuntimeHostCollectionBitmaps: int
Holds the base address of the collection's page bitmaps.
__ablaRuntimeHostCollectionMode (var)
var __ablaRuntimeHostCollectionMode: int
A foreground collection first tries to find each candidate's allocation from the registry alone (CollectionMode 1; see __ablaRuntimeHostMarkPointer) and builds the page directory only when a candidate is not a payload's start. The registry's lookup reads the word before the candidate, which is safe only in memory the process has mapped: Mapped holds the readable and writable ranges (start, end) of /proc/self/maps for the collection. NeedsDirectory remembers that a directory was needed. 0: the directory answers; 1: lazy; 2: the directory answers and the registry's answer is checked against it (ABLA_GC_STRESS=1).
__ablaRuntimeHostCollectionNeedsDirectory (var)
var __ablaRuntimeHostCollectionNeedsDirectory: bool
Indicates whether the current collection must use a page directory.
__ablaRuntimeHostCollectionDirectoryReason (var)
var __ablaRuntimeHostCollectionDirectoryReason: int
Trace reason for the directory in the current foreground collection. 0: none, 1: stress, 2: forced, 3: recent fallback, 4: mappings unavailable, 5: registry outside mappings, 6: pointer lookup miss, 7: raw-word scan.
__ablaRuntimeHostCollectionReadingRoots (var)
var __ablaRuntimeHostCollectionReadingRoots: bool
A miss can be a root or a field, and may name no tracked allocation at all.
__ablaRuntimeHostCollectionMapped (var)
var __ablaRuntimeHostCollectionMapped: int
Holds the table of readable and writable host address ranges.
__ablaRuntimeHostCollectionMappedCount (var)
var __ablaRuntimeHostCollectionMappedCount: int
Counts mapping ranges available to the current collection.
__ablaRuntimeHostCollectionMappedLast (var)
var __ablaRuntimeHostCollectionMappedLast: int
Holds the most recent mapping index used for collection lookup.
__ablaRuntimeHostCollectionMappedBuffer (var)
var __ablaRuntimeHostCollectionMappedBuffer: int
Holds the temporary buffer used to read the mapped address ranges.
__ablaRuntimeHostCollectionDirectorySkips (var)
var __ablaRuntimeHostCollectionDirectorySkips: int
Collections since the directory was last needed (see NeedsDirectory); every 16th tries the lazy lookup again.
__ablaRuntimeHostCollectionLazyCount (var)
var __ablaRuntimeHostCollectionLazyCount: int
Collections that found every candidate from the registry, and ones that built the directory (memoryHeapStat 5 and 6).
__ablaRuntimeHostCollectionDirectoryCount (var)
var __ablaRuntimeHostCollectionDirectoryCount: int
Counts collections that built a page directory.
__ablaRuntimeHostCollectionForce (var)
var __ablaRuntimeHostCollectionForce: int
ABLA_GC_LOOKUP forces a fallback, for the tests: 1 "directory" never looks up from the registry, 2 "nomaps" behaves as if /proc/self/maps were unreadable, 3 "untagged" as if the registry's headers were outside the mapped ranges (tagged pointers), 4 "openfail" and 5 "readfail" make the real system call fail. 0 otherwise.
__ablaRuntimeHostGcWorkers (var)
var __ablaRuntimeHostGcWorkers: int
ABLA_GC_WORKERS=n (2 to 8): the mark of a collection runs on n threads (the parallel mark, below); unset, 0 or 1 is the serial mark.
__ablaRuntimeHostGcWorkersConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcWorkersConfigured(): int
Returns the parallel collection worker count selected by the startup environment.
__ablaRuntimeHostCollectionSmallBytes (val)
val __ablaRuntimeHostCollectionSmallBytes: int
Sets the byte cutoff for the collector's small-allocation lookup.
__ablaRuntimeHostRegionCachedDescriptors (val)
val __ablaRuntimeHostRegionCachedDescriptors: int
Caps the number of cached descriptors.
__ablaRuntimeHostRegionPageBytes (val)
val __ablaRuntimeHostRegionPageBytes: int
Sets the normal allocation-region page size in bytes.
__ablaRuntimeHostRegionCachedPages (val)
val __ablaRuntimeHostRegionCachedPages: int
Caps the number of cached region pages.
__ablaRuntimeHostRootFrameAddress (fun)
@inline
trusted fun __ablaRuntimeHostRootFrameAddress(): int
Stack roots form a strict LIFO within one native thread. Sharing the head between workers lets their push/pop sequences interleave and makes a valid pop look corrupt. Resolve this address at each use so LLVM's local-exec TLS model selects the calling thread's independent head cell. The thread's region follows it, then its innermost recovery frame (a checked export's).
__ablaRuntimeHostRootFrameLoad (fun)
@inline
trusted fun __ablaRuntimeHostRootFrameLoad(): int
Returns the current thread's root frame chain head.
__ablaRuntimeHostRootFrameStore (fun)
@inline
trusted fun __ablaRuntimeHostRootFrameStore(frame: int): void
Sets the current thread's root frame chain head.
__ablaRuntimeHostRegionAddress (fun)
@inline
trusted fun __ablaRuntimeHostRegionAddress(): int
Returns the address of the calling thread's allocation-region slot.
__ablaRuntimeHostRegionLoad (fun)
@inline
trusted fun __ablaRuntimeHostRegionLoad(): int
Returns the current thread's active region descriptor or zero outside a region.
__ablaRuntimeHostRegionStore (fun)
@inline
trusted fun __ablaRuntimeHostRegionStore(regionAddress: int): void
Sets the current thread's active region descriptor.
__ablaRuntimeHostRecoveryAddress (fun)
@inline
trusted fun __ablaRuntimeHostRecoveryAddress(): int
Returns the address of the calling thread's recovery-state slot.
__ablaRuntimeRecoveryEnter (fun)
trusted fun __ablaRuntimeRecoveryEnter(
frame: int,
errorData: int,
errorCapacity: int,
errorLength: int
): int
A checked export's call runs under a recovery frame: a panic inside it copies its message to the caller's buffer and resumes the export at its setjmp instead of ending the program. The frame, on the export's stack: 0 the enclosing frame 8 the root frame head 16 the region 24 the message buffer 32 its capacity 40 where the length goes 48 the jmp_buf (the backend's abla_checked_invoke sizes it).
__ablaRuntimeRecoveryLeave (fun)
trusted fun __ablaRuntimeRecoveryLeave(frame: int): int
The call returned: its frame is no longer the innermost.
__ablaRuntimeRecoveryRestore (fun)
trusted fun __ablaRuntimeRecoveryRestore(frame: int): int
The call panicked: the root frames and the region it entered are abandoned with its stack (their memory is not reclaimed), so the thread's state is the frame's again, and a transaction it was in is rolled back.
__ablaRuntimeHostRegistryLast (fun)
@inline
trusted fun __ablaRuntimeHostRegistryLast(): int
The latest registered payload address, or 0.
__ablaRuntimeHostRegistryGrow (fun)
@noinline
trusted fun __ablaRuntimeHostRegistryGrow(): void
Out of line: it runs once per doubling, and inlined it made every allocation's path too large to inline where it used to be.
__ablaRuntimeHostSmallClassHeaderWidth (var)
var __ablaRuntimeHostSmallClassHeaderWidth: int
Both tracked formats end with the exact size and the packed registry slot/state. The state takes the low six bits (0..47), leaving 58 bits for the reverse slot. The registry names payload starts. Its bit 0 marks a large block, bit 1 is the parallel sweep's garbage tag, and bit 2 marks a compact native block. A region has no registry slot: state 63 names its owner at payload - 24. The native header width for small class allocations, or zero before configuration.
__ablaRuntimeHostEntryWidth (fun)
@inline
trusted fun __ablaRuntimeHostEntryWidth(entry: int): int
Returns the native header size of a registry entry, even if its garbage bit is set.
__ablaRuntimeHostWriteHeader (fun)
@inline
trusted fun __ablaRuntimeHostWriteHeader(payload: int, size: int, layout: int, slot: int, flags: int): void
Publishes a tracked payload and initializes its size and slot/state words.
__ablaRuntimeHostRegister (fun)
trusted fun __ablaRuntimeHostRegister(payload: int, size: int, layout: int, width: int): void
Registers a tracked payload with its native block format.
__ablaRuntimeHostUnregister (fun)
trusted fun __ablaRuntimeHostUnregister(slot: int): int
Clears a slot and returns its old entry, shrinking the registry tail when possible.
__ablaRuntimeHostCollectionRangeSwap (fun)
@inline
trusted fun __ablaRuntimeHostCollectionRangeSwap(
left: int,
right: int
): void
Swaps two allocation ranges in the collector's range table.
__ablaRuntimeHostCollectionRangeSift (fun)
@noinline
trusted fun __ablaRuntimeHostCollectionRangeSift(
rootIndex: int,
count: int
): void
Pointer integers retain the allocator's top-byte tag (including when freed). Order their complete bit patterns unsigned, and derive unsigned page ordinals; a tagged Android allocation need not be positive as an Abla int. Heap sort gives the conservative marker an address-ordered allocation index without another allocation or recursion. Interior string/array pointers can then be resolved in logarithmic time instead of walking every live allocation. This is especially important for long-running servers: request garbage intentionally accumulates between bounded collections. Share the sift between heap construction and extraction.
__ablaRuntimeHostCollectionRangesHeapSort (fun)
trusted fun __ablaRuntimeHostCollectionRangesHeapSort(count: int): void
Sorts allocation ranges by address for interior-pointer lookup.
__ablaRuntimeHostRegionPageAcquire (fun)
@noinline
trusted fun __ablaRuntimeHostRegionPageAcquire(minimum: int): int
Region pages are ordinary native allocations with a 32-byte control header: next, capacity, used, and reserved. Request-local objects are bump-allocated after that header and reclaimed together when their region ends. Page acquisition is rare; keep malloc and cache handling out of the register footprint of each successful bump allocation.
__ablaRuntimeHostRegionPagesRelease (fun)
trusted fun __ablaRuntimeHostRegionPagesRelease(pageAddress: int): void
Releases the page chain into the cache or the native allocator.
__ablaRuntimeHostRegionAllocate (fun)
trusted fun __ablaRuntimeHostRegionAllocate(size: int): int
Returns a new payload address in the active region, obtaining a page when needed.
__ablaRuntimeHostSmallBytes (var)
var __ablaRuntimeHostSmallBytes: int
Blocks of up to 512 bytes, header included, go on a list by size when freed (8 bytes apart, as malloc was asked for them), and the next allocation of that size takes one: under a collector every block is freed once, and a malloc and a free each cost more than the object's first use. The lists hold at most 128 MB between them (memorySetFreeBlockLimit changes it; the compiler keeps 32 MB); past that a block goes back to malloc. Blocks on a list serve only their size, so what they hold is lost to everything else: cut from chunks and kept for good, they took an Xtensa build of abla-embedded's package-import from 3.04 GB to 3.74 GB at its peak (2026-11-02). Within the limit they keep what they serve (__ablaRuntimeHostSmallListsSettle). They are taken and given back under the heap lock. A block's first word links it while free.
__ablaRuntimeHostSmallLimit (var)
var __ablaRuntimeHostSmallLimit: int
Holds the byte limit for tracked small-block free lists.
__ablaRuntimeHostSmallLists (fun)
trusted fun __ablaRuntimeHostSmallLists(): int
(Static storage, as the collection's page cache: 65 lists, at a block's size.)
__ablaRuntimeHostSmallKept (var)
var __ablaRuntimeHostSmallKept: int
What the lists serve between collections sets how much they keep at the next: as much as they served since the last, a quarter more, at least 32 MB and at most the limit. A program that frees and reallocates its small blocks between collections keeps what it reuses (trees ran 35% fewer instructions, json-megabyte 6%, 2026-11-02); one that doesn't keeps 32 MB, as before (json-megabyte peaked 116 MB higher at a fixed 128 MB, 5 MB here). If at least 32 MB was served and less than 1/64 as much is left unused, double the budget: nearly all cached bytes were useful, so the next sweep can keep more of what it frees. Otherwise keep the cautious quarter: blocks left on inactive size lists cannot serve another size, and growing those took json-megabyte's peak from 214 to 361 MiB. The exhaustion check runs only here, with no new accounting on allocation or freeing. Limits by size, at least 1 MB each and half again what each served, did worse: trees and strings lost what they gained, as most sizes stayed small and each free counted twice.
__ablaRuntimeHostSmallMarked (var)
var __ablaRuntimeHostSmallMarked: int
Records the bytes initially held in small-block free lists at the start of a collection.
__ablaRuntimeHostSmallPushed (var)
var __ablaRuntimeHostSmallPushed: int
Counts bytes of small blocks pushed to free lists during collection.
__ablaRuntimeHostSmallListsSettle (fun)
trusted fun __ablaRuntimeHostSmallListsSettle(): void
Before a sweep: the lists' size for the sweep and the cycle after it, from what they served in the cycle that ends; and where the next cycle's serving is counted from (the sweep's frees add to what the lists hold and to what was given back alike).
__ablaRuntimeHostBlockAllocate (fun)
@inline
trusted fun __ablaRuntimeHostBlockAllocate(size: int, width: int): int
Allocates a tracked block and returns its header address, reporting exhaustion if allocation fails.
__ablaRuntimeHostBlockKept (fun)
@inline
trusted fun __ablaRuntimeHostBlockKept(size: int): bool
Whether a block of size payload bytes goes on the lists above when freed now.
__ablaRuntimeHostBlockFree (fun)
@inline
trusted fun __ablaRuntimeHostBlockFree(header: int, size: int, width: int): void
Releases the block using its header address and payload size.
__ablaRuntimeHostTrackedAllocate (fun)
@inline
trusted fun __ablaRuntimeHostTrackedAllocate(size: int, layout: int): int
Inlined into each runtime allocator (as it always was by size): left out of line, those allocators become small enough to be inlined into every allocation site instead.
__ablaRuntimeHostAllocateBody (fun)
@inline
trusted fun __ablaRuntimeHostAllocateBody(
requested: int,
layout: int
): int
The general allocation: under the heap lock, in a region or from the lists, malloc, or past the registry's room.
__ablaRuntimeHostAllocateGeneral (fun)
@noinline
trusted fun __ablaRuntimeHostAllocateGeneral(requested: int, layout: int): int
The same, out of line: what an object's allocation falls back to, so that its common case below keeps no registers across a call.
__ablaRuntimePlatformAllocateLayout (fun)
@inline
trusted fun __ablaRuntimePlatformAllocateLayout(
requested: int,
layout: int
): int
Allocation. An object's (layout 5, a constant where this is inlined) common case is straight-line code with no call: one thread (no heap lock), no region, a block of this size waiting on its list, room in the registry and under the memory limit. It does what __ablaRuntimeHostTrackedAllocate does for a small block. Any other case, and every other layout (strings and arrays miss the lists often enough that the attempt costs them more than it saves), is the general allocation inline.
__ablaRuntimePlatformAllocate (fun)
@inline
trusted fun __ablaRuntimePlatformAllocate(requested: int): int
Returns a tracked allocation with the default boxed layout.
__ablaRuntimeHostFreeUnlocked (fun)
trusted fun __ablaRuntimeHostFreeUnlocked(address: int): void
Releases a tracked allocation while the caller holds the heap lock.
__ablaRuntimePlatformFree (fun)
trusted fun __ablaRuntimePlatformFree(address: int): void
Frees a tracked allocation under the runtime heap lock.
__ablaRuntimePlatformMemoryCheckpoint (fun)
trusted fun __ablaRuntimePlatformMemoryCheckpoint(): int
A checkpoint is a marker allocation (layout 12) appended to the registry: the collector keeps it, nothing else can free it, and reset frees what follows it. A plain registry position (the latest allocation) was freed by a collection whenever that allocation was garbage, and the reset then walked past it and freed live objects. Consecutive checkpoints share the latest marker, so a checkpoint/reset loop adds one marker in all.
__ablaRuntimePlatformMemoryReset (fun)
trusted fun __ablaRuntimePlatformMemoryReset(checkpoint: int): void
Releases tracked allocations made after the checkpoint.
__ablaRuntimePlatformMemoryLiveBytes (fun)
trusted fun __ablaRuntimePlatformMemoryLiveBytes(): int
Returns the current live tracked payload bytes.
__ablaRuntimePlatformMemoryHeapStat (fun)
trusted fun __ablaRuntimePlatformMemoryHeapStat(which: int): int
Allocator numbers for diagnostics (see the wasm platform); the host's system allocator reports only 4, tracked live bytes.
__ablaRuntimeHostCensus (var)
var __ablaRuntimeHostCensus: int
The heap census (abla/memory's memoryCensus): what the last __ablaRuntimePlatformMemoryCensusTake found, as __ablaRuntimeMemoryCensusWords words (see the runtime's census layout). Kept outside the tracked heap, so taking a census adds nothing to what it counts.
__ablaRuntimePlatformMemoryCensusTake (fun)
trusted fun __ablaRuntimePlatformMemoryCensusTake(): void
Collects a snapshot of allocation counts, payload sizes and overhead by layout.
__ablaRuntimePlatformMemoryCensusWord (fun)
trusted fun __ablaRuntimePlatformMemoryCensusWord(index: int): int
Returns an indexed census word, zero before a census, or traps for an invalid index.
__ablaRuntimePlatformMemoryLimit (fun)
trusted fun __ablaRuntimePlatformMemoryLimit(): int
Returns the configured tracked-memory limit or the default limit.
__ablaRuntimePlatformMemorySetLimit (fun)
trusted fun __ablaRuntimePlatformMemorySetLimit(limit: int): void
Sets the tracked-memory limit and traps if it is below zero or the current live bytes.
__ablaRuntimePlatformMemorySetCollectionGrowth (fun)
trusted fun __ablaRuntimePlatformMemorySetCollectionGrowth(bytes: int): void
Collect under allocation pressure once the tracked heap has grown bytes (or half again, if more) past what the last collection kept. Before the first collection, the first comes once the heap has grown half of bytes, as with ABLA_GC_GROWTH: a compiler asking for 256 MB steps had collected at 32 MB, in the middle of a small build.
__ablaRuntimePlatformMemorySetFreeBlockLimit (fun)
trusted fun __ablaRuntimePlatformMemorySetFreeBlockLimit(bytes: int): void
At most bytes of freed small blocks kept for reuse (__ablaRuntimeHostSmallBytes).
__ablaRuntimePlatformMemorySetManualCollection (fun)
trusted fun __ablaRuntimePlatformMemorySetManualCollection(): void
Manual collection: allocation pressure no longer collects (until a later memorySetLimit or memorySetCollectionGrowth); only memoryCollect() does.
__ablaRuntimePlatformMemorySetStress (fun)
trusted fun __ablaRuntimePlatformMemorySetStress(on: bool): void
ABLA_GC_STRESS and ABLA_GC_TRACE as calls (memorySetStress, memorySetTrace): a shared library has no process environment to read them from. Stress collects at every safe point and fills what it frees; turning it off puts the threshold back to the growth rule's next value at the next collection.
__ablaRuntimePlatformMemorySetStressStride (fun)
trusted fun __ablaRuntimePlatformMemorySetStressStride(stride: int): void
Sets how many safe points pass between two stress collections (1 or less: every one).
__ablaRuntimePlatformMemorySetTrace (fun)
trusted fun __ablaRuntimePlatformMemorySetTrace(on: bool): void
Changes whether the host collector emits trace output.
__ablaRuntimePlatformMemorySetLayout (fun)
trusted fun __ablaRuntimePlatformMemorySetLayout(
address: int,
layout: int
): void
Updates the tracked allocation's layout tag and traps for invalid input.
__ablaRuntimeHostCollectionPageSlot (fun)
@inline
trusted fun __ablaRuntimeHostCollectionPageSlot(table: int, mask: int, page: int): int
The slot of page in a page table (where it is, or the empty slot it would take).
__ablaRuntimeHostCollectionPagesGrow (fun)
trusted fun __ablaRuntimeHostCollectionPagesGrow(table: int, capacity: int): int
Grows the page directory and returns the address of the replacement containing its existing entries.
__ablaRuntimeHostGetenv (fun)
@noinline
trusted fun __ablaRuntimeHostGetenv(name: i64*): i64*
The value of the environment variable name (a NUL-terminated string), or null: the first "name=value" entry of the environment vector. The variables read here are looked up at start, before any program code could change the environment.
__ablaRuntimeHostGetpid (fun)
@inline
trusted fun __ablaRuntimeHostGetpid(): int
The calling process's id, by system call (a forked child has its own).
__ablaRuntimeHostHexDigit (fun)
@inline
trusted fun __ablaRuntimeHostHexDigit(byte: int): int
The value of a hexadecimal digit, or -1.
__ablaRuntimeHostCollectionForceConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostCollectionForceConfigured(): int
Returns the diagnostic lookup mode selected by the environment, or zero for the default.
__ablaRuntimeHostCollectionMappingsLoad (fun)
trusted fun __ablaRuntimeHostCollectionMappingsLoad(): bool
Reads /proc/self/maps into Mapped: the ranges the process can read and write, merged, in address order. False when there is no /proc (the collection then builds its directory as always).
__ablaRuntimeHostCollectionIsMapped (fun)
trusted fun __ablaRuntimeHostCollectionIsMapped(address: int): bool
Whether the two words at the supplied address are in mapped, readable memory.
__ablaRuntimeHostCollectionRegistryMapped (fun)
trusted fun __ablaRuntimeHostCollectionRegistryMapped(): bool
Whether the registry's first and last payload prefixes are in the mapped ranges: a target whose heap addresses carry tag bits (Android's tagged pointers) shows none of /proc/self/maps' untagged ones.
__ablaRuntimeHostCollectionPagesBuild (fun)
trusted fun __ablaRuntimeHostCollectionPagesBuild(): void
Every registered allocation into the page directory (or, when larger, the address-ordered list of large allocations), in one pass over the registry: its entries say which are large, so no header is read. A page's bitmap is placed when the page is first met (the table holds its offset until the pass ends, as the bitmaps may move while they grow).
__ablaRuntimeHostCollectionPageCache (fun)
trusted fun __ablaRuntimeHostCollectionPageCache(): int
The pages looked up lately and their bitmaps, in 256 slots by a page's low bits (each [page + 1 (0: none), bitmap]), emptied as each collection builds its directory. A scan meets pointers into a few pages at a time: in a self-build 99% of lookups hit here, where the last page alone caught 36% and the rest probed the directory's table. (Static storage, not a global: one place, which no inlining copies.)
__ablaRuntimeHostCollectionBitmapOf (fun)
@inline
trusted fun __ablaRuntimeHostCollectionBitmapOf(page: int): int
The bitmap of page, or 0 when no small allocation starts in it.
__ablaRuntimeHostHighestBit (fun)
@inline
trusted fun __ablaRuntimeHostHighestBit(bits: int): int
The index of the highest set bit of a nonzero word.
__ablaRuntimeHostCollectionNearest (fun)
trusted fun __ablaRuntimeHostCollectionNearest(bitmap: int, page: int, bit: int): int
The small payload starting last at or before bit bit of page, or zero.
__ablaRuntimeHostDirectoryContains (fun)
@inline
trusted fun __ablaRuntimeHostDirectoryContains(bitmap: int, candidate: int): bool
Returns true when the aligned address is marked as a payload start in the bitmap.
__ablaRuntimeHostCollectionLocate (fun)
trusted fun __ablaRuntimeHostCollectionLocate(candidate: int): int
Finds the start of the payload that contains a candidate, or zero.
__ablaRuntimeHostCollectionLocateLarge (fun)
@inline
trusted fun __ablaRuntimeHostCollectionLocateLarge(candidate: int): int
Finds a candidate in the address-ordered table of large payloads.
__ablaRuntimeHostCollectionFind (fun)
@noinline
trusted fun __ablaRuntimeHostCollectionFind(candidate: int): int
An exact candidate's prefix is readable when it is in a mapped range or is marked in the directory. The packed slot must name this very payload.
__ablaRuntimeHostMarkPointer (fun)
trusted fun __ablaRuntimeHostMarkPointer(candidate: int): bool
Marks the allocation reached by the candidate pointer and returns whether a new mark was added.
__ablaRuntimeHostClaimSerial (fun)
@inline
trusted fun __ablaRuntimeHostClaimSerial(payload: int, packed: int): void
Queues a payload for serial tracing and sets the queued bit in its slot/state word.
__ablaRuntimeHostMarkExactReference (fun)
@inline
trusted fun __ablaRuntimeHostMarkExactReference(candidate: int): void
Kinds 4 and 5 hold runtime-created one-word references to payload starts. Objects, arrays and maps have an allocation header, except in the frozen window. The region state is outside the range of unmarked layouts.
__ablaRuntimeHostMarkValue (fun)
@noinline
trusted fun __ablaRuntimeHostMarkValue(value: int): void
The root and layout walkers share this tag dispatch instead of duplicating it.
__ablaRuntimeHostMarkRootChain (fun)
trusted fun __ablaRuntimeHostMarkRootChain(head: int): void
Marks allocations reachable from the supplied linked list of root frames.
__ablaRuntimeHostMarkRootValues (fun)
trusted fun __ablaRuntimeHostMarkRootValues(): void
Every thread's roots: the collecting thread's chain, the chains of the registered threads (all parked, or in a join, while the registry is locked by the stop), and the permanent frames of threads that left the registry.
__ablaRuntimeHostTraceMarkedAllocations (fun)
trusted fun __ablaRuntimeHostTraceMarkedAllocations(): void
Drains the mark worklist transitively through reachable allocations.
__ablaRuntimeHostMarkStack (val)
val __ablaRuntimeHostMarkStack: int
A thread's block: +0 its stack's address, +8 its count, +16 its page cache's address, +24 1 once its thread started, +32 its thread handle, +40 objects it traced, +48 times it took from the pool, +56 times it gave to the pool, +64 idle sleeps, +72 idle looks at the pool (the counts are for ABLA_GC_TRACE=1); the stack and the cache follow.
__ablaRuntimeHostMarkHeader (val)
val __ablaRuntimeHostMarkHeader: int
Gives the header size of a parallel mark block in bytes.
__ablaRuntimeHostMarkBlock (val)
val __ablaRuntimeHostMarkBlock: int
Gives the storage size of a parallel mark block in bytes.
__ablaRuntimeHostMarkBitmapOf (fun)
@inline
trusted fun __ablaRuntimeHostMarkBitmapOf(cache: int, page: int): int
__ablaRuntimeHostCollectionBitmapOf with the thread's own page cache.
__ablaRuntimeHostMarkChunk (val)
val __ablaRuntimeHostMarkChunk: int
A large array's element scan is split: past this many elements the scan is cut into chunks of this many, which the threads take from the shared range queue (state +48 the entries' address, +56 their count, +64 their capacity; three words each: the first and the end of the chunk in the payload, and the layout, which gives the element size).
__ablaRuntimeHostMarkWorker (fun)
trusted fun __ablaRuntimeHostMarkWorker(context: int): int
A thread of the mark (the C entry of the ones started for it; the collecting thread calls it too): works until every thread is out of work.
__ablaRuntimeHostTraceParallel (fun)
trusted fun __ablaRuntimeHostTraceParallel(workers: int): void
The mark on workers threads, from the roots the collection has put on its work list.
__ablaRuntimeHostCollectionSweep (fun)
trusted fun __ablaRuntimeHostCollectionSweep(): void
Free what the marker did not reach; clear the marks of what it did. What is kept moves down the registry in its order, closing the empty slots.
__ablaRuntimeHostFreeState (fun)
trusted fun __ablaRuntimeHostFreeState(): int
The helper's state, static storage: +0 whether the program asked (1 on, 2 off, 0 not: the default), +8 the helper's pthread_t, +16 a helper is freeing (0/1), +24 the process that started it, +32 the batch the sweep is filling (chunks of [next chunk, count, headers…], 65534 headers a chunk).
__ablaRuntimeHostBackgroundOptOutConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostBackgroundOptOutConfigured(): bool
Whether the environment turns background freeing off: ABLA_GC_BACKGROUND=0 (any other value, or none, leaves the program's own choice or the default).
__ablaRuntimeHostBackgroundOptOut (var)
var __ablaRuntimeHostBackgroundOptOut: bool
Whether ABLA_GC_BACKGROUND=0 was in the environment at start (read once).
__ablaRuntimeHostBackgroundFreeOn (fun)
trusted fun __ablaRuntimeHostBackgroundFreeOn(): bool
Whether this collection frees in the background: what the program chose with memorySetBackgroundFree, else (a build that gives programs the collection with background freeing, decision #107) yes unless ABLA_GC_BACKGROUND=0. The environment's 0 also overrides a program's own request, so a user can turn the helper thread off for any program. Never fails.
__ablaRuntimePlatformMemorySetBackgroundFree (fun)
trusted fun __ablaRuntimePlatformMemorySetBackgroundFree(enabled: bool): void
Turns background freeing on or off for the program (memorySetBackgroundFree); ABLA_GC_BACKGROUND=0 in the environment still wins.
__ablaRuntimePlatformMemorySetGcWorkers (fun)
trusted fun __ablaRuntimePlatformMemorySetGcWorkers(count: int): void
The collection threads a program asks for (2 to 8; anything else leaves the serial collector), unless ABLA_GC_WORKERS is in the environment: then the environment decides (also 0 and 1, which turn it off).
__ablaRuntimeHostGcWorkersAsked (var)
var __ablaRuntimeHostGcWorkersAsked: bool
Set once the program has called memorySetGcWorkers (whatever the count): the default below leaves its choice alone.
__ablaRuntimeHostGcWorkersDefaulted (var)
var __ablaRuntimeHostGcWorkersDefaulted: bool
Set once the default number of collection threads has been applied (or left alone) at the first background collection.
__ablaRuntimeHostGcWorkersDefault (fun)
trusted fun __ablaRuntimeHostGcWorkersDefault(): void
A program built with the collection with background freeing that never asked for collection threads gets four (fewer on a machine with fewer CPUs; used adaptively, see below), at its first collection: decision #107. ABLA_GC_WORKERS in the environment (0 included) and a call of memorySetGcWorkers (0 included) decide instead. Never fails.
__ablaRuntimeHostFreeWorker (fun)
trusted fun __ablaRuntimeHostFreeWorker(batch: int): int
Frees every block of a batch, then its chunks: the helper's entry (C ABI, through nativeFunctionAddress), or the collection itself when no helper could start.
__ablaRuntimeHostFreeLater (fun)
trusted fun __ablaRuntimeHostFreeLater(header: int, size: int, width: int): void
A block the sweep found unreachable, for the helper.
__ablaRuntimeHostFreeBatch (fun)
trusted fun __ablaRuntimeHostFreeBatch(header: int): void
A block the sweep found unreachable and nothing keeps on the lists: appended to the batch for the helper.
__ablaRuntimeHostFreeWait (fun)
trusted fun __ablaRuntimeHostFreeWait(): void
Waits for the helper still freeing the last collection's batch (in the process that started it; a forked child forgets it).
__ablaRuntimeHostFreeStart (fun)
trusted fun __ablaRuntimeHostFreeStart(): void
Hands the batch the sweep filled to a helper (freed here when none can start).
__ablaRuntimeHostTrimWorthwhile (fun)
@inline
trusted fun __ablaRuntimeHostTrimWorthwhile(working: int): bool
Returns whether the estimated native heap surplus warrants trimming.
__ablaRuntimeHostTrimAfterGc (fun)
@noinline
trusted fun __ablaRuntimeHostTrimAfterGc(working: int): void
If the native heap has a large reclaimable surplus, hand pages back. Heap mappings are an allocator-side estimate. They exclude memory owned by other subsystems and may include pages the kernel already discarded.
__ablaRuntimeHostFinishAdaptiveGc (fun)
@noinline
trusted fun __ablaRuntimeHostFinishAdaptiveGc(stopped: int): int
Set the next automatic threshold while mutators are still parked. An explicit collection publishes it through the same saved threshold as a stop.
__ablaRuntimeHostTrimAfterAdaptiveGc (fun)
@inline
trusted fun __ablaRuntimeHostTrimAfterAdaptiveGc(working: int): void
Releases excess native heap pages after an adaptive collection when reclaiming them is worthwhile.
__ablaRuntimeHostForkChildFirstCollect (fun)
trusted fun __ablaRuntimeHostForkChildFirstCollect(): bool
The first heap call of a raw fork's child: the registry still lists the parent's other threads, so a stop would wait out its 20 ms for threads that are not there and be abandoned. Repairs it and returns true: the caller collects nothing this once (the child's own allocation pressure asks for a real collection when it needs one). Both collectors (the plain one and the background-freeing one) begin with it. Returns true when it repaired a fork child (the caller then collects nothing); false otherwise. It never fails.
__ablaRuntimePlatformMemoryCollect (fun)
@noinline
trusted fun __ablaRuntimePlatformMemoryCollect(): int
Collects the tracked heap and returns reclaimed payload bytes.
__ablaRuntimeHostCollectionLookupBegin (fun)
trusted fun __ablaRuntimeHostCollectionLookupBegin(parallel: bool): void
How the mark of a collection with background freeing finds the allocation a pointer names: serially, as the plain collection does (from the registry alone while /proc/self/maps lists the heap, the page directory when a pointer needs it, ABLA_GC_LOOKUP and the stress mode forcing the directory), or, for the parallel mark (parallel), always through the page directory. Builds the directory when the mode needs it. Never fails.
__ablaRuntimeHostCollectionLookupEnd (fun)
trusted fun __ablaRuntimeHostCollectionLookupEnd(): void
The end of the mark begun by __ablaRuntimeHostCollectionLookupBegin: counts the collection under the way it went (memoryHeapStat 5 registry, 6 directory) and frees the mapped-range lists the lazy lookup read. Never fails.
__ablaRuntimeHostBackgroundMemoryCollect (fun)
trusted fun __ablaRuntimeHostBackgroundMemoryCollect(): int
__ablaRuntimePlatformMemoryCollect with background freeing: what a program that turns it on (memorySetBackgroundFree, anywhere in its own code) has as its collection in place of the one above (bootstrapBackgroundFreeParse); a program that doesn't never reaches it, nor the helper.
__ablaRuntimeHostSweepBlock (val)
val __ablaRuntimeHostSweepBlock: int
__ablaRuntimeHostCollectionSweep, handing what it frees to the helper. ---- Parallel sweep (ABLA_GC_WORKERS=n, with the parallel mark; the background-free collection only) ---------------------- __ablaRuntimeHostBackgroundSweep on n threads, in four passes over the registry in n slices (one thread each, the collecting thread one of them), so that the pause has no serial walk of the registry. The collection's worklist (allocation count words, dead once the mark is done) is the scratch array: no second array is allocated. 1 (parallel): for each entry, the header's state tells garbage from kept. Garbage is poisoned (stress), its size counted, and either pushed on the worker's own small-block lists (what __ablaRuntimeHostBlockKept would keep; the lists are spliced into the global ones afterwards) and its slot zeroed, or tagged (the entry's bit 1) for the helper. Kept: the mark is cleared (state - 32). Each worker counts its kept and tagged entries. (serial, n steps) the counts give each slice its place in the dense registry (kept entries) and in the scratch array's tagged part. 3 (parallel, no header is read of a tagged entry): the slice's kept entries go to the scratch array, in order, at their place, and each kept payload receives its new slot and unmarked state; tagged native block addresses go to the scratch array after the kept ones. 4 (parallel, n slices of the dense registry): the kept entries are copied from the scratch array to the registry. (serial) the tagged entries are appended to the helper's batch. Nothing in a worker allocates, takes a lock or touches thread-local storage. A worker's block: +0 the slice's first slot, +8 its end, +16 the garbage bytes it freed, +24 the small-block bytes it kept on its lists, +32 their budget, +40 its pthread handle, +48 1 once its thread started; the lists' heads follow at +64 (offset by block size, 65 words), then their tails at +64 + 520, then +1104 the slice's kept entries, +1112 its tagged ones, +1120 the scratch index of its first kept entry and +1128 of its first tagged one.
__ablaRuntimeHostSweepWorker (fun)
trusted fun __ablaRuntimeHostSweepWorker(context: int): int
The C entry of the threads started for a pass (the collecting thread calls it as well).
__ablaRuntimeHostRegistryCheck (fun)
trusted fun __ablaRuntimeHostRegistryCheck(): void
Check the dense registry, reverse slots and cleared states after a parallel sweep under stress.
__ablaRuntimeHostGcWorkersForced (var)
var __ablaRuntimeHostGcWorkersForced: bool
True when ABLA_GC_WORKERS was set at start: collections then always use the worker threads, never the adaptive choice.
__ablaRuntimeHostGcWorkersForcedConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcWorkersForcedConfigured(): bool
Returns whether the ABLA_GC_WORKERS environment variable is present (any value); it never fails.
__ablaRuntimeHostGcAdaptiveMinimumSlots (val)
val __ablaRuntimeHostGcAdaptiveMinimumSlots: int
The minimum registry size, in slots, for an adaptive parallel collection.
__ablaRuntimeHostSweepParallel (fun)
trusted fun __ablaRuntimeHostSweepParallel(workers: int): void
Sweeps unreachable tracked allocations across the specified workers.
__ablaRuntimeHostBackgroundSweep (fun)
trusted fun __ablaRuntimeHostBackgroundSweep(): void
Releases the allocation batch assigned to the background sweeper.
__ablaRuntimeRootsPush (fun)
trusted fun __ablaRuntimeRootsPush(
frame: int,
roots: int,
count: int
): int
Links the frame into the current thread's collection roots and returns zero.
__ablaRuntimeRootsPop (fun)
trusted fun __ablaRuntimeRootsPop(frame: int): int
Unlinks the supplied root frame and returns zero, trapping if it is absent.
__ablaRuntimeRootsUnlink (fun)
@noinline
trusted fun __ablaRuntimeRootsUnlink(frame: int): int
A pop that finds another frame on top: an export's static global-root frame is pushed once, lazily, by the first export that touches globals, possibly while an outer frame is live. That outer frame's pop then finds the permanent frame above it, so unlink it from the middle; a frame absent from the chain is a bug. Out of line and cold: inlined at every return of every rooted function, this walk was 4% of a program's code.
__ablaRuntimeHostGcGrowthConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcGrowthConfigured(): int
ABLA_GC_GROWTH selects a payload growth step (decimal bytes, at least 1 MiB). Missing or invalid values leave the adaptive policy enabled.
__ablaRuntimeHostGcStressConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcStressConfigured(): bool
Whether the environment says ABLA_GC_STRESS=1; then collection starts at once.
__ablaRuntimeHostGcPoisonConfigured (fun)
@noinline
trusted fun __ablaRuntimeHostGcPoisonConfigured(): bool
Whether the environment says ABLA_GC_POISON=1.
__ablaRuntimeMemoryPressure (fun)
trusted fun __ablaRuntimeMemoryPressure(): int
Each allocating function has a safe point. Keep the payload comparison inline and share the decision when the heap reaches its threshold or uses automatic pacing.
__ablaRuntimeHostPressureCheck (fun)
@noinline
trusted fun __ablaRuntimeHostPressureCheck(live: int, threshold: int): int
Checks whether allocation pressure requires a collection and returns zero after the safe point.
__ablaRuntimeHostGcStressStride (var)
var __ablaRuntimeHostGcStressStride: int
Under stress, the safe points between two collections (memorySetStressStride; 1: every one).
__ablaRuntimeHostGcStressPasses (var)
var __ablaRuntimeHostGcStressPasses: int
Counts the stressed safe points that passed under a stride. Not atomic: threads may share or skip a count, which only moves where the next collection falls.
__ablaRuntimeHostLoopPasses (var)
var __ablaRuntimeHostLoopPasses: int
A loop's back edge (where it allocates): the same check, except that under ABLA_GC_STRESS=1 only every 1,024th pass collects. A loop building a long list would otherwise collect, walking the whole list, once per node.
__ablaRuntimeMemoryPressureLoop (fun)
trusted fun __ablaRuntimeMemoryPressureLoop(): int
Checks host allocation pressure at a loop back edge and returns zero.
__ablaRuntimeHostScrubCollectorStack (fun)
@noinline
trusted fun __ablaRuntimeHostScrubCollectorStack(): void
Zeroes the 4096 bytes below this call: the frames a collection used (mark, sweep, the stop protocol) lie there when the safe point returns, below the frame of the entry that allocated (a constant-time entry's own wipe, ctScrubStack, reaches its own work but not a collection's deeper frames, which hold words of the heap it walked). A function of its own, as in abla/ct/scrub, so the caller keeps nothing in a red zone.
__ablaRuntimeHostPressureCollect (fun)
@noinline
trusted fun __ablaRuntimeHostPressureCollect(): int
Runs a collection at a pressure safe point and updates the threshold before returning zero.
__ablaRuntimePlatformRegionBegin (fun)
trusted fun __ablaRuntimePlatformRegionBegin(): int
Opens an allocation region and returns its descriptor address.
__ablaRuntimePlatformRegionEnd (fun)
trusted fun __ablaRuntimePlatformRegionEnd(regionAddress: int): void
Releases the region's pages and restores the enclosing region.
__ablaRuntimePlatformRegionActive (fun)
trusted fun __ablaRuntimePlatformRegionActive(): bool
Returns whether the current thread has an active allocation region.
__ablaRuntimePlatformPromoteAllocation (fun)
trusted fun __ablaRuntimePlatformPromoteAllocation(address: int): int
Return an equivalent allocation owned by the parent region. This is the uncommon backpressure/lifetime boundary; ordinary request allocations stay on the zero-malloc bump path.
__ablaRuntimePrintStack (fun)
trusted fun __ablaRuntimePrintStack(): void
Prints the stack to standard error in a debug build (the compiler gives it that body); does nothing elsewhere.
__ablaRuntimeHostRecover (fun)
trusted fun __ablaRuntimeHostRecover(data: int, length: int): int
Inside a checked export, a panic's message goes to its caller's buffer (as much as fits; the length is the whole message's) and the export resumes at its recovery frame; elsewhere this returns and the panic ends the program.
__ablaRuntimePanicContain (fun)
trusted fun __ablaRuntimePanicContain(data: int, length: int): int
panic from abla/process/exit (through __ablaPanicContain's compiler-given body): the same recovery as a runtime panic.
__ablaRuntimeHostWrite (fun)
trusted fun __ablaRuntimeHostWrite(descriptor: int, data: int, length: int): int
The runtime's own standard-error writes and its exit: on macOS the BSD system calls (write 4, exit 1), so a macOS program imports neither libSystem's write nor _exit for them (#811); elsewhere the C functions, which Linux's builds supply by system call. ablaHostIsMacOS() is a constant: each function keeps one side only.
__ablaRuntimeHostExit (fun)
trusted fun __ablaRuntimeHostExit(status: int): void
Terminates the host process with the supplied status.
__ablaRuntimePlatformPanic (fun)
@noinline
trusted fun __ablaRuntimePlatformPanic(data: int, length: int): int
A panic raised by the runtime or by compiled code (division by zero, an index out of bounds, the memory limit) ends the program the way panic from abla/process/exit does: "panic: <message>" on standard error, the stack in a debug build, then exit status 101. String literals are flat, so their data is word 0: __ablaRuntimeStringData's rope path (which allocates) would keep the whole allocator in every program that can panic, even one that never allocates.
__ablaRuntimeHostOutOfMemorySeen (var)
var __ablaRuntimeHostOutOfMemorySeen: int
Records whether out-of-memory reporting has begun.
__ablaRuntimeHostOutOfMemory (fun)
@noinline
trusted fun __ablaRuntimeHostOutOfMemory(): void
The system refused memory: usually a limit on the process rather than the machine (ulimit -v, or the compiler's launcher, which sets it from ABLA_MAX_MEMORY_MB). A trap would say nothing. If reporting it needs memory too, that ends it. Share this failed-allocation path between the allocator's checks.
__ablaRuntimeFloatRemainder (fun)
trusted fun __ablaRuntimeFloatRemainder(x: f64, y: f64): f64
A float % (f64 and f32) on x86-64 Linux, which then needs no fmod or fmodf from libm (#806): the backend calls this there instead of LLVM's frem. The same exact algorithm as WebAssembly's (platform/wasm.ab): C's fmod, x - n·y for the integer n that x / y truncates to, with x's sign, every step exact.
ablaDarwinSyscall (extern)
trusted noescape extern:"intrinsic" fun ablaDarwinSyscall(
number: int,
argument0: int,
argument1: int,
argument2: int,
argument3: int,
argument4: int,
argument5: int
): int
macOS: the Linux-style system calls of the portable standard library over the BSD system calls themselves (#811: a macOS program should import as little of libSystem as it can). ablaDarwinSyscall is the BSD number and six arguments, the result -errno on failure (backend: bootstrapLlvmInlineDarwinSyscall). A Linux number this dispatcher does not handle goes to the C adapter (runtime/abla_darwin_compat.c), which keeps those cases until each group has moved here; its own cases for the numbers handled here exist only for iOS. ablaHostIsMacOS() is a constant: on every other target this function is dead and the C call below never links.
ablaDarwinSyscallPair (extern)
trusted noescape extern:"intrinsic" fun ablaDarwinSyscallPair(
number: int,
argument0: int,
argument1: int,
argument2: int,
argument3: int,
argument4: int,
second: int
): int
The same with five arguments and the second result register (x1 / rdx: fork's child flag, the second descriptor of pipe) stored at second.
abla_darwin_linux_syscall (extern)
trusted noescape extern:"c" fun abla_darwin_linux_syscall(
number: int,
argument0: int,
argument1: int,
argument2: int,
argument3: int,
argument4: int,
argument5: int
): int
Dispatches a Linux-numbered syscall through the Darwin adapter and returns the result.
__ablaRuntimeHostFrozenBase (var)
var __ablaRuntimeHostFrozenBase: int
The window: [base, end), 0 until the first freeze.
__ablaRuntimeHostFrozenEnd (var)
var __ablaRuntimeHostFrozenEnd: int
Holds the exclusive upper address of the frozen heap window.
__ablaRuntimeHostFrozenIn (fun)
@inline
trusted fun __ablaRuntimeHostFrozenIn(address: int): bool
Returns whether the address lies in the frozen heap window.
__ablaRuntimeHostFrozenGroupOf (fun)
trusted fun __ablaRuntimeHostFrozenGroupOf(address: int): int
The record of the group holding address (in the window), or 0.
__ablaRuntimeHostFrozenMark (fun)
@noinline
trusted fun __ablaRuntimeHostFrozenMark(address: int): void
The mark reached address, in the window.
__ablaRuntimeHostFrozenReclaim (fun)
trusted fun __ablaRuntimeHostFrozenReclaim(): void
After the mark: the groups the reached ones point at are reached too, and what none reached goes back to the window.
__ablaRuntimeHostFreezeFind (fun)
trusted fun __ablaRuntimeHostFreezeFind(payload: int): int
The index of the original payload in the forwarding table, or -1.
__ablaRuntimeHostFreezeTableInsert (fun)
trusted fun __ablaRuntimeHostFreezeTableInsert(table: int, mask: int, payload: int, index: int): void
Records the frozen-copy index for an original allocation payload.
__ablaRuntimeHostFreezeAdd (fun)
trusted fun __ablaRuntimeHostFreezeAdd(payload: int, mode: int): void
Adds the block at payload to the group: its place, its flag.
__ablaRuntimeHostFreezeLocate (fun)
trusted fun __ablaRuntimeHostFreezeLocate(candidate: int): int
The payload that contains candidate and has an unmarked layout, or zero.
__ablaRuntimeHostFreezeNote (fun)
trusted fun __ablaRuntimeHostFreezeNote(candidate: int, mode: int): void
Discovery: the pointer candidate found in a block being copied.
__ablaRuntimeHostFreezeRelocate (fun)
trusted fun __ablaRuntimeHostFreezeRelocate(candidate: int): int
The copy's address for candidate (a pointer into a block of the group, or elsewhere: unchanged).
__ablaRuntimeHostFreezeSlot (fun)
@inline
trusted fun __ablaRuntimeHostFreezeSlot(payload: int, copy: int, offset: int, mode: int): void
One pointer slot of a block: offset from its payload. Discovery notes the pointer; the copy pass (copy is the copy's payload) rewrites the copy's word.
__ablaRuntimeHostFreezeValueSlots (fun)
trusted fun __ablaRuntimeHostFreezeValueSlots(payload: int, copy: int, offset: int): void
A value at offset (24 bytes: tag, auxiliary, two words): the words that hold pointers, by the marker's rules.
__ablaRuntimeHostFreezeScan (fun)
trusted fun __ablaRuntimeHostFreezeScan(payload: int, copy: int, mode: int): void
The pointer slots of the block at payload, by its layout as the marker walks it. copy: 0 to discover, else the copy's payload.
__ablaRuntimeHostFreezeCleanup (fun)
trusted fun __ablaRuntimeHostFreezeCleanup(): void
Frees what a freeze built (its tables and the directory the collector's locator reads).
__ablaRuntimePlatformMemoryFreeze (fun)
trusted fun __ablaRuntimePlatformMemoryFreeze(value: any): any
The value stays rooted while the freeze waits for a stop (it may park behind another thread's collection, which would otherwise free what the caller's temporary holds).
__ablaRuntimeHostFreezeBody (fun)
trusted fun __ablaRuntimeHostFreezeBody(value: any): any
The value, frozen: a copy of everything it reaches in a read-only group, or the value itself when it cannot be (no window on this system, a threads stop that did not happen, inside a region). A block the copy cannot take (a raw block holding a heap pointer, a task, a thread, a weak reference, a cell) panics, naming its layout.
__ablaRuntimeHostFreezeFlatten (fun)
trusted fun __ablaRuntimeHostFreezeFlatten(rope: int, destination: int): void
The flat bytes of the rope whose payload is at rope, written at destination (length + 1 bytes' room, the terminator already zero): its leaves in order, from the flat copy of any node that has one. An explicit stack, from the system allocator (not the tracked heap: a freeze runs under the heap lock), and no store into the rope.
__ablaRuntimeHostFreezeIsRope (fun)
trusted fun __ablaRuntimeHostFreezeIsRope(candidate: int): bool
Whether candidate is a rope node (a layout 6 block's payload, the start of one).
__ablaRuntimePlatformAllocateOwned (fun)
trusted fun __ablaRuntimePlatformAllocateOwned(requested: int, layout: int, owner: int): int
A block that lives as long as owner: in the owner's region when it was allocated in the active one, else outside every region (a global's rope flattened first inside a request's region would otherwise keep a copy the region frees).
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.