bytecodealliance / bytecodealliance/wasmtime

Cranelift aarch64 backend: use constant pool to defer constant emission to the end, unless out of range

Open
#1,549 12 comments 0 reactions 0 assignees View on GitHub
cranelift cranelift:area:aarch64 cranelift:area:machinst enhancement
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

Currently, to avoid issues with (i) the PC-relative addressing range of `LDR`, and (ii) the fact that the constant pool needs to be relocatable, the aarch64 backend emits constants inline with code and branches around them. This is obviously suboptimal for code-density and branchiness reasons.

To handle the first issue, we should use the `ConstantPool` to collect constants, as the old backend does, and then modify our emission logic to defer constant emission to the end *unless* we're about to go out of range of pending constant references, in which case we emit a "constant island".

To handle the second issue, we need to emit constant-pool relocations.

It's still unclear how we can handle the intersection of these two, i.e., when constant references become out-of-range because the client relocates the constant pool further away. One known use case of the relocatable constant pool is for SpiderMonkey to insert its own epilogue into Wasm functions; there, at least, we can bound how much further away the constant pool will be, so perhaps we can just have a slightly-conservative limit for when we must emit a constant island.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.