Module wasm_quota

Module wasm_quota 

Source
Expand description

Portable, runtime-independent WebAssembly compute-quota instrumentation and shared task-level resource accounting.

Instruments standard .wasm module binaries so that compute-quota deductions (deduct-before-effect), linear-memory and table logical vs. physical growth checks, and interruption ordinals execute identically on any compliant WebAssembly runtime (tinywasm, V8/Node WebAssembly, Wasmtime, etc.) without requiring a forked WASM engine.

Structs§

InstrumentedWasmModule
Metadata and instrumented .wasm bytes produced by instrument_wasm_module_bytes.
SharedWasmTaskQuota
Shared task-level compute and output quota tracker used to ensure that repeated or nested helper invocations within a single document evaluation task deduct from one shared allowance rather than silently replenishing quotas.
SharedWasmTaskQuotaState
Mutable state inside a SharedWasmTaskQuota.

Constants§

CTB_CAPABILITY_YIELD_EXPORT
Optional guest () -> () stub export rewritten at runtime to invoke CTB_HOST_CAPABILITY_IMPORT_NAME so standard modules remain zero-import .wasm.
CTB_EXHAUSTED_EXPORT
Exported i32 global indicating interruption status: 0 = none, 1 = ComputeQuotaExhausted, 2 = MemoryLimitExceeded, 3 = TableLimitExceeded.
CTB_HOST_CAPABILITY_IMPORT_NAME
Internal host import function name used by DcWasmSession to suspend a live intra-step continuation for a mid-step host capability request.
CTB_HOST_IMPORT_MODULE
Internal host import module name used by DcWasmSession to suspend and resume live intra-step continuations on compute-quota exhaustion and mid-step host capability requests.
CTB_HOST_SUSPEND_IMPORT_NAME
Internal host import function name used by DcWasmSession to suspend and resume live intra-step continuations on compute-quota exhaustion.
CTB_INTERRUPTED_OP_EXPORT
Exported i64 global recording the 1-based ordinal of the interrupted operation (or requested total pages/elements on physical growth exhaustion).
CTB_MAX_MEM_PAGES_EXPORT
Exported i64 global holding the logical maximum 64 KiB pages (max_memory_pages).
CTB_MAX_TABLE_ELEMS_EXPORT
Exported i64 global holding the logical maximum table elements (max_table_elements).
CTB_OP_ORDINAL_EXPORT
Exported i64 global tracking the 1-based ordinal of metered operations executed.
CTB_PHYS_MAX_MEM_PAGES_EXPORT
Exported i64 global holding the physical host allocation cap in 64 KiB pages.
CTB_PHYS_MAX_TABLE_ELEMS_EXPORT
Exported i64 global holding the physical host allocation cap in table elements.
CTB_QUOTA_CONSUMED_EXPORT
Exported i64 global holding the compute quota units consumed in the current run.
CTB_QUOTA_REMAINING_EXPORT
Exported i64 global holding the remaining portable compute quota units.
CTB_REQUIRED_COST_EXPORT
Exported i64 global recording the compute cost required by the interrupted operation.
CTB_RESUME_TARGET_OP_EXPORT
Exported i64 global specifying the 1-based operation ordinal at which portable single-threaded continuation replay begins charging quota (0 = charge from op 1).
CTB_TOTAL_MEM_PAGES_EXPORT
Exported i64 global tracking total allocated 64 KiB pages across all module memories.
CTB_TOTAL_TABLE_ELEMS_EXPORT
Exported i64 global tracking total allocated elements across all module tables.
CTB_WASM_START_EXPORT
Exported function name used when a module’s Start section (section 8) is hoisted for explicit metered execution.
V2_MAX_STRAIGHT_LINE_OPS
Maximum straight-line non-loop/non-bulk/non-grow WASM operations permitted in V2 structural-checkpoint metering before inserting a stride checkpoint.

Functions§

instrument_wasm_module_bytes
Validates and instruments a standard WebAssembly module binary with portable deduct-before-effect compute-quota accounting and logical/physical memory and table growth guards.