Project Lambda: Java Language Specification draft

Rémi Forax forax at univ-mlv.fr
Fri Jan 29 02:03:10 PST 2010


Le 29/01/2010 06:16, Neal Gafter a écrit :
> On Thu, Jan 28, 2010 at 4:05 PM, Rémi Forax<forax at univ-mlv.fr>  wrote:
>> Le 28/01/2010 20:11, Neal Gafter a écrit :
>>> By the way, looping through an ArrayList using indexing happens to be
>>> faster than looping through using an iterator because the latter
>>> requires two method calls per element, while the former requires only
>>> one.  It's not hard to verify this experimentally.
>> This not true if the code is hot.
> Have you run experiments to back up that assertion?

Yes,
I had done a similar experiment one week ago when testing method handles.
I've updated it this morning to remove method handle things.
You can find the two codes and the generated assembler codes is here:
http://cr.openjdk.java.net/~forax/assembly-loop/loop-assembly.zip

Look for a method named __test__  and takes the second one,
the first one is generated before Hotspot decides to inline iterator's 
methods.

The method increment do parsing/toString to avoid to be inlined,
__test__ is not inlined too.
I've also tried to use the Iterator of a LinkedList during the warm-up
to avoid too easy code for a CHA analysis but it doesn't change the 
generated code.

Rémi



More information about the coin-dev mailing list