Chapter 3: Zero-Header B8G-ABI Dispatch Tables
Chapter 3: Zero-Header B8G-ABI Dispatch Tables
Lineage: Green/Red/Purple Dragon (Language-Coupled C++ ABIs & Name Mangling) → White Dragon (Zero-Header C11 Static Dispatch)
Live Proof:sections/chromium-build/b8g_chromium_abi_table.h& 18 real Chromium DLLs (11.5–13 KBeach)
3.1 The C++ ABI Mirage
The Purple Dragon Book (2006) treats calling conventions and vtables as backend code-generation details. In real-world C++ systems, however, the ABI is the architecture. Because C++ encodes template arguments, inline destructors, exception tables, and std::string layouts into mangled symbol names, linking against a subsystem like Blink, Viz, Mojo, or V8 forces every caller to #include the subsystem's entire internal header universe.
Break that coupling once by deleting C++ headers at the boundary, and you never break binary callers again.
3.2 The Two-Header Rule: <stddef.h> and <stdint.h> Only
Every B8G-ABI boundary header obeys one unforgiving rule: it may include only <stddef.h> and <stdint.h>. Zero STL. Zero v8.h. Zero absl. Zero Oilpan. Zero skia.
All data crossing the boundary uses fixed-width, cache-friendly POD structs (B8gFlatFlexItem32C at 32 bytes, B8gVizQuad48C at 48 bytes), and all behavior is exposed through flat C11 function-pointer tables:
#include <stddef.h>
#include <stdint.h>
#define B8G_CHROMIUM_ABI_MAGIC 0x41473842u /* "B8GA" */
#define B8G_CHROMIUM_ABI_VERSION_V2 0x00020000u
#define B8G_CHROMIUM_ABI_VERSION_V3 0x00030000u
typedef struct B8gChromiumAbiTable {
uint32_t magic;
uint32_t abi_version;
const B8gIpczDispatchTable* ipcz;
const B8gBlinkFlexDispatchTable* blink_flex;
const B8gVizDispatchTable* viz;
const B8gV8DispatchTable* v8;
const B8gBaseDispatchTable* base;
const B8gMojoDispatchTable* mojo;
const B8gNetDispatchTable* net;
const B8gGpuDispatchTable* gpu;
const B8gShellDispatchTable* shell;
} B8gChromiumAbiTable;
Because downstream consumers parse ~190 lines of pure C11 instead of 500,000 lines of C++ templates, each subsystem wrapper compiles in 170 ms (and zero-v8.h C-ABI consumers compile in 90.52 ms), producing 18 real Chromium subsystem DLLs ranging from 11.5 KB to 13 KB each — a > 10,000× reduction compared to the 166.41 MB chrome.dll monolith.
3.3 Step-Wise v2 → v3 Prefix Compatibility (offsetof == 0)
A common objection to flat C function tables is evolution: how do you add new subsystems without a flag-day rebuild?
B8G-ABI v3 solves this with monotonic prefix embedding verified at compile time (_Static_assert(offsetof(B8gChromiumAbiTableV3, v2) == 0)):
typedef struct B8gChromiumAbiTableV3 {
B8gChromiumAbiTable v2; /* MUST stay at byte offset 0 */
uint32_t struct_size; /* sizeof(B8gChromiumAbiTableV3) */
uint32_t capability_flags;
const B8gOriginArenaDispatchTable* origin_arena;
const B8gCloudSyncV3DispatchTable* cloud_sync;
const B8gLibNodeDispatchTable* libnode;
const B8gAbiUpgradeDispatchTable* upgrade;
} B8gChromiumAbiTableV3;
static inline int b8g_abi_is_v3(const B8gChromiumAbiTable* tbl) {
if (!tbl || tbl->magic != B8G_CHROMIUM_ABI_MAGIC) return 0;
if (tbl->abi_version < B8G_CHROMIUM_ABI_VERSION_V3) return 0;
const B8gChromiumAbiTableV3* v3 = (const B8gChromiumAbiTableV3*)tbl;
return v3->struct_size >= sizeof(B8gChromiumAbiTableV3);
}
Bidirectional Compatibility Invariants
- v2 Host + v3 Module: Reads the exact offset-0
v2prefix; safely ignores the appendedv3tail. - v3 Host + v2 Module:
b8g_abi_is_v3()returns0; host stays in v2 compatibility mode with zero crashes. - v3 Host + v3 Module: Verifies
struct_sizeandcapability_flags(B8G_CAP_ORIGIN_ARENA,B8G_CAP_CLOUD_SYNC,B8G_CAP_LIBNODE_SHARED_V8) and enables live RAMhot_swap_subsystem()without touchingchrome.dllorv8.dll.
3.4 Historical Contrast: C++ Header Graphs vs. Zero-Header B8G-ABI
| Dimension | Classical C++ ABI (Purple Dragon Era) | Zero-Header B8G-ABI (White Dragon) |
|---|---|---|
| Header Footprint | 500,000+ LOC (v8.h, absl, skia, STL) |
<stddef.h> + <stdint.h> (~190 LOC) |
| Module Compile Time | Tens of seconds to minutes per TU | 170 ms per Chromium ABI module |
| Binary Size | 166.41 MB monolith / 551 DLLs (1.30 GB) |
18 real DLLs at 11.5–13 KB each |
| ABI Evolution | Flag-day recompilation on layout change | Offset-0 prefix (v2 → v3) + struct_size + capability_flags |
| Hot-Swapping | Impossible without process restart | Live hot_swap_subsystem() in microseconds in RAM |
Zero-header boundaries eliminate the #include tax at module edges. In Chapter 4, we eliminate redundant compilation inside the remaining 47 KEEP-ALGO kernels using Content-Addressed .b8p CAS Packs.