RFR: 6869327: Add new C2 flag to keep safepoints in counted loops.
Andreas Eriksson
andreas.eriksson at oracle.com
Fri Nov 27 13:29:08 UTC 2015
On 2015-11-27 14:18, Aleksey Shipilev wrote:
> Hi,
>
> On 11/27/2015 04:01 PM, Andreas Eriksson wrote:
>> Please review this change that adds a flag to keep a safepoint in
>> counted loops.
>>
>> Currently C2 removes safepoints in counted loops.
>> This can force other safepointing threads to wait for the counted loop
>> thread for long periods of time.
>> This change adds a flag, UseCountedLoopSafepoints, which keeps a
>> safepoint in the loop. Its default value is false.
>>
>> Bug: 6869327: Add new C2 flag to keep safepoints in counted loops.
>> https://bugs.openjdk.java.net/browse/JDK-6869327
>>
>> Webrev: http://cr.openjdk.java.net/~aeriksso/6869327/webrev.00/
> Do I get it right that this logic works good with loop unrolling? Can we
> check?
It should, but verifying it would indeed be good.
I'll check and let you know.
Thanks,
Andreas
> E.g. I would expect that a counted loop like this:
>
> int s = 0;
> for (int c = 0; c < N; c++) {
> s += c;
> <safepoint>
> }
>
> ...would get unrolled and stripped to:
>
> int s = 0;
> for (int c = 0; c < N; c += 4) {
> s += c + 0;
> s += c + 1;
> s += c + 2;
> s += c + 3;
> <safepoint> // only one safepoint here
> }
>
> This would basically perform a limited variant of what Vladimir mentions
> as "strip mining" (aka transform a countable loop into two nested loops
> and place safepoint into external loop), where the size of "internal"
> loop is limited by unrolling.
>
> Thanks,
> -Aleksey
>
More information about the hotspot-compiler-dev
mailing list