help understanding the "putLongRelease" implemetation in openjdk9
Mikael Vidstedt
mikael.vidstedt at oracle.com
Fri Oct 28 05:08:31 UTC 2016
Adding back the hotspot-dev mailing list - please keep it on the cc: line.
The JIT compiler only compiles methods which are “hot” (which are being executed a lot). Before the methods are JIT compiled they are executed by the interpreter. The interpreter will *not* short-circuit the method, and will instead execute it exactly like it’s written, delegating to putLongVolatile which will take execution into unsafe.cpp/Unsafe_PutLongVolatile. Leaving the body of the method empty would mean that if the method is not JIT compiled, the interpreter would effectively execute a no-op, which of course will not have the desired effect.
Cheers,
Mikael
> On Oct 27, 2016, at 9:51 PM, 恶灵骑士 <1072213404 at qq.com> wrote:
>
>
> you already know that JIT compiler handles the method
> 'public final void putLongRelease(Object o, long offset, long x) ' differently,
>
> why you still implemeted the method putLongRelease as
> '@HotSpotIntrinsicCandidate
> public final void putLongRelease(Object o, long offset, long x) {
> putLongVolatile(o, offset, x);
> }'
>
> Why can't it be a empty method like '@HotSpotIntrinsicCandidate
> public final void putLongRelease(Object o, long offset, long x) {
>
> }' ?
>
> Is method putLongRelease used somewhere else not by JIT?
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Mikael Vidstedt";<mikael.vidstedt at oracle.com>;
> 发送时间: 2016年10月28日(星期五) 中午12:04
> 收件人: "恶灵骑士"<1072213404 at qq.com>;
> 抄送: "hotspot-dev"<hotspot-dev at openjdk.java.net>;
> 主题: Re: help understanding the "putLongRelease" implemetation in openjdk9
>
>
> In jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.cpp you’ll find this:
>
> /** Release version of {@link #putLongVolatile(Object, long, long)} */
> @HotSpotIntrinsicCandidate
> public final void putLongRelease(Object o, long offset, long x) {
> putLongVolatile(o, offset, x);
> }
>
> That is - in the default/interpreter case the putLongRelease method will delegate to the putLongVolatile method, and putLongVolatile in turn is in the default/interpreter case implemented in unsafe.cpp. However, the @HotSpotIntrinsicCandidate annotation is an indication that the JIT compiler handles the method differently, and if you have a look at hotspot/src/share/vm/opto/library_call.cpp you’ll find that putLongRelease, along with the other methods in the same family, get intensified and expanded during compilation using the inline_unsafe_access C++ method.
>
> Cheers,
> Mikael
>
> > On Oct 27, 2016, at 8:29 PM, 恶灵骑士 <1072213404 at qq.com> wrote:
> >
> > for jdk8 according to src/share/vm/classfile/vmSymbols.hpp
> > do_intrinsic(_putOrderedLong, sun_misc_Unsafe, putOrderedLong_name, putOrderedLong_signature, F_RN)
> > do_name( putOrderedLong_name, "putOrderedLong")
> >
> >
> >
> > i can find method "putOrderedLong" in src/share/vm/prims/unsafe.hpp,
> >
> >
> > but for jdk9 src/share/vm/classfile/vmSymbols.hpp
> > do_intrinsic(_getLongAcquire, jdk_internal_misc_Unsafe, getLongAcquire_name, getLong_signature, F_R)
> > do_name(getLongAcquire_name, "getLongAcquire") do_name(putLongRelease_name, "putLongRelease")
> >
> >
> > i can not find method "putLongRelease" in src/share/vm/prims/unsafe.hpp,
> > why ?
> > Is the method "putLongRelease" of interpreter userd version discarded?
> > only reserve the implemetation of compiler used version?
More information about the hotspot-dev
mailing list