lua-users home
lua-l archive

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


It was thus said that the Great Soni L. once stated:
> 
> On 23/06/15 03:45 PM, Sean Conner wrote:
> >   It appears that all one has to do is allocate a new global state, copy
> > all the fields, then set, say, strt, l_registry, mt and possibly seed
> > with new values.  The only thing that gives me pause though, is the GC
> > related fields, as the garbage collector might get confused as it
> > doesn't seem to be an easy way to share the GC between global states. 
> > So you either have to move the fields you want to override to the
> > lua_State, or make a global_global state to be able to share the GC
> > between global states.  I think the safest thing would be to move strt,
> > l_registry, mt and seed to lua_State (and all the code changes that
> > requires) as that might have the least impact code change wise, as well
> > as a minimal impact on performance (the GC still uses one pointer
> > dereference to get to its data rather than two).  On the downside,
> > lua_States will now take more memory.
> 
> I only want to move
> 
> struct Table *mt[LUA_NUMTAGS];  /* metatables for basic types */
> 
> and
> 
> TValue l_registry;
> 
> out of the global_State and into the lua_State.

  Well ... no one is stopping you.  Make sure to report back on how well it
works and any performance penalties there might be.

  Okay, sorry to sound so dimissive, but I think at some point, you have to
meet us halfway.  I'm pointing the way (there!) but it seems you expect
others to do the work for you (or rather, uncritically adapt your ideas).

  -spc (Again, have you considered writing an implementation of Lua in
	LuaJIT?)