lua-users home
lua-l archive

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


Hallo,

On Thu, Jun 23, 2011 at 4:35 PM, David Given <dg@cowlark.com> wrote:
>
> Each top-level function is a C function. Each such function turns into a
> state machine which represents the flattened basic block graph which is
> the contents of the function. C functions call each other reentrantly,
> which means my state machines need to be able to call each other
> reentrantly. Trust me, I'm creating new state machines *very frequently*.
>

     Oh, I understand your point better now...

> Using goto, the overhead of a state machine is nil, as the state is
> encoded in the Lua program counter and locals are directly accessible
> without needing heap cells. Each C function turns into precisely on Lua
> function.
>

     ...But I still don't think your problem is caused by the locals,
because you need that state anyway, in one form or the other. Instead,
the memory usage is caused by the state functions themselves. One of
the aims of the Lua language is to have a fast, simple compiler, and
it cannot see that it does not need to create those internal closures
in this case. Other compilers can[1]. The fact that it's possible
doesn't help you though, because the Lua compiler won't change.

[1] - http://wingolog.org/archives/2009/08/10/goto-

-- 
-alex
http://www.artisancoder.com/