Standard library
The standard library is a set of ordinary Abla modules, imported by path: import "abla/text". Importing a module pulls in only that module and what it needs, so a program that never touches JSON, TLS or the compiler doesn't carry them.
Generate the source reference with build/ablac doc. The output is build/docs/index.md, a Markdown page per source module under build/docs/abla/, and build/docs/coverage.json for tools such as the readiness scorecard. These are build products; do not check them in. --stdlib <root> selects a different stdlib directory (containing abla/); --output <directory> selects the destination. The default stdlib follows the compiler's ABLA_STDLIB / ABLA_SYSROOT settings.
The generator uses the compiler's unevaluated analysis graph and parser. It lists public source declarations, including methods, extensions, aliases, values and registered sub-languages, with signatures sliced from the original source and adjacent doc comments. Re-exports link the API to its declaring module; coverage counts declarations at their source, once, rather than at every re-export. Constructor parameters are part of the type signature, not separate coverage entries. Compile-time generated declarations are not executed or counted. Entry modules show their public import path; auxiliary source modules have their own pages, reached through the entry module's re-export links.
Coverage schema version 1 contains modules (each with module, documented, undocumented, total) and totals (the same counts without module). An adjacent /** ... */ or run of // comments counts as documentation, matching editor hover documentation. Modules and declarations appear in deterministic source order.
The suite tracks legacy declarations without comments in tools/doc-coverage-floor.txt. Each row identifies a declaration by module, name, and signature fingerprint, so adding an undocumented overload fails even when another declaration gains a comment. When you document or remove a legacy declaration, run tools/test-doc-coverage-floor.sh build/ablac and remove the rows it lists as resolved. The Linux CI suite checks that those exceptions only shrink relative to the tested base revision.
The same extraction is exposed by ablac analyze --stdio graph symbols and hover results: signature is the exact source header, documentation is the adjacent comment, and optional parameters contains {name, label, documentation?} entries. Parameter labels preserve their source spelling, including defaults and ownership modifiers. Parameter documentation comes from adjacent comments, not @param tags in a function's comment.
By task
| Page | Modules |
|---|---|
| Text, bytes and number formatting | abla/text, abla/bytes, abla/float/text |
| Arrays | abla/array |
| Console, files, processes and time | abla/io, abla/fs, abla/process/* |
| Numbers, bits and randomness | abla/core, abla/math, abla/math/v8, abla/math/fast, abla/float, abla/bits, abla/integer, abla/random |
| Vectors | abla/simd, abla/simd/target |
| Constant-time primitives | abla/ct |
| 256-bit integers | abla/uint256, abla/int256 (int256) |
| 128-bit integers | abla/uint128, abla/int128 (int128) |
| UUIDs | abla/uuid |
| Regular expressions | abla/regex |
| Hashing, encryption, encoding and dates | abla/crypto, abla/date |
| Testing | abla/test and ablac test |
| JSON | abla/json, abla/http/json, $json |
| Networking | abla/net, abla/http/*, abla/websocket/*, abla/tls/pure, abla/dns, abla/dns/async, abla/jwt |
| Compiler API, subparsers, programmable builds | abla/compiler, abla/compiler/parser, abla/build, abla/wasm/build, abla/android/build |
Built into the language rather than imported: string, arrays, Map, Cell, Shared, Weak, Mutex, tasks, threads, generators and region { ... } (language.md).
All modules
| Import | Responsibility |
|---|---|
abla/core | int.abs(), int.sign() |
abla/math | numeric algorithms: integer min/max/clamp, f64 functions and constants |
abla/math/v8 | abla/math's declarations with the results of V8's Math (Node 22, x86-64), bit for bit |
abla/math/fast | abla/math's declarations with fast fdlibm-style results (within about 1 ulp) |
abla/float | f64/f32 conversions and bit patterns |
abla/float/text | shortest round-trip f64 text and parsing; needed to interpolate floats |
abla/integer | exact integer intrinsics (u32.countLeadingZeros()) |
abla/bits | named functions for 64-bit bit operations |
abla/bytes | byte buffers, byte encoding, borrowed slices, stable hashing |
abla/text | string helpers (split, trim, replace, ...) and UTF-8 validation, code points and slicing |
abla/simd | fixed-width vectors; targetHas, cpuHas, AES rounds and carry-less multiply |
abla/ct | secret integers, masks and selects with no branch or index on the value |
abla/uint256 | uint256's arithmetic, comparisons, conversions, decimal and hex text, and big- and little-endian bytes; abla/int256, abla/uint128 and abla/int128 likewise for their types |
abla/crypto | SHA-512, SHA-384, SHA-256, SHA-1, MD5, HMAC, PBKDF2, Base64, hexadecimal, constant-time comparison |
abla/crypto/hkdf | HKDF (RFC 5869) and TLS 1.3 HKDF-Expand-Label / Derive-Secret |
abla/crypto/x25519 | X25519 (RFC 7748), constant-time, on every target |
abla/crypto/ed25519 | Ed25519 (RFC 8032): keys, signatures, verification; constant-time on the secret paths |
abla/crypto/aes, abla/crypto/rsa, abla/crypto/pure | AES and RSA in Abla, no OpenSSL, on every target; what timing protection each has is documented |
abla/crypto/legacy | 3DES-CBC and RC2-CBC, decrypt only, to read old PKCS#12 files (not constant time; no OpenSSL) |
abla/date | UTC calendar dates, ISO 8601 and HTTP dates |
abla/test | checks for test programs run by ablac test |
abla/io | console output, end-of-input-aware line input, buffered text writers |
abla/io/buffered | buffered file writer |
abla/fs | Path, metadata, atomic text writes, directory entries, watches |
abla/fs/path | Lexical path syntax for POSIX and Windows paths (root, parent, name, extension, join, normalize, components, canonical / form), with no file system access |
abla/process | arguments, environment, commands, exit, time: everything below |
abla/process/arguments, /environment, /command, /exit, /time | the same, one capability per import, including an affine allocation-free clock |
abla/process/supervisor | hosted child-process launch, isolated logs, polling, process-tree termination, monotonic timing, and processor discovery |
abla/process/metrics | the process's CPU time, resident/virtual memory, open descriptors and their limit, start time and tracked heap bytes |
abla/random | bounded cryptographic entropy (getrandom) |
abla/uuid | random UUIDv4, time-ordered UUIDv7, bytes and strict text parsing |
abla/regex | linear-time regular expressions: find, findAll, replace, groups |
abla/random/hosted | the same function under its hosted name, hostedSecureRandomBytes |
abla/random/result | SecureRandomResult |
abla/memory | heap limit, collection mode, memoryCollect(), live-byte statistics |
abla/json | bounded JSON parsing, deterministic serialization, and $json literals |
abla/html | HTML data model and the $html subparser |
abla/device | native character-device streams with deadline-bounded binary writes |
abla/serial | baud, framing, raw mode and RTS/CTS configuration |
abla/net | affine dual-stack TCP/UDP sockets, structured I/O results, deadlines, and epoll readiness on raw Linux |
abla/net/contracts | transport-neutral network outcome types |
abla/net/hosted | DNS-capable dual-stack TCP/UDP plus epoll on Linux and kqueue on macOS |
abla/dns | bounded DNS A/AAAA codec, compression-pointer parser, a resolver with /etc/hosts, resolv.conf search domains and ndots, and a hostname connect helper |
abla/dns/async | DnsAsyncResolver: many nonblocking A/AAAA queries driven by step or an outside poller |
abla/http | HTTP/1 client/server, chunk-aware client parsing, pluggable transport, and version-aware routing |
abla/http/stream | keep-alive/chunked policy, gzip negotiation, and Server-Sent Events framing |
abla/http/event | bounded epoll HTTP/1.1 manager with pipelining, partial writes, and backpressure |
abla/http/async | nonblocking HTTP(S) client driven by a poll loop |
abla/http/tls | certificate-verified HTTPS client transport |
abla/http/json | adapters between JSON values and HTTP requests/responses |
abla/compression/gzip | gzip compression and bounded single-member decompression; gzipDecompress(input, maxOutputBytes) collects the result, while gzipStream reads bounded chunks. Both reject malformed input and concatenated members. |
abla/archive/tar | Read bounded POSIX ustar files and directories from memory or a stream, rejecting traversal, duplicates, unsupported entry types and malformed archives |
abla/xtensa/companion | Installer-internal module, not a stable public API. Offline descriptor-relative extraction spools and validates before writing payloads; limits are 512 MiB compressed and 1 GiB unpacked. The in-memory companionValidateArchive retains its 128 MiB / 256 MiB limits. |
abla/fs/secure | Descriptor-relative operations with component validation, bounded handle reads and directory listings, no-follow opens and no-replace rename. replaceSymlink requires a trusted parent; its non-symlink destination check is not atomic against a hostile writer. |
abla/fs/watch | fileEvents(paths): waits (with a timeout) for a change to files, by inotify on Linux and kqueue on macOS through system calls, no libc. A wait can also report a write that changed nothing, or on macOS another file of the same directory: compare the contents (watchFiles) to know. ablac run --watch uses it. |
abla/tls/pure | TLS client and server over raw sockets, with hostname and certificate verification |
abla/websocket | bounded RFC 6455 handshake, framing, connection lifecycle, and routed server helpers |
abla/websocket/client | client masking keys |
abla/websocket/json, /rpc | bounded JSON messages and transport-neutral RPC method routing |
abla/websocket/event | bounded epoll WebSocket manager with fragmentation, ping/pong, and output backpressure |
abla/websocket/server | connection-oriented WebSocket server with admission, broadcast and draining |
abla/websocket/server/tls | TLS for abla/websocket/server: a certificate and key as WebSocketServerOptions(tls = ...), nonblocking handshakes |
abla/websocket/tls | certificate-verified WSS client transport |
abla/jwt, abla/jwt/remote | JWS RS256/ES256 verification against a key set, and a cached remote JWKS |
abla/xml | XML literals, tree nodes and namespace-aware access |
abla/sql | compile-time checked PostgreSQL-subset templates and separately typed bound parameters |
abla/compiler, abla/compiler/parser | compile-time reflection, transforms, generated code and subparser APIs (compile time only) |
abla/build | framework-neutral compile-time program and export requests |
abla/android/build | Android arm64 target, libabla_app.so request, and generated JNI/Kotlin/CMake/Gradle integration |
abla/wasm/build | WebAssembly wasm32 target and no-entry module request |
abla/mvc/wasm/build | an MVC composition that generates a thin browser loader around the Wasm module |
abla/llvm/aot, abla/llvm/orc | in-process object emission and persistent JIT sessions |
abla/unsafe/memory | the trusted native boundary plus checked pointer cells and buffers |
abla/unsafe/memory/raw | raw stack, static and section memory, and raw loads and stores (trusted) |
abla/unsafe/native | typed call-through-address functions and atomics (trusted) |
abla/unsafe/mmio | trusted volatile 8/16/32/64-bit memory-mapped I/O primitives for platform frameworks and device drivers |
abla/unsafe/xtensa | Xtensa interrupt-entry addresses and dispatcher tables |
abla/sys/linux | opt-in raw x86-64 Linux syscall and native descriptor APIs |
abla/sys/linux/fs, /io, /process, /net, /random | the raw-kernel implementations behind the portable modules |
abla/platform/host | the hosted runtime's ablaHost* functions; portable code uses the modules above instead |
abla/runtime/* | the runtime itself, linked automatically; internal (its address intrinsics are callable only from it: native.runtime-internal) |
An interrupted companion publication can leave its version directory at mode
- Verification waits briefly and reports
publication_in_progresswithout
changing it. To reinstall, first ensure no installer is running, then remove the named version directory and rerun installation.
gzipStream(source, maxInputBytes, maxOutputBytes) reads from a caller-owned GzipSource resource. Pass that same source to each read(source, maxBytes) call. Each returned chunk is at most 64 KiB; an empty source chunk must mark EOF or report an error. The decoder can read ahead, so do not consume or reposition the source between calls. Output is provisional until done is true, after the CRC, ISIZE and end of the single member are checked. Errors are invalid, limit or source; abandoning the stream early does not validate it. The stream owns its history buffer and releases it when dropped.
tarStream(limits) accepts a caller-owned TarSource on each next(source) and readData(source, maxBytes) call. Read the current file completely before requesting the next entry; data chunks are bounded to 64 KiB. Names, file sizes, entry count and archive bytes obey TarLimits, and streamed TarEntry.offset is always zero. File data and metadata are provisional until next reports done, after padding, terminal blocks and source EOF have been checked. Errors are invalid, unsupported, limit, or an error returned by the source; an empty non-EOF source response is source. The archive limit is enforced as bytes arrive, so malformed input that also exceeds the limit can report a different first error from the in-memory tarRead.
There are no visibility modifiers, so a module's internal helpers are also importable. The functions named on the task pages are the supported API.
Architecture notes
ByteBuffer currently uses immutable chunks and ByteSlice is a checked view. That representation is portable and works in both # evaluation and native code; a target backend may specialize it to contiguous storage while preserving the source API. Bytes are one-byte strings at this layer so no integer-to-Unicode conversion can silently corrupt binary data.
abla/text layers explicit Unicode scalar semantics over byte-preserving strings. Validation rejects overlong encodings, surrogate code points, truncation, and values beyond U+10FFFF. It has no locale or large Unicode table dependency and works during both staged and runtime execution.
abla/io console output and EOF-aware line input use the Linux descriptor implementation and work unchanged in hosted and JIT execution. abla/fs and abla/process use the same Linux implementations as the compiler, including atomic files, directory enumeration/watch identities, arguments, sleep, and command/child lifecycle. abla/process/time exposes millisecond/nanosecond monotonic values, checked nanosecond sleep, and an affine MonotonicClock that reuses its three kernel buffers in hot loops. Linux lowers these operations to clock_gettime and nanosleep syscalls without libc.
BufferedTextWriter batches text behind an ordinary (string) -> bool sink. Its stdout/stderr constructors stay in abla/io; the file adapter is a separate abla/io/buffered import and flushes through append-only atomic kernel writes after an explicit truncate decision. This callback boundary is also the integration point for sockets, compression, and future TLS transports.
Native memory is deliberately outside abla/core. NativeI64Cell, NativePointerCell, and NativeByteBuffer are affine resource class values with checked operations and idempotent close; the LLVM backend lowers their trusted implementation directly instead of routing it through C. They are the out-parameter and bounded-buffer building blocks used by LLVM ORC and raw platform APIs. Raw dereference and call intrinsics are callable only from a function-level trusted implementation; ordinary consumers borrow the checked resources. A static reservation only produces an opaque integer address, while using that address as memory remains trusted. The trusted boundary also provides fixed-signature call-through-address operations for native extension entry points. Each operation encodes its exact pointer and integer lanes; there is no unchecked variadic call surface.
A NUL-terminated native string becomes an Abla string with nativeCString, which copies it: the string stays valid after the native memory is released or reused. borrowNativeCString reads it in place, without a copy, and is valid only while that memory is. A string made from a borrowed one can share the same bytes, because string operations don't copy what they can share: a template such as "${s}", + with an empty side, a concatenation longer than 64 bytes (it keeps references to its parts), and a stored value. Use a borrowed string, and anything made from it, only while the memory is live; text that outlives the memory comes from nativeCString.
Native counter integrations can use the monotonic atomic i64 fetch-add operation instead of introducing a foreign runtime helper or data race. Trusted embedded drivers can also request function-scoped native storage with nativeStackAllocate; LLVM lowers the intrinsic directly in its caller to alloca, and the unsafe 8/16/32/64-bit loads, stores, copy, and memory-set operations lower directly to LLVM memory instructions. The address must not escape its calling function. nativeStaticAllocate reserves one zero-initialized LLVM global per constant-sized call site for process-lifetime driver storage. Higher-level packages should wrap that raw address in a checked nominal handle or an ownership-checked resource type.
Freestanding startup code that owns writable-memory preparation can call nativeInitializeGlobals() after data and BSS are ready. The call runs the same once-only initializer used by ordinary foreign entries. Its presence also tells the compiler that this entry owns initialization, so LLVM does not insert an unsafe earlier guard ahead of a kernel or firmware boot function.
abla/unsafe/xtensa can also turn a named top-level () -> void function into a native Xtensa interrupt-entry address. This is a compiler operation, not a boxed Fn conversion: closures and local aliases are rejected, the entry uses the target's native calling convention, and its directly reachable Abla code is placed in .iram1.text automatically. The platform framework remains responsible for installing that address and for keeping every indirectly reached function and datum interrupt-safe. The same module exposes the linker-provided Xtensa dispatcher-table address as a native scalar so a framework can install entries directly without calling a C registration ABI. For a framework that owns the classic dual-core dispatcher ABI, nativeXtensaOwnedDispatcherTableAddress emits initialized 64-entry interrupt and 128-entry exception tables as native globals and returns the interrupt table address. It also emits the classic ESP32's 32-byte read-only interrupt level table. Separate intrinsics expose all three table addresses and the two unhandled-handler symbols without a foreign call. It adds no runtime initializer or allocation and safely completes earlier external declarations of the same tables. Platform code must still provide the ABI's unhandled routines and vector path, and must not combine this ownership primitive with a competing table definition. An exact Xtensa xt_unhandled_interrupt export and its direct Abla call graph are automatically kept in IRAM because the vector can invoke that ABI while flash is unavailable.
abla/sys/linux is likewise explicit and target-specific. Its current x86-64 implementation lowers openat, read, write, close, and getpid through LLVM inline syscall assembly and offers checked descriptor and native byte-buffer wrappers. It neither silently replaces the portable abla/fs surface nor pulls libc's syscall wrapper into programs that select it.
abla/sys/linux/fs builds the complete text-file/path/watch layer on that surface: newfstatat, getcwd, openat, read, write, fsync, mkdir, rename, unlink/rmdir, and getdents64 are issued from Abla, with owned native buffers for kernel out-parameters. The Linux self-hosted compiler uses it for module loading, cache files, atomic outputs, and watched graphs. The compiler preserves the same intrinsic contract while final LLVM output lowers it directly; portable applications select abla/fs explicitly.
abla/sys/linux/io adds a stateful input reader that preserves bytes following a line terminator, distinguishes EOF from an empty line, accepts CRLF, and can poll for readiness. Its stdout/stderr helpers retry interrupted and partial writes. Like the raw filesystem profile, it links no project C symbols.
abla/sys/linux/net implements affine IPv4/IPv6 TCP listeners/connections, UDP sockets, structured I/O outcomes, and single/multi-descriptor readiness with socket, setsockopt, getsockopt, bind, listen, getsockname, getpeername, accept4, sendto, recvfrom, poll, and epoll syscalls. Graceful service shutdown blocks SIGTERM, consumes it through signalfd, and polls the listener and shutdown descriptor together; an active HTTP request therefore finishes before the next accept observes the drain request. On macOS the Darwin adapter backs rt_sigprocmask with pthread_sigmask and a signalfd with a kqueue watching EVFILT_SIGNAL, so a Mach-O server drains the same way. The current abla/net facade selects this backend, so AOT and JIT HTTP servers link and run without the project C capability adapter. Hosted services that need the same transport concepts on macOS can explicitly select abla/net/hosted; its narrow runtime adapter uses getaddrinfo, epoll, or kqueue while keeping descriptors inside affine Abla resources. The complete contract and current platform boundary are documented in networking.md.
Allocation regions are intentionally narrower than a garbage collector. region { ... } rejects heap-backed results, stores into older locals/objects, retaining foreign calls, and direct or transitive mutation of outer receivers and heap parameters. Affine resources are destroyed before the generation is reset. The raw numeric checkpoint functions (memoryCheckpoint, memoryReset in abla/memory) cannot encode those lifetime facts, so they are for runtime and compiler internals, not for application code. The REPL uses the checked form after unloading each JIT generation; HTTP handlers can adopt it once their response promotion and long-lived-state policy is explicit.
abla/memory exposes memoryLiveBytes(), memoryLimit(), memorySetLimit(bytes), memorySetCollectionGrowth(bytes), memorySetFreeBlockLimit(bytes), memorySetManualCollection(), memorySetBackgroundFree(enabled), and the explicit memoryCollect() safe point. The collector returns reclaimed bytes, preserves compiler-rooted locals, parameters, globals, affine/native payloads, and higher-order call buffers, and reclaims unreachable cyclic arrays/objects using precise allocation layouts. Compile-time tree evaluation treats the safe point as a successful no-op. The limit accounts for cumulative payload bytes of all tracked runtime allocations, defaults to one GiB on every target, rejects negative values or a value below current live usage, and fails before asking the platform allocator for memory. Native resource allocations are pinned until explicit ownership drop or region reset.
memoryCensus() says what the tracked heap holds, for diagnostics: per allocation layout (strings' bytes, arrays, class instances, ...) how many allocations and their payload bytes, which add up to memoryLiveBytes(); the instances' declared fields by the tag of the value each holds; and what the allocations cost past their payloads (their headers, and on Wasm the allocator's block headers and size-class rounding). It walks the heap once and collects nothing, so call memoryCollect() first to count only what is reachable.
Collection has two modes:
- Pressure collection (the default for hosted native programs with
main). Every allocating function is a safe point: on entry (where its root frame is pushed) and on the back edge of each of its loops that allocates, it collects once the tracked heap has grown past a threshold, so a loop that only builds strings or grows arrays collects too. (Comparing or indexing a string may flatten a rope, which allocates the rope's own copy; that alone makes no safe point.) The hosted default starts with an 8 MiB pressure budget. After each collection its next budget is three times the surviving footprint, clamped between 8 and 128 MiB and constrained by the payload limit. Pressure includes tracked payload and estimated bookkeeping, as well as native buffer allocation volume that would otherwise disappear when a buffer is closed between safe points. On the runtime's native heap, a collection trims excess free chunks when the mapped heap is large relative to the surviving footprint. Public live bytes and the hard payload limit retain their existing meaning. memorySetCollectionGrowth(bytes) selects explicit payload pacing. It sets the least growth between collections and starts the first collection at half that value when set before allocations. ABLA_GC_GROWTH=<bytes> also selects explicit pacing (decimal, at least 1 MiB, read at startup). memorySetFreeBlockLimit(bytes) caps the small-block cache at 128 MiB by default. Run with ABLA_GC_STRESS=1 to collect at every safe point instead (debugging.md). ABLA_GC_WORKERS=<n> (2 to 8, read once at startup; unset, 0 or 1 is the serial collector, which is what a program gets by default) runs the mark of each collection on n threads: the collecting thread and n - 1 it starts for the mark and joins at its end. It parallelizes only the mark, and only across objects: each thread claims an object by a compare-and-swap of its state word, keeps its own stack of claimed objects and trades work with the others through a shared pool, so a graph of many objects divides well, and a large array's elements are scanned in chunks of 4,096 by several threads (an array of fewer than 8,192 elements, or one long chain of objects, is still scanned by one thread). The sweep (the pass that frees what the mark did not reach and compacts the allocation registry) runs on threads too, as many as the process may use CPUs (at most 8, never fewer than the mark's: the program's own threads are stopped, and the pass waits on memory, one header read per registry slot): four passes over slices of the registry (clear the marks and count the kept and the unreachable entries; place the kept entries and the unreachable headers, which the helper frees, at their final places through the collection's dead worklist; copy the kept entries back), with no serial walk of the registry. Only the root scan is serial. The parallel mark needs the page directory for every pointer, so it does not use the lazy registry lookup a serial collection tries first. It is part of the collector that frees in the background, so a release hosted Linux executable gets it by default, and other programs can turn it on with memorySetBackgroundFree(true). A program can name a default with memorySetGcWorkers(count), which ABLA_GC_WORKERS (any value, 0 included) overrides: the editor service (ablac analyze --stdio) asks for 4, which halves its collection pauses over an edit loop on the compiler's own source (6.2 s to 3.1 s in total, 4 cores' worth of extra CPU time only while a collection runs, peak memory unchanged); the batch compiler asks for 4 as well (a one-stage self build on 6 cores: its 30 collections pause 1.68 s serial, 0.94 s on 4 threads always, 1.28 s adaptive, wall time 61.8 s serial and 59 to 61 s with threads, user CPU 134 s to 131 to 135 s). A program's request is clamped to the CPUs the process may use (one CPU stays serial) and is adaptive: a collection of fewer than 262,144 registry slots is serial, and a larger one parallel unless measured worse (the collector compares the cost per slot of consecutive collections run in the two modes, probing the other mode from the 2nd larger collection, then every 4th, 8th, ... up to 128th while a probe changes nothing; ABLA_GC_TRACE=1 prints gc: adaptive, parallel 0 or 1 ratio parallel/serial (thousandths) R probe every E). ABLA_GC_WORKERS=n in the environment always uses the threads. Under collector stress, the page directory is built every time, so adaptive marking starts at 65,536 registry slots. Sweeping stays serial during stress unless ABLA_GC_WORKERS explicitly requests workers. Measured on the editor's edit loop over the compiler's own source (16 collections, 3 to 6 runs each, a machine under load): the collections' total pause 3.9 s serial, 3.1 s at 2 threads, 2.7 s at 4 and 2.5 s at 8 (the mark itself about 2.1 s, 0.9 s at 4 threads), the loop's wall time 22.9 s, 22.1, 21.4 and 21.0, its user CPU +4% at 4 threads and +8% at 8; an HTTP event server whose live data is one 800,000-element array gained nothing and spent 8 to 10% more CPU. It is off by default until the large-array split is done (TODO.md); ABLA_GC_TRACE=1 adds, to each parallel collection, lines with how many objects each thread traced, how often it took from and gave to the shared pool and how often it slept waiting for work. Each collection also prints gc: phases us, pages P roots R mark M settle S (the page directory, the root scan, the mark and the frozen-group settle, in microseconds), gc: parallel sweep, slots N kept K us, mark-clear A place B copy C batch (serial) D and gc: phases us, sweep S free start F: where its pause went.
- Manual collection (the default for wasm and freestanding targets, and
for modules entered through their exports). Only an explicit memoryCollect() frees cyclic garbage. The compiler roots only the functions that can reach that call, so the program carries no safe-point code. A hosted program opts into it with memorySetManualCollection(): a call anywhere main can reach compiles it without pressure safe points, and at run time the call stops pressure collection.
memorySetBackgroundFree(enabled) (hosted native targets; a no-op elsewhere) moves returning unreachable blocks to the system allocator out of the collection: the sweep hands them to a helper thread of the runtime's own, which frees them while the program goes on, and the next collection waits for it first. A release (not `--fast`) hosted Linux executable has it by default (decision #107; the helper thread starts at the first collection that has something to free, with the adaptive collection threads, four by default and fewer on fewer CPUs). Automatic workers require 262,144 registry slots and at least 32 MiB of live allocations after the previous collection. They can run below 32 MiB when serial marking has found that the heap needs a page directory for its lookups.
memorySetBackgroundFree(false) in the program gives the plain collection back, memorySetGcWorkers(0) keeps background freeing with the serial mark and sweep, and in the environment ABLA_GC_BACKGROUND=0 turns background freeing off for any program (also one that asked for it) and ABLA_GC_WORKERS=0 the threads. A program that calls memorySetManualCollection(), a --fast build (which keeps its plain collection unless the program asks), a Wasm module, a shared or static library, an object and a macOS program are built as before (no helper, no threads, unless the program asks: macOS keeps its libSystem imports). Results are the same either way, and the memory is back with the system allocator before the next collection. A forked child drops the batch its parent's helper was freeing. The default costs a release hosted program, measured on a hello world: 17 KB more code (32.0 to 49.3 KB) and a compile 0.13 s longer (0.37 to 0.50 s), and one more thread once a collection has garbage to free; a --fast build is unchanged. tools/test-gc-default.sh covers the default and the opt-outs. The compiler turns it on itself.
memorySetLimit(bytes) and memorySetCollectionGrowth(bytes) select pressure collection in either mode: a program that can reach either is compiled with pressure safe points, and the call turns collection under pressure on at run time (after memorySetManualCollection() too).
A limit bounds live bytes, not the memory the process holds, which also has what collections parked on free lists. On Wasm a limit also lowers the thresholds at which parked memory is merged for reuse, to a limit's eighth and sixteenth, so a heap smaller than the defaults (4 MiB parked, then every 1 MiB) gets merges too. Linear memory can still reach several times the limit: garbage of many sizes under a 2 MiB limit grew it by 7 MiB (tools/test-wasm-reclaim-limit.sh).
Near its limit, pressure collection stops before it would run at nearly every allocating call. Its threshold stays below the limit, leaving a quarter of it (at most 64 MiB) as room. When a collection keeps so much that less than 1/64 of the limit is left under that threshold, the next collection waits until half of the remaining room to the limit is used, and never for less than 1/64 of the limit. A program whose live data grows to its limit reaches the limit's panic (memory limit exceeded, exit code 101) after a few collections. A program whose reachable data stays within about 1/64 of its limit also panics, where it would otherwise collect without end and make almost no progress. A long-running program, such as a server, that must not stop there needs a higher limit.
| Program | Default | Opt out / in |
|---|---|---|
hosted native, with main | pressure | memorySetManualCollection() |
| wasm, freestanding, export-only modules | manual | memorySetLimit / memorySetCollectionGrowth |
HTTP versioning
The router preserves the original repository's multiple-handler idea without hard-wiring it into the transport. Routes have a method, path pattern, handler, and optional ordered version key. A configurable request header chooses the newest version not newer than the requested version; no header selects latest. ISO dates are the initial canonical keys because lexical and chronological ordering agree.
import "abla/http"
import "abla/io"
fun customerV1(request: HttpRequest): HttpResponse = httpText("v1")
fun customerV2(request: HttpRequest): HttpResponse = httpText("v2")
fun main {
val api = httpRouter("Stripe-Version")
api.version("2024-01-01").get("/customers/:id", customerV1)
api.version("2025-01-01").get("/customers/:id", customerV2)
val old = httpGet("/customers/42", [HttpHeader("Stripe-Version", "2024-06-01")])
println(api.dispatch(old).body)
println(api.dispatch(httpGet("/customers/42")).body)
}
// output:
// v1
// v2
Handlers remain ordinary typed Abla functions, so V2 can call V1 and transform its typed model. Future @route and @version compile-time annotations will generate the same route table rather than introduce a second router.
Keeping binaries small
- Imports select source modules; HTTP does not import JSON, files, TLS, or the
compiler.
- Platform implementations are selected by target profile (
posix, future
linux-raw, WASI), never all linked together.
- IR reachability starts at
main, global initializers, exports, and
address-taken functions. Unreachable declarations are removed before LLVM.
- Runtime functions use individual sections and LLD garbage collection;
LLVM global DCE removes unused internal functions.
- Optional facilities such as TLS, Unicode databases, HTTP/2, reflection, and
compiler services remain separate imports.
Steps 1, 3, 4, and 5 are active today. Native programs with no extern:"host" instructions select an LLVM-emitted allocator/panic implementation and dead strip the complete project C adapter; importing a host capability selects the tracked ABI-compatible allocator. Emitted allocation generations and raw network transport are both active; typed errors and target-profile selection are the next platform boundary milestones.
Built from compiler source ba5d6b7d. Examples and generated signatures follow that source revision.