Clojure 'to the metal'

2 views
Skip to first unread message

cliffc

unread,
Oct 6, 2008, 11:44:36 AM10/6/08
to Clojure, richh...@gmail.com
> Hi Cliff,
> It was great meeting you at the JVM Summit - I learned a lot, thanks!
> I know the test is over, but wanted to get you a version of your simple test that demonstrates Clojure's ability to get to the metal on primitive numerics when given type hints.
> Attached is a new clojure.jar and a simple.clj
> Run with:
> java -server -cp clojure.jar clojure.lang.Script simple.clj
> Regards,
> Rich

Hi Rich - nice meeting you too - and Clojure is very impressive. Here
is 1 copy of the inner loop HotSpot generates on Azul, the full thing
is unrolled 32 times.
R6 - the original 'i' at the start of all 32 copies
R0 - 'sum' for iteration#2
R5 - large masking constant 0x3FFFFFFF
R1 - 'sum' for iteration#3

0.07% 31 0x131870c0 add4 r9, r6, 2 // r9 = i+2 - this is the 2nd
unrolled body
0.10% 45 0x131870c4 xor r2, r0, r9 // r2 = sum ^ (i+2)
0.09% 41 0x131870c8 beq r9, 0, 0x01318750c // div-by-zero check
0.15% 66 0x131870cc div4 r7, r2, r9 // r7 = (sum^(i+2)/(i+2)
2.33% 1,028 0x131870d0 add4 r3, r7, r0 // r3 = sum + (sum^i)/i
0.07% 30 0x131870d4 xor r2, r3, r0 // ??? - guess overflow check for
prior sum
0.05% 22 0x131870d8 blt0 r2, 0x0131874f8 // ??? - guess overflow check
for prior sum
0.07% 30 0x131870dc and r1, r3, r5 // sum = (....) & 0x3FFFFFFF


Cliff
Reply all
Reply to author
Forward
0 new messages