Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

This section describes wasmz’s internal architecture for contributors.

Overview

┌─────────────────────────────────────────────────────────────┐
│                        Public API                            │
│  (root.zig - Engine, Module, Store, Instance, Linker)       │
└─────────────────────────────────────────────────────────────┘
                              │
┌─────────────────────────────────────────────────────────────┐
│                       wasmz Module                           │
│  (High-level API implementation)                             │
└─────────────────────────────────────────────────────────────┘
                              │
┌──────────────┬──────────────┼──────────────┬───────────────┐
│    Parser    │   Compiler   │      VM       │    WASI       │
│              │              │               │               │
│  Binary      │  Stack-to-   │  Interpreter  │  Preview 1    │
│  Parser      │  Register    │  Engine       │  Host         │
│              │  Compiler    │               │               │
└──────────────┴──────────────┴───────────────┴───────────────┘
                              │
┌─────────────────────────────────────────────────────────────┐
│                     Core Types                               │
│  (Value types, ref types, heap types, trap, etc.)           │
└─────────────────────────────────────────────────────────────┘

Pipeline

  1. Parse - Binary parser reads the WASM module
  2. Compile - Stack-to-register IR transformation
  3. Execute - VM interpreter runs compiled IR

Note: wasmz does not implement a validator. Use external tools like wasm-tools to validate WASM modules before execution.

Key Directories

DirectoryPurpose
src/core/Core data types (types, values, traps)
src/parser/WASM binary parser
src/compiler/IR generation and optimization
src/engine/Function type handling, config
src/vm/Virtual machine, GC heap
src/wasmz/High-level API implementation
src/wasi/WASI system interface
src/validator/Placeholder (not implemented)
src/libs/Vendored dependencies

Next Sections