help understanding the "putLongRelease" implemetation in openjdk9
Mikael Vidstedt
mikael.vidstedt at oracle.com
Fri Oct 28 05:46:48 UTC 2016
Adding back hotspot-dev again. Pretty please, keep the hotspot-dev mailing list on the cc: line - that is, please use “reply all” instead of just “reply”.
Yes, that’s exactly right. In general, if the code is being executed in the interpreter it isn’t (yet) performance critical. In this specific case, the cost/overhead of going into the unsafe.cpp native code and back out again is significantly higher than the cost/savings of the barrier, so instead of having multiple separate versions of the code in native we simply make the methods fall back on the more heavy-weight barrier version. Only when JIT compiling the code, where we know that the code is hot and therefore likely performance critical, do we pick the best suited/cheapest barrier version.
Cheers,
Mikael
> On Oct 27, 2016, at 10:34 PM, 恶灵骑士 <1072213404 at qq.com> wrote:
>
>
> you means that if the method is not ‘hot’,
> even if using unsafe.cpp/Unsafe_PutLongVolatile which emits one more store-load barrier than the number of lazySet should emit,
> the time costing will be almost equal , so there is no need putLongRelease using a individual implemetation, right?
>
> thank you , Mikael!
>
> Arron
>
> ------------------ 原始邮件 ------------------
> 发件人: "Mikael Vidstedt";<mikael.vidstedt at oracle.com>;
> 发送时间: 2016年10月28日(星期五) 中午1:08
> 收件人: "恶灵骑士"<1072213404 at qq.com>;
> 抄送: "hotspot-dev"<hotspot-dev at openjdk.java.net>;
> 主题: Re: help understanding the "putLongRelease" implemetation in openjdk9
>
> 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 <mailto: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 <mailto:mikael.vidstedt at oracle.com>>;
>> 发送时间: 2016年10月28日(星期五) 中午12:04
>> 收件人: "恶灵骑士"<1072213404 at qq.com <mailto:1072213404 at qq.com>>;
>> 抄送: "hotspot-dev"<hotspot-dev at openjdk.java.net <mailto: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 <mailto: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