[concurrency-interest] CAS using a MethodHandle
viktor.klang at gmail.com
Mon Dec 19 14:35:00 EST 2011
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
>> Atomic*FieldUpdater and let the VM inline the method handle so there
>> should be
>> no cost (or a little one) compared to directly calling
>> 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).
> Concurrency-interest mailing list
> Concurrency-interest at cs.**oswego.edu <Concurrency-interest at cs.oswego.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest