codegen: patch method calls on-demand via traps
we can determine the source of an invalid memory access via unix signal
handling. to do so, we write
> mov (Addr 0) eax ; 0x8905 0000 0000
which tries to access memory at address 0. upon first execution of this
instruction the signalhandler is called. there, we replace it with
> nop ; 0x90
> call <target> ; 0xe8 YYYY YYYY ; Y = target
at the moment, this just works with Fib.fib() (or other recursive methods)
as the <target> address is more or less hardcoded.
several TODOs:
- determine address of target method in a different way
- after a call, we have to throw away arguments of the call.
this is hardcoded now.