Bytecode & Managed VMs
Architectura applies the same ArchManifest + SemProgram + IrEmitter model to stack-based and register-based virtual machines. Rather than treating bytecode as an unstructured native byte stream, each frontend validates and normalizes the container's function/method/prototype structure first, then lifts through checked Asem programs into archsem-ir.
[!NOTE] The four production bytecode crates—
archsem-wasm,archsem-evm,archsem-cil, andarchsem-lua—enable their default frontend features out of the box.archsem-pythonis an experimental handler-level frontend gated behindfeatures = ["python"].
WebAssembly (archsem-wasm)
- Parser & Validator: Backed by
fWASM(re-exportingwasmparsertypes).WasmModule::parse/parse_with_featuresvalidates the Wasm binary up front. - Modes & Memory:
WASM32(32-bit linear memory) andWASM64(Memory64,64-bit linear memory).AddrSpace::Datamodels little-endian linear memory. - Stack Normalization (
WasmFunction): Precomputes the deterministic WebAssembly operand-stack heights at every instruction and maps stack slots (STACK_REGISTER_BASE = 0x1000), locals (0x2000), and globals (0x3000) into synthetic registers. Structured control (block,loop,if/else,br,br_if,br_table,end) lowers directly to byte-addressed CFG edges. - One-Call Lifting:
lift_function_cfg(&module, fn_index, &limits)returnsLiftedWasmFunctioncontaining the completearchsem_ir::FunctionCFG. Proposal opcodes outside the neutral core appear asWasmOpcode::Opaquewith validated stack arity.
Ethereum Virtual Machine (archsem-evm)
- Decoder & Fork Gating: Backed by
evm-disassembler(EvmCode::parse/parse_hex).EvmFork(FrontierthroughOsaka) gates opcodes by hard fork—opcodes absent in the selected fork decode asINVALID. Truncated trailingPUSHnimmediates zero-pad to full width, andJUMPDESToffsets are collected at instruction boundaries. - Static Jump-Target Resolution (
EvmFunction): Performs bounded value-set analysis (AnalysisLimits) to resolveJUMPandJUMPIdestinations within the code object, exposingFunctionStackGraphandEvmStackSsaviews. - Address Spaces: Disjoint
AddressSpaceAliasGroups separate big-endian EVMMEMORY_SPACE(Data),CODE_SPACE(Code),STACK_SPACE(Vendor(0)),STORAGE_SPACE(Vendor(1), 256-bit word-addressed),TRANSIENT_SPACE(Vendor(2)),CALLDATA_SPACE(Vendor(3)),RETURNDATA_SPACE(Vendor(4)), andWORLD_STATE_SPACE(Vendor(5)). - 256-bit Semantics & Stack Templates: Stack ops (
stack evmin Asem) emit explicit underflow and 1024-word overflow guards (EVM_SP) around 256-bit arithmetic (ADD,MUL,EXP,ADDMOD,MULMOD,SHL/SHR/SAR,CLZ, etc.). External world-state, gas, and message calls remain typed opaque boundaries. - One-Call Lifting:
lift_code_cfg(&code, &limits)lifts an entire contract intoLiftedCode.
.NET CIL / ECMA-335 (archsem-cil)
- PE & Metadata Decoder: Backed by
cildec(metadata tables, method headers, signatures, exception clauses) andfNET(IL instruction decoder). - Modes (
CIL32/CIL64):mode_for_image_flagsresolves32BITREQUIREDvs PE32+ headers. - Evaluation Stack & Method Slots:
CilFunction::normalizecomputes stack heights and assigns synthetic registers for evaluation-stack slots (0x1000), method arguments (0x2000), and locals (0x3000), plusCIL_STACK_POINTER,CIL_EXCEPTION,CIL_RET, andCIL_FILTER. - Exception Handling (
lift_method_cfg&attach_unwind_edges): Discoverstry/catch/filter/finally/faulthandler entry points viaCfgLiftConfig::additional_entriesand attaches prioritizedExceptionalEdges onto the liftedFunction. - Managed Object Services: Object-model instructions (
newobj,callvirt,ldfld,castclass, etc.) emit typedOpaqueIntrinsics andvolatile./ ordered memory contracts (LoadContract/StoreContract).
Lua & LuaJIT (archsem-lua)
- Chunk Decoder: Backed by
fLUA, supportingLUA51,LUA52,LUA53,LUA54,LUAJIT21, andLUAJIT21_BITOPS(mode_for_version). - Boxed 128-bit Slot Model: Frame slots hold 128-bit boxed values (64-bit payload + 64-bit tag:
NIL_VALUE,FALSE_VALUE,TRUE_VALUE,INTEGER_TAG,FLOAT_TAG) addressed relative toLUA_FRAME, withLUA_LINKfor continuations and dedicated system temporaries for numeric loops and scalar operations. - CFG Lifting & Optional Runtime (
runtimefeature):lift_function_cfg(&module, index, &limits)lifts a prototype's CFG (LiftedLuaFunction). Enablingfeatures = ["runtime"]integratesarchsem-refwith a suspensible cursor (lift_cursor/ProgramCursor) and version-matched error/scope policies (VmErrorPolicy), while table metamethods, upvalues, GC, and native C calls remain explicit guest services.
Experimental: CPython 3.11.9 (archsem-python)
archsem-python (gated behind features = ["python"], not enabled by default) is an experimental, handler-level frontend for baseline CPython 3.11.9 wordcode (LOAD_FAST, BINARY_OP, and generic vectorcall CALL). Callers supply a FrameContext with stack-slot ownership evidence (StackSlot::Object, Null, Unknown) and PreparedVectorcall witness data to decode_3119, then lift single handlers via archsem_python::lift into PYTHON_MANIFEST (PY_LOCALS, PY_SP, PY_LASTI) and five cpython.3119.* reference-counting/protocol opaque services (own_fast, binary, vectorcall, decref, pending_after_success).