Orlandello, Luca
(2026)
An Ahead-of-Time and On-Device WebAssembly Compiler for Resource Constrained Devices.
[Laurea magistrale], Università di Bologna, Corso di Studio in
Informatica [LM-DM270]
Documenti full-text disponibili:
![[thumbnail of Thesis]](https://amslaurea.unibo.it/style/images/fileicons/application_pdf.png) |
Documento PDF (Thesis)
Disponibile con Licenza: Salvo eventuali più ampie autorizzazioni dell'autore, la tesi può essere liberamente consultata e può essere effettuato il salvataggio e la stampa di una copia per fini strettamente personali di studio, di ricerca e di insegnamento, con espresso divieto di qualunque utilizzo direttamente o indirettamente commerciale. Ogni altro diritto sul materiale è riservato
Download (742kB)
|
Abstract
Existing WebAssembly Ahead-of-Time compilers rely on heavyweight frameworks such as LLVM and require gigabytes of RAM, making on-device compilation on resource-constrained devices infeasible.
This thesis presents wasmc, a lightweight Ahead-of-Time compiler that translates WebAssembly modules into native 32-bit RISC-V machine code directly on the ESP32-C3 microcontroller (400 KB of RAM).
Key design decisions—function-at-a-time compilation, a memory efficient single pass control flow graph construction in static single assignment form adapted from Braun et al. [3], input proportional heap allocation, zero-copy WebAssembly module decoding, the deliberate omission of an intermediate representation optimizer (since WebAssembly modules are typically produced by optimizing compilers), and a back end implemented from scratch featuring linear scan register allocation, ABI enforcement, static single assignment form deconstruction, and naive macro expansion instruction selection—keep peak heap usage within a few kilobytes per function.
Benchmarks on ten programs show that wasmc compiles all of them directly on the device, with peak heap usage never exceeding 16.8 KB and compilation time never exceeding 26.6 ms.
The produced executables achieve 9.8x–24.2x speedups over the WebAssembly Micro Runtime interpreter.
A secondary contribution of this thesis is the first complete documentation of the WebAssembly Micro Runtime AOT executable file format by reverse engineering the WebAssembly Micro Runtime source code.
This documentation is complemented by readaot, an inspection utility analogous to readelf for AOT binaries.
These results demonstrate that full Ahead-of-Time compilation of WebAssembly modules on a resource-constrained microcontroller is practically feasible without sacrificing correctness or execution efficiency.
Abstract
Existing WebAssembly Ahead-of-Time compilers rely on heavyweight frameworks such as LLVM and require gigabytes of RAM, making on-device compilation on resource-constrained devices infeasible.
This thesis presents wasmc, a lightweight Ahead-of-Time compiler that translates WebAssembly modules into native 32-bit RISC-V machine code directly on the ESP32-C3 microcontroller (400 KB of RAM).
Key design decisions—function-at-a-time compilation, a memory efficient single pass control flow graph construction in static single assignment form adapted from Braun et al. [3], input proportional heap allocation, zero-copy WebAssembly module decoding, the deliberate omission of an intermediate representation optimizer (since WebAssembly modules are typically produced by optimizing compilers), and a back end implemented from scratch featuring linear scan register allocation, ABI enforcement, static single assignment form deconstruction, and naive macro expansion instruction selection—keep peak heap usage within a few kilobytes per function.
Benchmarks on ten programs show that wasmc compiles all of them directly on the device, with peak heap usage never exceeding 16.8 KB and compilation time never exceeding 26.6 ms.
The produced executables achieve 9.8x–24.2x speedups over the WebAssembly Micro Runtime interpreter.
A secondary contribution of this thesis is the first complete documentation of the WebAssembly Micro Runtime AOT executable file format by reverse engineering the WebAssembly Micro Runtime source code.
This documentation is complemented by readaot, an inspection utility analogous to readelf for AOT binaries.
These results demonstrate that full Ahead-of-Time compilation of WebAssembly modules on a resource-constrained microcontroller is practically feasible without sacrificing correctness or execution efficiency.
Tipologia del documento
Tesi di laurea
(Laurea magistrale)
Autore della tesi
Orlandello, Luca
Relatore della tesi
Correlatore della tesi
Scuola
Corso di studio
Indirizzo
CURRICULUM A: TECNICHE DEL SOFTWARE
Ordinamento Cds
DM270
Parole chiave
WebAssembly,Compiler,Ahead-of-Time,Resource-constrained device,Embedded device,On-device compilation,IoT,Compiler Internals
Data di discussione della Tesi
26 Marzo 2026
URI
Altri metadati
Tipologia del documento
Tesi di laurea
(NON SPECIFICATO)
Autore della tesi
Orlandello, Luca
Relatore della tesi
Correlatore della tesi
Scuola
Corso di studio
Indirizzo
CURRICULUM A: TECNICHE DEL SOFTWARE
Ordinamento Cds
DM270
Parole chiave
WebAssembly,Compiler,Ahead-of-Time,Resource-constrained device,Embedded device,On-device compilation,IoT,Compiler Internals
Data di discussione della Tesi
26 Marzo 2026
URI
Statistica sui download
Gestione del documento: