[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuaJIT-2.0.0-beta8
- From: Benoit Germain <bnt.germain@...>
- Date: Fri, 24 Jun 2011 11:43:56 +0200
2011/6/24 Mike Pall <firstname.lastname@example.org>:
> Benoit Germain wrote:
>> But if it is not a C function, and it is not a Lua function, what is
>> it, and how can I copy it from one state to another?
> It's an internal assembler function. And no, you can't 'copy' it.
> In general it's not safe to assume you can copy C closures between
> different state, by just copying their addresses. They might hold
> on to state-specific upvalues or reference static data. Or other
> closures may depend on the exact identity of a closure.
For C static data there isn't much that I can do besides relying on
the user knowing what he is doing.
Upvalues are taken care of. Exact identity isn't preserved in Lanes
anyway since a lane is totally separate, everything is copied by
value. Therefore the identity of all complex values (closures, tables)
However, full userdata identity is preserved as long as the copied
userdata are implemented in a special way that creates a dependence
with the Lanes module. Thread-safety should be taken care of the this
userdata's implementation. Unknown userdata generate an error when
> The only portable solution would be to identify the internal
> function in one state and then pick the same function in another
> state, e.g. by using an inverted table in both states.
All right, but how can I do this when LuaJIT's lua_tocfunction returns
NULL for these functions? How can I differentiate them? Is there
anything else than a string "fast#NN" in the lua_Debug structure?