[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can't pass a struct by value to LuaJIT FFI varargs function?
- From: Mike Pall <mikelu-1101@...>
- Date: Mon, 31 Jan 2011 13:56:50 +0100
David Greenspan wrote:
> Now there's just the callback situation -- I thought Objective-C's
> message-passing would insulate me, that I could have one C function that
> would be the implementation of every selector I need to implement, and I
> could do my own dispatching. However, it seems that calling conventions
> still apply through the msgSend wrapper, so I'm not sure how to avoid having
> multiple C forwarders for different function types.
That's why msgSend is written in assembler. All argument registers
are preserved and the stack is left untouched before it tail-calls
the receiver. It only needs variants for FP returns or struct
returns, depending on the target platform. Have a look at the
sources -- I guess you could do something similar.
> Perhaps I just have to
> wait for FFI to get callbacks to clean up that part of my code.
Probably. But I still have no good solution that avoids keeping
callbacks alive forever (slowly chewing up memory) without
resorting to manual lifetime management.
--Mike