RFR: 8270794: Avoid loading Klass* twice in TypeArrayKlass::oop_size()
Aleksey Shipilev
shade at openjdk.java.net
Tue Jul 27 08:34:28 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 to me, but somebody from runtime team should take a look as well.
src/hotspot/share/opto/runtime.cpp line 305:
> 303: is_deoptimized_caller_frame(current)) {
> 304: // Zero array here if the caller is deoptimized.
> 305: int size = TypeArrayKlass::cast(array_type)->oop_size(result);
I think you can pull `TypeArrayKlass::cast(array_type)` into a local variable, and use it in the line below as well.
-------------
Marked as reviewed by shade (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/4799
More information about the hotspot-dev
mailing list