Implementation of transfers out of closures

Mark Mahieu mark at twistedbanana.demon.co.uk
Mon Jul 14 12:09:50 PDT 2008


On 14 Jul 2008, at 01:11, Neal Gafter wrote:
> I have the following design constraints:
> The "normal" case should be relatively fast. Specifically, there  
> should be no capturing of a stack trace when the transfer is  
> successful.
> The structure of the generated code should take advantage of  
> existing hotspot optimizations and enable new ones.
I've had a quick play with the code, using a very artificial and  
unfair recursive test designed to examine how well this technique  
performs.

On my machine, this test executes in around 250ms using normal return  
statements, and around 10000ms after being translated to use Jump and  
friends:

http://slm888.com/snippets/NormalReturn.java
http://slm888.com/snippets/JumpReturn.java

However, manually inlining the call to transfer() within the try  
block has a nice effect: the test completes in under 2200ms:

http://slm888.com/snippets/InlinedJumpReturn.java

Presumably this change is sufficient to trigger a particular hotspot  
optimisation which isn't performed in the non-inlined version, such  
as a straightforward branch to the code in the catch block.

Quite promising I think.


Regards,

Mark




More information about the closures-dev mailing list