[Haskell-cafe] Return stack buffer vs Haskell compilers
fw at deneb.enyo.de
Sun Nov 28 15:52:14 CET 2010
Are there any Haskell compilers which use a calling convention which
is friendly to return stack buffers found in many modern CPUs? Such a
calling convention uses CALL/RET pairs for function calls. Tail calls
are implemented with JMP and may require shuffling the stack,
including the return address, if the number of arguments passed on the
stack differs between tail caller and callee.
Such an approach means that the CPU can use the return stack buffer,
which allows exact prediction of the jump target of the RET
instruction (as long as the return stack buffer does not overflow).
In contrast, if an indirect jump is used to implement RET, it enters
the same prediction logic as any other indirect call, which is less
precise and affects predicition of other indirect calls.
This is especially important on the Intel Atom and VIA Nano CPUs,
which are reported (Agner Fog, "The microarchitecture of Intel, AMD
and VIA CPUs", last updated 2010-09-25) to have a return stack buffer,
but a very simple indirect branch predictor which uses the last target
as the next predicted target.
More information about the Haskell-Cafe