lua-users home
lua-l archive

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


Graham Wakefield wrote:
> So, another question: Am I right in thinking that it would be feasible  
> to run multiple independent lua_States in different threads (along the  
> lines of LuaRings)?
> That is, can the JIT engine itself be instantiated multiple times, with 
> each instance fully encapsulated within a global lua_State (i.e. no 
> statics)?

Yes, this works fine. It uses *zero* static writable memory. I've
had an eye on good embeddability. No use of virtual memory tricks
or process-wide OS stuff either (good luck embedding Java ;-)).

But it won't necessarily be efficient. If you open 10 global
states and run the same scripts, the bytecode is stored 10x,
compiled 10x, the machine code is stored 10x etc. ...

You may have to lower some parameters to get this to scale to a
larger number of global states. E.g. -Osizemcode=16 or 8, if the
machine code still fits in there (pointless for Windows, since it
enforces a 64K granularity).

That said, globally sharing bytecode/machine code would be nice,
but is very difficult. I think that some kind of support for
native threads in the same global state would be a better idea
(but that's still hard).

--Mike