Draft JEP on enhanced volatiles

Paul Sandoz paul.sandoz at oracle.com
Mon Feb 10 11:46:44 UTC 2014


On Feb 9, 2014, at 1:52 PM, Remi Forax <forax at univ-mlv.fr> wrote:

> On 02/08/2014 06:52 PM, Brian Goetz wrote:
>>> can you be a little more specific and provide the way
>>> foo.volatile.compareAndSet is compiled with this example:
>> 
>> Hey, the JEP isn't even out of draft yet!  Stop asking hard questions.
> 
> :)
> 
>> 
>> The current strawman, though, is to expose direct (CP-ready) MH forms (Lookup API / constant pool format TBD) for field get/set with fence, array element get/set with fence, field CAS, and array element CAS. Then the static compiler translates
>> 
>>   foo.volatile.cAS(n,m)
>> 
>> as
>> 
>>   LDC #MH[lookupFieldCASer(foo)]
>>   aload n
>>   aload m
>>   invokevirtual "invokeExact"
> 
> wow, you bring out the big guns !
> 
> I see a big issue with this approach, it requires to change the JVM spec each time you want to add a new operation.
> 

Yes, although realistically i would expect new operations only to be added with each major release.


> Moreover, overloads of LDC are usually re-written by JVMs has private opcodes, so why not directly use new opcodes,
> it will take less space in the classfile too.
> 

More work than expanding the kinds of method handle?

I have not looked at this in detail but perhaps there might be a few new reference_kind items (for get/put/static fields) that can refer to a new constant pool entry consisting of a pair of CONSTANT_Fieldref_info and CONSTANT_InterfaceMethodref_info for VirtualXXX iface?

Paul.


More information about the core-libs-dev mailing list