bytecodealliance / bytecodealliance/wasmtime
Make use of pinned register for vmctx or heap base in wasmtime?
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
We currently have special support for exactly one "pinned register" in CLIF, and this is used by the SpiderMonkey bindings to Cranelift in order to ensure that the VM context pointer always remains accessible in a register. However, the Wasmtime code translation does not make use of the pinned register, or provide register-allocator hints in general, to allow the backend to handle the VM-context pointer or heap base pointer in any specially-optimized way.
I was reminded in a recent conversation of this, and it is still an open opportunity. We could either use the pinned register as-is (with `get_pinned_reg` and `set_pinned_reg` instructions) or, perhaps once we've moved over to regalloc2, develop a more general sort of metadata/hint that indicates that certain values are long-lived. (Something like the `register` keyword that used to mean something to C compilers.) Perhaps the regalloc heuristics are good enough to work this out in many cases, but perhaps they aren't, and we can save some work; we should study the issue to be sure.
This might make a good starter issue for someone looking to get into the codegen/backends, and can range from relatively simple (use existing pinned-reg infra) to more general; I'm happy to help describe more detail if so!
Contributor guide
Assessment
This issue has not been assessed yet.