Next: Immediate values, Previous: Common features, Up: Standard macros
Delay slot scheduling is obtained by clients through the
jit_delay macro. However this macro is not to be defined
in the platform-independent layer, because gnu lightning provides
a common definition in core-common.h.
Instead, the platform-independent layer must define another macro,
called jit_fill_delay_after, which has to exchange the
instruction to be scheduled in the delay slot with the branch
instruction. The only parameter accepted by the macro is a call
to a branch macro, which must be expanded exactly once by
jit_fill_delay_after. The client must be able to pass the
return value of jit_fill_delay_after to jit_patch_at.
There are two possible approaches that can be used in
jit_fill_delay_after. They are summarized in the following
pictures:
jit_fill_delay_after.
before | after
---------------------------------+-----------------------------
... |
<would-be delay instruction> | <branch instruction>
<branch instruction> | <delay instruction>
NOP | <--- _jit.pc
<--- _jit.pc |
jit_fill_delay_after toggles the bit:
before | after
---------------------------------+-----------------------------
... |
<would-be delay instruction> | <branch instruction>
<branch with annulled delay> | <delay instruction>
<--- _jit.pc | <--- _jit.pc
Don't forget that you can take advantage of delay slots in the
implementation of boolean instructions such as le or gt.