lua-users home
lua-l archive

Re[2]: [ANN] Lua Fun - a functional programming library for tracing JIT compiler

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


I'm sorry, there was a type:
 n = 100
 ans = sum(map(function(x) return x^2 end, take(n, tabulate(math.sin)))) -- was sin(x)
Wednesday, November 20, 2013 11:05 AM -08:00 from :
> > sum(map(function(x) return x^2 end, take(n, tabulate(math.sin(x)))))
> 
> Wow, LuaJIT translates that to one loop? amazing! Does it implement
> stream fusion?
> 
The magic is done by the tracing compiler [1]. LuaJIT can trace entire loops
and optimize them wholly, instead of optimizing single functions.
The compiler unrolls compositions of functions, eliminates high-order functions
replaces recursions with loops and makes other sophisticated optimizations.
I have never seen such powerful JIT in any language. Seriously.
I think Mike Pall can provide more details.
The source code is fully compatibly with Lua 5.1. However,
this library was especially optimized to use tracing JIT at its full strength.
[1] http://en.wikipedia.org/wiki/Tracing_just-in-time_compilation
--
WBR,
 Roman Tsisyk <roman@tarantool.org>
 http://tarantool.org/ - an efficient in-memory database and a Lua application server

AltStyle によって変換されたページ (->オリジナル) /