akirilov-arm labeled issue #1549:
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.
Last updated: Nov 22 2024 at 17:03 UTC