RFR: 8138659: Speed up InstanceKlass subclass discrimination
Kim Barrett
kim.barrett at oracle.com
Thu Oct 8 00:43:31 UTC 2015
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.
[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