I have just realized that our current closure record passing strategy is
incredibly stupid. The current mechanism is:

1. Call proceeds to a heap-allocated ASM stub that loads the closure record
pointer into some transient register. The key requirements for this register
are that it is call clobbered and not used in the calling convention or the
function prologue.
2. Asm stub transfers to a C stub that picks up the closure record from the
magic register, stores it to a local, and forwards the call in such a way as
to make the closure record explicit. Basically this is implementing "poor
man's FFI".

What I just now realized is that the C stub is completely unnecessary. If we
can pick up the magic register from inside the C stub, then we can certainly
pick it up just as well from inside the target procedure. For static calls
we can implement a short ASM wrapper that puts the environment into the
expected place.

How silly of me not to have noticed this possibility.

shap
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to