[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua Fun - a functional programming library for tracing JIT compiler
- From: Roman Tsisyk <roman@...>
- Date: Wed, 20 Nov 2013 23:40:05 +0400
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 . 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.
Roman Tsisyk <email@example.com>
http://tarantool.org/ - an efficient in-memory database and a Lua application server