RFR: 8269119: C2: Avoid redundant memory barriers in Unsafe.copyMemory0 intrinsic [v4]
Tobias Hartmann
thartmann at openjdk.java.net
Mon Sep 6 06:48:45 UTC 2021
On Fri, 3 Sep 2021 14:24:57 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> `Unsafe::copyMemory0` intrinsic unconditionally inserts barriers arounds the call to `unsafe_arraycopy` stub.
>> It is a conservative approach and barriers can be avoided in most common cases (similar to what is done for scalar unsafe accesses).
>>
>> `Unsafe::copyMemory()` performs argument validation which limits inputs either
>> to off-heap location (null + absolute address) or primitive on-heap array.
>>
>> The only cases when barriers are still needed are:
>> * mixed accesses (`Object+offset`);
>> * mismatched access due to lack of type info on base oop (`Object:NotNull+offset`).
>>
>> Testing: hs-tier1 - hs-tier6
>
> Vladimir Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>
> Stress instruction scheduling
src/hotspot/share/opto/library_call.cpp line 4082:
> 4080: bool is_mixed = !in_heap && !in_native;
> 4081:
> 4082: bool is_prim_array = (addr_t != NULL) && (addr_t->elem() != Type::BOTTOM);
What does `is_prim_array` stand for? I read this as "is primitive array" which does not make sense :)
test/hotspot/jtreg/compiler/unsafe/UnsafeCopyMemory.java line 31:
> 29: *
> 30: * @run main/othervm -Xbatch -XX:CompileCommand=dontinline,compiler.unsafe.UnsafeCopyMemory::test*
> 31: * -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:+StressLCM
You should add `@key stress` to the test.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5259
More information about the hotspot-compiler-dev
mailing list