RFR(M): 6700100: optimize inline_native_clone() for small objects with exact klass

Roland Westrelin roland.westrelin at oracle.com
Mon Nov 3 13:19:41 UTC 2014

Hi Aleksey,

Thanks for the feedback.

> A minor pet peeve about the code style in Hotspot, which adds up to
> accidental code complexity: pro-actively blowing up more methods than
> required to solve the task at hand.
> This change provides the example: both compute_injected_fields() and
> has_injected_fields() do dances around _has_injected_fields value. It
> would seem more readable to just have has_injected_fields() to lazily
> compute the value on demand, inlining both compute_injected_fields() and
> compute_injected_fields_helper(). That would spare two additional
> methods, and make the code generally more readable, and maintainable.

has_injected_fields() is small so it can fit in the .hpp and be inlined which pays off if it’s called repeatedly once _has_injected_fields is computed. The compute_injected_fields() stuff is in its own method to keep has_injected_fields() small. compute_injected_fields_helper() is its own method because we have to enter the VM to do that computation and it’s clearer (to me at least) that whatever we do once we have entered the VM is together in a separate method.

So it doesn’t look that bad to me.


More information about the hotspot-compiler-dev mailing list