# silverlineframework/wasm-micro-runtime architecture

> Architecture diagram of the GitHub repository silverlineframework/wasm-micro-runtime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/silverlineframework/wasm-micro-runtime
- Repository: https://github.com/silverlineframework/wasm-micro-runtime

## Overview

##### Project Type and Purpose
- WAMR is an open-source, embeddable WebAssembly runtime and toolchain.
- It comprises four primary deliverables:
- VMcore (“core/iwasm”): the runtime library with interpreter, AOT and JIT engines.
- CLI (“product-mini/iwasm”): a standalone executable for loading WASM modules.
- AOT Compiler (“wamr-compiler/wamrc”): translates Wasm binaries into native AOT modules.
- Ecosystem: language bindings, SDK, test-tools, samples, CI pipelines.

##### High-Level File-Structure Analysis
- Top-level modules:
- core/…: C source for interpreter, AOT, fast-JIT, LLVM JIT, GC, platform abstraction.
- product-mini/: minimal demo CLI and platform ports (Linux, SGX, Zephyr, etc.).
- wamr-compiler/: AOT compiler sources and build scripts.
- language-bindings/: Go, Python, Rust wrappers around the C API.
- wamr-sdk/: prebuilt sysroots and CMake toolchain files for app developers.
- test-tools/: VSCode IDE extension, wasm toolchain Docker images, utility scripts.
- samples/, tests/: usage examples and benchmark/unit test suites.
- CI and build: .github/workflows/*, build-scripts/, SConscript/CMakeLists.txt orchestrate multi-platform builds.

##### Key Insights from README
- Four pillars: VMcore, iwasm CLI, wamrc AOT compiler, developer-facing tools.
- Execution modes: interpreter, AoT, Fast JIT, LLVM JIT with tier-up.
- Embedding API: wasm_c_api and native export hooks.
- Platform abstraction layer under core/common and core/shared/platform.
- Support for WASI, builtin libc, pthreads, wasi-threads, socket, SGX, embedded OS.

a. Main Components
1. Wasm App (input .wasm)
2. wamrc AOT Compiler
3. VMcore
- Interpreter
- Fast-JIT
- LLVM-JIT
- GC, Memory Manager
- Platform Abstraction Layer
- WASI & libc modules
4. iwasm CLI (invokes VMcore)
5. Language Bindings (Go/Python/Rust wrappers calling C API)
6. SDK (sysroot + CMake toolchains)
7. Test Tools & IDE Extension
8. External Services & OS/Hardware Platforms
b. Relationships
- wasm_app → wamrc → AOT Module (.aot)
- AOT Module / .wasm → VMcore
- iwasm CLI → VMcore API → Platform Abstraction (OS syscalls)
- Language Bindings → embed VMcore via C API → host application
- SDK toolchain and CMake files → embed and build host + VMcore
- Test-tools & IDE → orchestrate build/debug workflows → underlying Docker/CI
c. Architectural Patterns
- Layered modular architecture: separation of core execution engines, platform layer, embedding API, and tooling.
- Plugin-like engine selection: runtime chooses interpreter, Fast-JIT, or LLVM-JIT dynamically.
- Platform abstraction: core/shared/platform provides uniform interfaces for POSIX, SGX, RTOS.
- Declarative build: SCons/CMake driving multi-target cross-compilation.
d. Technology Highlights
- C/CMake/SCons for build system
- Asm for native trampolines (core/iwasm/common/arch)
- LLVM ORC for JIT tier
- Python/TypeScript for IDE extension
- Docker for reproducible CI/images

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top-level inputs
    WasmApp["Wasm App (.wasm)"]:::external
    WasmApp -->|"input"| Wamrc

    %% Compiler pipeline
    Wamrc["wamrc AOT Compiler"]:::tooling
    click Wamrc "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/wamr-compiler"
    Wamrc -->|"produces .aot"| AOTModule["AOT Module (.aot)"]:::runtime

    %% VMcore with engines and modules
    subgraph "VMcore (Runtime Library)" 
        direction TB
        VMcoreCore["core/iwasm"]:::runtime
        click VMcoreCore "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/core/iwasm"
        subgraph Engines
            direction TB
            Interpreter["Interpreter"]:::runtime
            click Interpreter "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/core/iwasm/interpreter"
            FastJIT["Fast-JIT"]:::runtime
            click FastJIT "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/core/iwasm/fast-jit"
            LLVMJIT["LLVM-JIT"]:::runtime
            click LLVMJIT "https://github.com/silverlineframework/wasm-micro-runtime/blob/main/core/iwasm/compilation/aot_llvm_extra.cpp"
            click LLVMJIT "https://github.com/silverlineframework/wasm-micro-runtime/blob/main/core/iwasm/compilation/aot_orc_extra.cpp"
        end
        GC["GC & Memory Manager"]:::runtime
        click GC "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/core/iwasm/common/gc"
        Platform["Platform Abstraction Layer"]:::runtime
        click Platform "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/core/shared/platform"
        WASIMod["WASI & libc modules"]:::runtime
    end

    %% Connections into VMcore
    WasmApp -->|".wasm"| VMcoreCore
    AOTModule -->|"loads .aot"| VMcoreCore

    %% CLI invocation
    IWASM["iwasm CLI"]:::tooling
    click IWASM "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/product-mini"
    IWASM -->|"invoke VMcore API"| VMcoreCore

    %% Embedding layers
    subgraph "Embedding & SDK"
        direction TB
        CAPI["Embedding C API"]:::embed
        click CAPI "https://github.com/silverlineframework/wasm-micro-runtime/blob/main/core/iwasm/common/wasm_c_api.c"
        click CAPI "https://github.com/silverlineframework/wasm-micro-runtime/blob/main/core/iwasm/include/wasm_c_api.h"
        GoBind["Go Binding"]:::embed
        click GoBind "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/language-bindings/go"
        PyBind["Python Binding"]:::embed
        click PyBind "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/language-bindings/python"
        RustBind["Rust Binding"]:::embed
        click RustBind "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/language-bindings/rust"
        SDK["SDK (sysroot & CMake)"]:::embed
        click SDK "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/wamr-sdk"
    end
    CAPI -->|"embed VMcore"| VMcoreCore
    GoBind -->|"embed via C API"| VMcoreCore
    PyBind -->|"embed via C API"| VMcoreCore
    RustBind -->|"embed via C API"| VMcoreCore
    SDK -->|"links sysroot"| VMcoreCore

    %% Tools and CI
    TestTools["Test Tools & IDE"]:::tooling
    click TestTools "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/test-tools"
    CI["CI Pipelines"]:::tooling
    click CI "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/.github/workflows"
    BuildSys["Build Scripts (SCons/CMake)"]:::tooling
    click BuildSys "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/build-scripts"
    click BuildSys "https://github.com/silverlineframework/wasm-micro-runtime/tree/main/SConscript"
    click BuildSys "https://github.com/silverlineframework/wasm-micro-runtime/blob/main/CMakeLists.txt"
    TestTools -->|"orchestrate build/debug"| CI
    CI -->|"invoke builds"| BuildSys

    %% External Platforms
    OSHardware["OS/Hardware Platforms"]:::external
    OSHardware -->|"syscalls"| Platform

    %% Styles
    classDef runtime fill:#a0c4ff,stroke:#333,stroke-width:1px
    classDef tooling fill:#caffbf,stroke:#333,stroke-width:1px
    classDef embed fill:#ffd6a5,stroke:#333,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#333,stroke-width:1px
```
