OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

Function alignment optimization

Open LADSoft opened this issue 5 years ago • 1 comments

on x86, aligning functions on 16-byte boundaries can improve the speed. Make this a speed improvement.

LADSoft avatar Oct 29 '20 00:10 LADSoft

A way to do this would be in the linker location, when creating the binary when we have a function what we do is we take the current location, mod 16, then add a variable length NOP, we could in theory use a 9-byte and a 6 byte nop for functions that just start on a boundary, or, depending on whether the code is "hot" or "cold" reorder where the functions appear to add the least number of nops to the code and thus cutting down code size. For reference on the multi-byte nops, 1345 of the current intel manuals has information.

chuggafan avatar Dec 13 '20 19:12 chuggafan