RFR: 8215995: Add specialized toArray methods to immutable collections

Claes Redestad claes.redestad at oracle.com
Wed Jan 2 19:16:46 UTC 2019

Hi Martin,

On 2019-01-02 20:00, Martin Buchholz wrote:
> Looks good to me.


> Can you explain why there are two identical test methods get and get2 ?

It was to provoke the expected level of mono-, bi- and megamorphicness
at each callsite depending on the method under test, while ensuring the
different benchmarks doesn't pollute eachother. I should add a comment
about that...

> I was surprised by the use of SALT in SetN. I'm guessing you could 
> improve SetN by adapting the tricky circular array traversal code from 
> ArrayDeque.
> I'm not convinced that the extra non-determinism from negative SALT 
> pulls its weight.

This is one of Stuart's designs - the goal being to avoid
situations where tests and production code create an unintended
dependency on the iteration order - giving us more freedom to change
hash algorithm etc. Since the SALT is calculated only once the untaken
paths should be DCE'd, so we're not paying any real cost for this.

(I'm guilty of moving the use of SALT from creation time to the
iterators, though, to at least ensure consistent run-to-run memory
layout of SetN/MapN so that we can archive these collections)


> On Wed, Jan 2, 2019 at 10:12 AM Claes Redestad 

More information about the core-libs-dev mailing list