lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Florian Weimer wrote:
> * Mike Pall:
> > tl;dr: Just pass a Lua function to a C function taking a callback
> > argument and the FFI will do all the magic in the background.
> 
> I'm trying to figure out what made this feat suddenly possible.

Magic, of course. And careful planning.

> I was
> under the impression that it wouldn't be possible introduce, say,
> allocations into traces which were deemed allocation-free before.

Umm? 1) Why not? 2) I do not see any relation to callbacks.

> By the way, you could probably use stubs of the form
> 
>   CALL vm_ffi_callback
>   RET
> 
> and derive the slot and the address of the state pointer from the
> return address on the stack within vm_ffi_callback.  This would allow
> you to squeeze a few more stubs into that memory area.

No. That would take 6 bytes on x86 (and won't always work on x64).
My stubs need only 4.34375 bytes on x86. :-)

--Mike