How silverlineframework/wasm-micro-runtime works
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