RFR: 8270794: Avoid loading Klass* twice in TypeArrayKlass::oop_size()

Coleen Phillimore coleenp at openjdk.java.net
Tue Jul 27 15:05:30 UTC 2021


On Thu, 15 Jul 2021 19:56:04 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> TypeArrayKlass::oop_size() calls into TypoArrayOopDesc::object_size() which loads the Klass* from the object, but this is not necessary because we're coming from TypeArrayKlass.
> 
> Note: This came up in Lilliput, where we need to be careful how to load the Klass, and must figure out the object size using oopDesc::size_given_klass() without blindly re-loading the Klass*. Outside of Lilliput I consider this a cosmetic change (i.e. no substantial performance improvement expected because most cases should be covered by layout-helper).
> 
> Testing:
>  - [x] tier1
>  - [ ] tier2

This looks fine. I was wondering why the other Metadata types have oop_size(oop) which call object_size() shouldn't have the same treatment but it doesn't appear that objArrayOop::object_size loads the _klass field.  So TypeArrayKlass::object_size() can be different and that seems fine.  It's not virtual.

-------------

Marked as reviewed by coleenp (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/4799


More information about the hotspot-dev mailing list