lua-users home
lua-l archive

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


On Thu, Nov 24, 2011 at 11:08 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> - optimization for |if cond then goto|

It is now the case that these two chunks generate identical bytecode
(including debuginfo):

  local x = 1
  while not(x > 1e8) do
    x = x + 1
  end

  local x = 1
  ::a:: if x > 1e8 then goto e end
  x = x + 1
  goto a; ::e::

However, the above are a fraction of the speed of the equivalent `for`
loop, which generates FORPREP/FORLOOP byte codes.  That's something to
keep in mind for code generation.  Other bytecode examples are on
http://lua-users.org/wiki/GotoStatement .