bjorn3 opened Issue #2824:
The old backends used the
CodeSink
to emit instruction bytes and relocations as they were being generated. The machinst backends store everything in aMachBuffer
before finally emitting the compiled code one byte at a time to theCodeSink
. Unlike a plainmemcpy
this is not easily vectorizable. In addition there are a lot of branches to check if the current instruction has a relocation, can trap or is a call site.I propose that either the
CodeSink
interface is removed in favor of giving the embedder direct access to theMachBufferFinalized
or theCodeSink
interface will get aput_bytes
function that allows copying all bytes at the same time in combination with explicit offsets for thereloc_external
,trap
andadd_call_site
methods.
cfallin commented on Issue #2824:
Yes, agreed, this would be great!
We're somewhat constrained until we eventually remove the old backend infrastructure (which is on my TODO list but not my very highest priority at the moment). Once that happens, I think we'll want to look over the codegen-crate interfaces generally to see if there are any other possible efficiency improvements like this one.
Last updated: Nov 22 2024 at 16:03 UTC