On Nov 9, 2015, at 3:27 AM, Aleksey Shipilev <aleksey.shipi...@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