lua-users home
lua-l archive

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


Nothing like crossed posts :)

On 15-Dec-06, at 9:21 AM, Mike Pall wrote:

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.

Indeed. However, it's possible to handle 'break' by annotating the VM code with scope identifiers. The rule for a JMP is that the target must have the same scope-id or a parent scope-id; in the latter case, the JMP must be a BREAK if some local has been between the target and the source has been captured. Given the annotations, this is easy to verify in the byte-code loader, for example.

The annotations do add somewhat to the size of the compiled bytecode; in the implementation I did they add two bytes per opcode plus four bytes per scope (base, length, parent)