[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL
- From: Mike Pall <mikelu-1101@...>
- Date: Wed, 26 Jan 2011 15:51:29 +0100
David Given wrote:
> On 26/01/11 13:05, Mike Pall wrote:
> > Neither should be a problem for the LuaJIT FFI. The import stubs
> > are not needed and __stdcall is automatically detected. So just
> > omit any calling convention in the declaration and the FFI will
> > figure it out for you.
>
> Gosh --- how?
The LuaJIT interpreter employs an assembler helper to call
C functions via the FFI. It remembers the stack pointer before the
call and simply restores it after the call. This allows calling
both __cdecl and __stdcall functions from the same code.
If a difference between the stack pointers before and after the
call is detected, then it must have been a stdcall. This causes
the function declaration to be fixed up. The JIT compiler can
later use this info to inline the call with the correct calling
convention.
--Mike
- References:
- LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, malkia
- Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, CrazyButcher
- Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, Henk Boom
- Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, David Given
- Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, Mike Pall
- Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL, David Given