[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (rc1) now available
 
- From: David Manura <dm.lua@...>
 
- Date: Thu, 24 Nov 2011 19:07:53 -0500
 
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 .