[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modifying current execution line/opcode
- From: Mike Pall <mikelu-0612@...>
- Date: Fri, 15 Dec 2006 15:21:44 +0100
Hi,
Fabien wrote:
> On 12/15/06, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> >Does it take care of closing closures when jumping out of the scope of
> >a variable which is used by an inner function?
>
> By "local to a function", I really mean "in the very same function, not in a
> nested one". You can't jump out of a function even if it's an anonymous,
> local one, so you can't jump through a closure boundary, unless I missed
> something.
Umm, I guess you misunderstood Roberto. It's not about leaving a
closure. It's about leaving a scope (e.g. do ... end) which has
created a closure.
You need to add a CLOSE opcode before any JMP opcode leaving a
scope which has created a closure holding an upvalue which points
to a local variable inside of the scope. Just have a look at the
compilation of the break statement.
In your case you can subsume multiple CLOSE opcodes by the CLOSE
generated from leaving the outermost scope which holds an open
upvalue.
BTW: Adding arbitrary gotos may also lead to irreducible control
flow graphs. Which violates one of the nicest properties of Lua,
namely that all CFGs are reducible. This makes it much easier to
analyze and/or compile Lua programs.
So maybe you should warn users of metalua that their programs may
or may not execute properly with LuaJIT depending on what kind of
modifications they make to the bytecode. And a possible future
version may not digest standard bytecode at all ...
Bye,
Mike