Sign in

    #wasmoon_jit/artifact

    Target-portable ordinary data for Wasmoon Cwasm files and persistent JIT cache entries.

    The package defines the compatibility manifest, stable import and function identities, logical signatures, and the complete unlinked code-object payload. Relocations remain symbolic. Artifacts never contain process addresses, executable-memory addresses, linked images, MilkIR, MachV, Target VCode, allocation results, or frame-planning objects.

    Decoding and encoding belong to this package. Compatibility checks, target code-object verification, symbol resolution, executable-memory allocation, and installation belong to the native Milky2018/wasmoon_jit facade.

    decode treats every input as untrusted. DecodeLimits bounds the file, function and import counts, strings, signatures, code, relocations, metadata, and safepoint roots before allocation. Malformed input, incompatible versions, invalid UTF-8, unknown tags, truncation, and limit violations are reported as structured ArtifactDecodeError values.

    ArtifactDecodeError

    pub suberror ArtifactDecodeError {
    ArtifactTooLarge(size~ : Int, limit~ : Int)
    BadMagic
    UnsupportedVersion(version~ : Int)
    Truncated(field~ : String, offset~ : Int, needed~ : Int, remaining~ : Int)
    InvalidTag(field~ : String, tag~ : Int)
    InvalidValue(field~ : String, message~ : String)
    InvalidUtf8(field~ : String)
    LimitExceeded(field~ : String, count~ : Int, limit~ : Int)
    TrailingBytes(count~ : Int)
    } derive(Eq,
    Debug
    )

    ArtifactEncodeError

    pub suberror ArtifactEncodeError {
    InvalidArtifactField(field~ : String, message~ : String)
    } derive(Eq,
    Debug
    )

    Artifact

    pub(all) struct Artifact {
    manifest : CompatibilityManifest
    imports : Array[ImportIdentity]
    functions : Array[FunctionCode]
    } derive(Eq,
    Debug
    )

    Target-portable ordinary data contained in one Cwasm file or cache entry.

    CallBinding

    pub(all) enum CallBinding {
    StableEntry
    DirectBody
    } derive(Eq,
    Debug
    )

    Binding policy for internal direct and tail calls.

    CodeModel

    pub(all) enum CodeModel {
    Small
    Large
    } derive(Eq,
    Debug
    )

    Addressing range selected by target emission.

    CompatibilityManifest

    pub(all) struct CompatibilityManifest {
    format_version : Int
    target : TargetSpec
    required_cpu_features : Array[CpuFeature]
    jit_abi_version : Int
    codegen_revision : String
    module_identity : ModuleIdentity
    policy : CompilationPolicy
    } derive(Eq,
    Debug
    )

    Complete compatibility contract checked before code-object verification.

    Every field matches exactly except required_cpu_features, for which the installing host may provide a strict superset.

    CompilationPolicy

    pub(all) struct CompilationPolicy {
    optimization_level : OptimizationLevel
    code_model : CodeModel
    call_binding : CallBinding
    cancellation_safepoints : Bool
    debug_info : Bool
    } derive(Eq,
    Debug
    )

    Compilation choices that change generated code or its runtime contract.

    CpuFeature

    pub(all) struct CpuFeature {
    name : String
    } derive(Eq,
    Debug
    )

    A target CPU feature required by every function in the artifact.

    Names are stable wire identities. Compatibility validation rejects names that are not known for TargetSpec::architecture; it never guesses a fallback feature.

    DecodeLimits

    pub(all) struct DecodeLimits {
    max_artifact_bytes : Int
    max_imports : Int
    max_functions : Int
    max_cpu_features : Int
    max_string_bytes : Int
    max_signature_values : Int
    max_code_bytes_per_function : Int
    max_total_code_bytes : Int
    max_relocations_per_function : Int
    max_sources_per_function : Int
    max_traps_per_function : Int
    max_safepoints_per_function : Int
    max_unwind_directives_per_function : Int
    max_roots_per_safepoint : Int
    } derive(Eq,
    Debug
    )

    Resource limits applied before allocating variable-length artifact data.

    DecodeLimits::default

    fn DecodeLimits::default() -> DecodeLimits

    Digest

    pub(all) struct Digest {
    bytes : Bytes
    } derive(Eq)

    Content digest used for source-module and semantic-feature identity.

    The Cwasm codec accepts exactly 32 bytes and interprets them as SHA-256.

    FunctionCode

    Serializable ordinary-data form of one unlinked target code object.

    This record deliberately contains symbolic relocations and no resolved process or executable-memory address. The Wasmoon JIT root reconstructs and verifies UnlinkedCodeObject values from these fields before installation.

    FunctionIdentity

    pub(all) struct FunctionIdentity {
    function_index : Int
    symbol :
    CodeSymbol

    signature :
    Signature

    } derive(Eq,
    Debug
    )

    Stable identity and logical signature for a defined function.

    ImportIdentity

    pub(all) struct ImportIdentity {
    function_index : Int
    module_name : String
    function_name : String
    symbol :
    ExternalSymbol

    signature :
    Signature

    } derive(Eq,
    Debug
    )

    Stable identity and logical signature for an imported function.

    ModuleIdentity

    pub(all) struct ModuleIdentity {
    name : String
    source_digest : Digest
    semantic_features_digest : Digest
    } derive(Eq,
    Debug
    )

    Identity of the validated WebAssembly module that produced this artifact.

    OperatingSystemAbi

    pub(all) enum OperatingSystemAbi {
    MacOS
    LinuxGnu
    LinuxMusl
    WindowsMsvc
    } derive(Eq,
    Debug
    )

    Operating-system ABI assumed by generated code and unwind metadata.

    OptimizationLevel

    pub(all) enum OptimizationLevel {
    O0
    O1
    O2
    O3
    } derive(Eq,
    Debug
    )

    MilkIR optimization level used before target lowering.

    PointerWidth

    pub(all) enum PointerWidth {
    Bits64
    } derive(Eq,
    Debug
    )

    Pointer width assumed by the Wasmoon JIT ABI.

    TargetSpec

    pub(all) struct TargetSpec {
    architecture :
    Architecture

    operating_system_abi : OperatingSystemAbi
    endianness :
    Endianness

    pointer_width : PointerWidth
    } derive(Eq,
    Debug
    )

    Exact target and platform contract for the persisted machine code.

    FORMAT_VERSION

    let FORMAT_VERSION : Int

    The first breaking Cwasm format after the legacy v8 representation.

    decode

    fn decode(data : Bytes, limits? : DecodeLimits) -> Artifact raise ArtifactDecodeError

    Decode untrusted v9 Cwasm bytes into ordinary artifact data.

    This function performs bounded structural decoding only. The native wasmoon_jit facade performs compatibility and code-object verification before installation.

    encode

    fn encode(artifact : Artifact) -> Bytes raise ArtifactEncodeError

    Encode one v9 Cwasm artifact without resolving symbolic relocations.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io