#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, 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
    )

    ArtifactDecodeError::equal

    ArtifactDecodeError::not_equal

    ArtifactEncodeError

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

    ArtifactEncodeError::equal

    ArtifactEncodeError::not_equal

    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.

    Artifact::equal

    fn Artifact::equal(Artifact, Artifact) -> Bool

    Artifact::not_equal

    fn Artifact::not_equal(x : Artifact, y : Artifact) -> Bool

    Artifact::to_repr

    CallBinding

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

    Binding policy for internal direct and tail calls.

    CallBinding::equal

    fn CallBinding::equal(CallBinding, CallBinding) -> Bool

    CallBinding::not_equal

    fn CallBinding::not_equal(x : CallBinding, y : CallBinding) -> Bool

    CodeModel

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

    Addressing range selected by target emission.

    CodeModel::equal

    fn CodeModel::equal(CodeModel, CodeModel) -> Bool

    CodeModel::not_equal

    fn CodeModel::not_equal(x : CodeModel, y : CodeModel) -> Bool

    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.

    CompatibilityManifest::equal

    CompatibilityManifest::not_equal

    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.

    CompilationPolicy::equal

    CompilationPolicy::not_equal

    fn CompilationPolicy::not_equal(x : CompilationPolicy, y : CompilationPolicy) -> Bool

    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.

    CpuFeature::equal

    fn CpuFeature::equal(CpuFeature, CpuFeature) -> Bool

    CpuFeature::not_equal

    fn CpuFeature::not_equal(x : CpuFeature, y : CpuFeature) -> Bool

    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

    DecodeLimits::equal

    DecodeLimits::not_equal

    fn DecodeLimits::not_equal(x : DecodeLimits, y : DecodeLimits) -> Bool

    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.

    Digest::equal

    fn Digest::equal(Digest, Digest) -> Bool

    Digest::not_equal

    fn Digest::not_equal(x : Digest, y : Digest) -> Bool

    Digest::to_repr

    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.

    FunctionCode::equal

    FunctionCode::not_equal

    fn FunctionCode::not_equal(x : FunctionCode, y : FunctionCode) -> Bool

    FunctionIdentity

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

    signature :
    Signature

    } derive(Eq,
    Debug
    )

    Stable identity and logical signature for a defined function.

    FunctionIdentity::equal

    FunctionIdentity::not_equal

    fn FunctionIdentity::not_equal(x : FunctionIdentity, y : FunctionIdentity) -> Bool

    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.

    ImportIdentity::equal

    ImportIdentity::not_equal

    fn ImportIdentity::not_equal(x : ImportIdentity, y : ImportIdentity) -> Bool

    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.

    ModuleIdentity::equal

    ModuleIdentity::not_equal

    fn ModuleIdentity::not_equal(x : ModuleIdentity, y : ModuleIdentity) -> Bool

    OperatingSystemAbi

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

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

    OperatingSystemAbi::equal

    OperatingSystemAbi::not_equal

    OptimizationLevel

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

    MilkIR optimization level used before target lowering.

    OptimizationLevel::equal

    OptimizationLevel::not_equal

    fn OptimizationLevel::not_equal(x : OptimizationLevel, y : OptimizationLevel) -> Bool

    PointerWidth

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

    Pointer width assumed by the Wasmoon JIT ABI.

    PointerWidth::equal

    PointerWidth::not_equal

    fn PointerWidth::not_equal(x : PointerWidth, y : PointerWidth) -> Bool

    TargetSpec

    Exact target and platform contract for the persisted machine code.

    TargetSpec::equal

    fn TargetSpec::equal(TargetSpec, TargetSpec) -> Bool

    TargetSpec::not_equal

    fn TargetSpec::not_equal(x : TargetSpec, y : TargetSpec) -> Bool

    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.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io