2. Knowing the range from two jit_prolog() calls, it can figure the range of a
function. Could even know about dead code, but probably better to not try
to be too much smart about jumps and jump targets, just slightly smart :-)
3. Most important, this linked list should have information about non relative
labels, so that it could even reallocate the buffer and adjust offsets. This
is
tricky, because to have it to work transparently, it would need to modify the
api, that is, instead of having a label as a "jit_insn *", it would need
something
more like:
jit_movi_p(&my_label, r0, pointer);
jit_bner_i(&my_other_label, r0, 0);
otherwise, if it resizes the buffer, with either allocate a new one and copy
contents, or try to extend with realloc or mremap, it may need to adjust
"pending" labels.
Just some ideas... This would also make it easier/safer to use the change
I did to adjust the stack alignment in i386/x86_64 by patching the immediate
to adjust %esp in the jit_prolog call, as it could figure out what routine it
did
jump to, but forward jumps to another function would still be tricky; the
problem
is that if it jumps to another function, and call another from there, if it
patches
the stack adjustment due to building a large frame, it will patch the adjustment
of the wrong function, same if it calls jit_allocai to have some %ebp relative
buffer, like is done for x87/sse conversion (but this one is mostly for testing,
maybe should always allocate the first 8 stack bytes for it, or just push/pop
always).