lua-users home
lua-l archive

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


On Wed, 28 Nov 2001, Edgar Toernig wrote:

> Roberto Ierusalimschy wrote:
> >
> > Any sugestions how to correct that?
>
> First idea: create struct UpVal during OP_CLOSURE, these are linked
> into lua_State, struct UpVal performs an additional indirection.
>
> [...]

Another solution is to "decompose" the upval address into a base and an
index. When the upval is the in the stack, the base is the stack base; when
it is closed, the index is 0 (and the base is the struct UpVal address). We
keep "open" closures ordered by indices, in one single list for all stacks
(that is, in G). When we "close" a piece of stack, it is easy to check
which upvalues refer to this particular stack (comparing their bases).

-- Roberto