Stream: cranelift

Topic: Type agnostic Wasm register allocation for baseline JITs


view this post on Zulip Robin Freyler (Nov 28 2023 at 14:25):

I don't really know where to ask this or if this is even a genuinely good questions but here we go.
(Note: I am not a compiler expert and may therefore lack basic knowledge.)

In Wasm everything is typed as per Wasm validation. This means also local variables are typed and locals with different typed cannot share the same variable which makes sense with respect to Wasm validation.

A naive baseline JIT compiler or rewriting interpreter may simply allocate a virtual register per Wasm local variable. However, a register might fit different types of values and thus doesn't require this typed duplication on a technical level. (E.g. at least in wasmi registers fit any 64-bit Wasm type.)

So ideally we want to allocate registers based on their respective lifetimes instead of type.
Fast compilation requirements disallow SSA based IR.

Are there known techniques for dealing with allocation of virtual register slots that are applicable for singlepass JITs or rewriting interpreters optimized for fast compilation? Happy about links or papers or search hints. :)


Last updated: Oct 23 2024 at 20:03 UTC