RFR: 8138659: Speed up InstanceKlass subclass discrimination
Coleen Phillimore
coleen.phillimore at oracle.com
Thu Oct 8 11:21:35 UTC 2015
On 10/7/15 8:43 PM, Kim Barrett wrote:
> On Oct 7, 2015, at 7:35 PM, Coleen Phillimore <coleen.phillimore at oracle.com> wrote:
>> Kim,
>>
>> This looks *very* nice. Thank you for doing this:
>>
>> + return static_cast<InstanceMirrorKlass*>(k);
>>
>>
>> For bonus points can you change this to a static_cast<> ???
>>
>> // Casting from Klass*
>> static InstanceKlass* cast(Klass* k) {
>> assert(k == NULL || k->is_klass(), "must be");
>> assert(k == NULL || k->oop_is_instance(), "cast to InstanceKlass");
>> return (InstanceKlass*) k;
>> }
> Yikes! I somehow forgot that InstanceKlass::cast accepted NULL. But I wonder if that case really
> arises? Certainly a large percentage of uses of it will (nearly) instantly crash if k is NULL, because
> we immediately call some member function on the result of the cast.
Oh, yeah, this looks bad! File another bug and someone will look for
why we allow null here.
Coleen
>
> [And the is_klass is questionable too, since for it to even potentially return false someone must
> have performed a bad cast, so we’re already in the realm of undefined behavior and that call
> could do anything.]
>
More information about the hotspot-dev
mailing list