RFR: 8231269: CompileTask::is_unloaded is slow due to JNIHandles type checks [v6]
Aleksey Shipilev
shade at openjdk.org
Tue Apr 29 09:22:10 UTC 2025
On Mon, 28 Apr 2025 18:48:47 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>>> I agree is_permanent_class_loader_data() captures the intent better. Let me see if it fits well here.
>>
>> Ah wait, it does not. We need to hold on to something that blocks the unloading. Just checking `is_permanent_class_loader_data()` does not get us there. We would need to ask for some holder for it. For the reasons above, `method->method_holder()->klass_holder()` works for non-strong hidden classes as well.
>>
>> This is also why current mainline code works -- it captures the same thing.
>
> Ok, thanks for checking! Good to know there's no existing bug.
>
> What I had in mind is as follows:
>
> InstanceKlass* holder = method->method_holder();
> if (holder->class_loader_data()->is_permanent_class_loader_data()) {
> return nullptr; // method holder class can't be unloaded
> } else {
> // Normal class, return the holder that would block unloading.
> // This would be either classloader oop for non-hidden classes,
> // or Java mirror oop for hidden classes.
> assert(holder->klass_holder() != nullptr, "");
> return holder->klass_holder();
> }
>
>
> IMO it makes the check more precise and, at the same time, communicates the intent better. What do you think?
Yes, OK, let's do a variant of that. Committed. I'll re-run test to see if there are any surprises about these asserts.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24018#discussion_r2065897750
More information about the hotspot-compiler-dev
mailing list