RFR: 8141678: sun.invoke.util.Wrapper eagerly initializes all integral type caches

John Rose john.r.rose at oracle.com
Thu Nov 12 01:01:21 UTC 2015


On Nov 9, 2015, at 3:27 AM, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:
> 
> I agree with Claes here: let's not touch the valueOf hotpath.

Probably the best way to fix the present problem is to use the valueOf hotpath *more*, by having the zero-function call the appropriate valueOf function, instead of cache a constant.  That's what Claes's latest revision (switch-inside-zero-function) does.

It's also possible that the calls to Wrapper.zero from the MH runtime might be replaced (in some cases) by direct calls to valueOf or even a primitive-valued zero function.  After all, Wrapper.zero is a convenience for something that could be coded a different way.

Here's a relevant code puzzler:  Outside of Wrapper, just using java.lang, how can you go from a primitive Class to a zero value of that class?  Hint:  Use java.lang.reflect.Array::get.  Bonus question:  Will it constant fold in the optimizer?

— John


More information about the core-libs-dev mailing list