Gaurav Gahlot
Gaurav Gahlot is a Software Engineer passionate about building low-level systems, Rust, and Cloud Native technologies. As part of a journey to better understand WebAssembly, Gaurav built Whisk - a minimal runtime to run Wasm modules., and is excited to share the lessons learned. He also shares his insights and expertise on his blog - https://gauravgahlot.in
Acquia
Job title –Senior Software Engineer
Session
03-01
15:00
35min
Building Whisk: A Minimal WebAssembly Runtime from Scratch
Gaurav Gahlot
- Introduction
- What is WebAssembly and why build your own runtime?
- Introducing Whisk: The goal, the constraints, and the motivation.
- Laying the Foundation
- Understanding the structure of Wasm modules (sections and LEB128 decoding).
- Implementing a parser.
- Key Learning - Binary parsing teaches you to appreciate efficient encoding and data representation.
- Executing Functions
- Implementing an interpreter for Wasm opcodes.
- Building a stack-based virtual machine.
- Handling control flow (e.g.,
return
,call
). - Supporting arithmetic operations and simple control flow.
- Key Learning - Small, incremental steps are crucial to avoid being overwhelmed by complexity.
- Adding WASI Support
- Parsing the Imports section to handle external functions.
- Implementing minimal WASI functions (e.g.,
fd_write
) to support basic I/O. - Mapping imports to host functions dynamically.
- Key Learning - Understanding WASI deepens your appreciation for portable system interfaces.
- Running Real-World Programs
- Parsing Exports to locate and execute the _start function.
- Compiling and running a Rust program with Whisk.
- Demo: Executing hello.wasm with Whisk.
- Key Learning - Running a non-trivial program validates your runtime and boosts your confidence.
- Key Takeaways
- Debugging Wasm modules without existing tooling.
- Implementing stack management and function call mechanics.
- Balancing minimalism with extensibility.
- How Whisk deepened my understanding of WebAssembly.
- Inspiration for the audience to explore Wasm internals.
- Open the floor for questions and discussions.
Open Source Innovation and Leadership
Shivneri Room (Chanakya Building / School of Business)