[concurrency-interest] CAS using a MethodHandle

√iktor Ҡlang viktor.klang at gmail.com
Mon Dec 19 14:35:00 EST 2011


Excellent!
On Dec 19, 2011 8:19 PM, "Doug Lea" <dl at cs.oswego.edu> wrote:

> On 12/19/11 13:28, Rémi Forax wrote:
>
>> Hi all,
>> Some time ago, I said that we should try to use a MethodHandle instead of
>> an
>> Atomic*FieldUpdater and let the VM inline the method handle so there
>> should be
>> no cost (or a little one) compared to directly calling
>> unsafe.compareAndSwapObject.
>>
>> The following code does exactly that, I have also include a small test
>> that just
>> demonstrates that it works.
>> Because I'm neither a benchmark expert nor an assembler expert, I've just
>> checked that the method handle is fully inlined by the JIT and that the
>> generated code seems to don't have more code than it should.
>>
>
> Thanks! This is potentially better than FieldUpdaters since it avoids
> some of the dynamic type checks.  The checks inside your MethodHandle
> returning method look either identical or compatible with updaters.
>
> And on jdk7u2 (but not 1.7.0)  performance seems better.
>
> I'll try experimenting with using this approach on the other various forms
> (scalars; stores/loads; maybe somehow arrays) and contemplate a
> general factory API that when put in place could be used instead
> of updaters (and if all goes well, might even lead to deprecating them).
>
> -Doug
>
>
>
>
>
> ______________________________**_________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.**oswego.edu <Concurrency-interest at cs.oswego.edu>
> http://cs.oswego.edu/mailman/**listinfo/concurrency-interest<http://cs.oswego.edu/mailman/listinfo/concurrency-interest>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20111219/6318a12b/attachment.html>


More information about the Concurrency-interest mailing list