Today, I'll be writing about the aegraph , or acyclic egraph , the data structure at the heart of Cranelift's mid-end optimizer. I introduced this approach in 2022 and, after a somewhat circuitous path involving one full rewrite, a number of interesting realizations and "patches" to the initial idea, various discussions with the wider e-graph community (including a talk ( slides ) at the…
Note: this post is also cross-posted to the Bytecode Alliance blog here . This is a blog post outlining the odyssey I recently took to implement the Wasm exception-handling proposal in Wasmtime , the open-source WebAssembly engine for which I'm a core team member/maintainer, and its Cranelift compiler backend. When first discussing this work, I made an off-the-cuff estimate in the…
This is the final post of a three-part series covering my work on "fast JS on Wasm"; the first post covered PBL, a portable interpreter that supports inline caches, the second post covered ahead-of-time compilation in general terms, and this post discusses how we actually build the ahead-of-time compiler backends. Please read the first two posts for useful context! In the last post, we covered how…
This is a continuation of my "fast JS on Wasm" series; the first post covered PBL, a portable interpreter that supports inline caches, this post adds ahead-of-time compilation, and the final post will discuss the details of that ahead-of-time compilation. Please read the first post first for useful context! The most popular programming language in the world, by a wide margin -- thanks to the…
The Rust programming language is best-known for its memory-related type system features that encode ownership and borrowing : these ensure memory safety (no dangling pointers), and also enforce a kind of "mutual exclusion" discipline that allows for provably safe parallelism. It's fantastic stuff; but it can also be utterly maddening when one attempts to twist the borrow checker in a…
For the past year, I have been hard at work trying to improve the performance of the SpiderMonkey JavaScript engine when compiled as a WebAssembly module. For server-side applications that use WebAssembly (and WASI , its "system" layer) as a software distribution and sandboxing technology with significant exciting potential , this is an important enabling technology: it allows existing software…
Today I'm going to be writing about ISLE , or the "instruction selection/lowering expressions" domain-specific language ( DSL ), which over the past year we have designed, improved, and fully adopted in the Cranelift compiler project. ISLE is now used to express both our instruction-lowering patterns for each of four target architectures, and also machine-independent optimizing rewrites.…
This post is the fourth part of a three-part series 1 describing work that I have been doing to improve the Cranelift compiler. In this post, I'll describe the work that went into regalloc2 , a new register allocator I developed over the past year. The allocator started as an effort to port IonMonkey's register allocator to Rust and a standalone form usable by Cranelift ("how hard could…
This post is the last in a three-part series about Cranelift . In the first post , I covered overall context and the instruction-selection problem; in the second post , I took a deep dive into compiler performance via careful algorithmic design. In this post, I want to dive into how we engineer for and work to ensure correctness , which is perhaps the most important aspect of any compiler project.…
This post is the second in a three-part series about Cranelift . In the first post , I described the context around Cranelift and our project to replace its backend code-generation infrastructure, and detailed the instruction-selection problem and how we solve it. The remaining two posts will be deep-dives into some interesting engineering problems. In this post, I want to dive into the compiler…
This post is the first in a three-part series about my recent work on Cranelift as part of my day job at Mozilla. In this first post, I will set some context and describe the instruction selection problem. In particular, I'll talk about a revamp to the instruction selector and backend framework in general that we've been working on for the last nine months or so. This work has been…
Hello, and welcome to blog.cfallin ! I've thought for a while that it might be nice to share, occasionally, some thoughts on whatever technical tidbits interest me. This blog will likely be home to assorted ramblings on compilers, runtimes, and the like; you can find a bit more about my background at 'About' . My first post, coming soon, will be about the new compiler backend…