RFR (trivial): 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate

Claes Redestad claes.redestad at oracle.com
Tue Jan 8 12:10:52 UTC 2019

On 2019-01-08 12:56, Roman Kennke wrote:
>>>>>>> Those methods are virtual. How useful is it to flag them 'inline' ?
>>>>>> Useful enough to measurably save a few ns/op on Array.newInstance and
>>>>>> Object.clone microbenchmarks (when running TieredStopAtLevel=1 to stay
>>>>>> in the JNI slow path).
>>>>> If a method is virtual, it cannot be inlined, right? Unless you call it
>>>>> in a funny non-virtual way. Or what am I missing?
>>>> Could be these are the only implementations when compiling without
>>>> shenandoah so gcc realizes the virtual can be ignored?
>>> I doubt that gcc can make that call. The linker probably could, but at
>>> this point it would be too late. C++ is not Java. I don't think the
>>> patch hurts, but I doubt its usefulness ;-)
>> I only go by what I see in microbenchmarks, and somehow this netted a
>> small improvement.
> Ok.
> I'm just curious. ;-) Can you by any chance send me the microbenchmark?
> Maybe I can figure out what's going on. I suppose there is a chance that
> if you call one of those methods with an object of known type, e.g.
> G1CollectedHeap*, and the compiler can prove that it cannot be a
> subtype, then yeah, it might actually inline it. If the benchmark is
> using jmh, you can run with and without the patch with perfasm profiler
> and it should show you what's different in the hot path.

I've run these:

import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
import java.lang.reflect.Array;

public class ArrayInstantiationBenchmark {

    @Param({"10", "100", "1000"})
    private int length;

    public Object obj = new Object();

    public Object newInstance() {
      return Array.newInstance(String.class, length);

    public Object clone() {
      return obj.clone();


with -XX:TieredStopAtLevel=1 - -prof perfasm doesn't say much since the
time is mainly spent in native code, but async-profiler profiles
indicates the objArray_allocate method no longer manifests on the stack.


> Roman

More information about the hotspot-gc-dev mailing list