RFR: 8074101: Add verification that all tasks are actually claimed during roots processing [v2]
Albert Mingkun Yang
ayang at openjdk.java.net
Tue Jan 12 18:46:15 UTC 2021
On Tue, 12 Jan 2021 17:14:10 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> src/hotspot/share/gc/g1/g1RootProcessor.cpp line 66:
>>
>>> 64: // already processed in java roots.
>>> 65: _process_strong_tasks.try_claim_task(G1RP_PS_CodeCache_oops_do);
>>> 66: #endif
>>
>> Rather than these fake claims, consider something like this:
>>
>> template<typename... Ts>
>> void all_tasks_completed(uint nworkers, Ts... tags) {
>> // Type-check more_skipped are all of the same type as first_skipped.
>> T0 typed_skipped[] = { first_skipped, more_skipped... };
>> uint skipped[] = { static_cast<uint>(tags)... };
>> all_tasks_completed_impl(nworkers, skipped, ARRAY_SIZE(skipped));
>> }
>>
>> void all_tasks_completed(uint nworkers) {
>> all_tasks_completed_impl(nworkers, nullptr, 0);
>> }
>>
>> Usage:
>>
>> all_tasks_completed(n_workers(),
>> G1RP_PS_CodeCache_oops_do,
>> G1RP_PS_refProcessor_oops_do)
>>
>> all_tasks_completed_impl can check that all tasks have been claimed except
>> the skipped ones, which have not been claimed.
>>
>> There might be better ways to write the variadic all_tasks_completed. It's
>> been a while since I've done anything with variadic templates.
>
> Here's a better version of the variadic `all_tasks_completed`
>
> template<typename T0, typename... Ts,
> ENABLE_IF(Conjunction<std::is_same<T0, Ts>...>::value)>
> void all_tasks_completed(uint n_threads, T0 first_skipped, Ts... more_skipped) {
> static_assert(std::is_convertible<T0, uint>::value, "not convertible");
> uint skipped[] = { static_cast<uint>(first_skipped), static_cast<uint>(more_skipped)... };
> all_tasks_completed_impl(n_threads, skipped, ARRAY_SIZE(skipped));
> }
> `Conjunction` is in metaprogramming/logical.hpp.
Thank you; updated as suggested.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2046
More information about the hotspot-gc-dev
mailing list