A hotspot patch for stack profiling (frame pointer)

Bertrand Delsart bertrand.delsart at oracle.com
Thu Jan 15 11:13:08 UTC 2015

On 14/01/2015 20:12, John Rose wrote:
> On Jan 14, 2015, at 6:42 AM, Bertrand Delsart
> <bertrand.delsart at oracle.com <mailto:bertrand.delsart at oracle.com>> wrote:
>> I would not prevent the JITs from using RBP as long as the changeset
>> is not sufficient to guarantee the profiling will work... and IMHO
>> solving the JSR292 issue will be much more intrusive (impacting
>> HotSpot stack walking code).
> Here are some thoughts on that.
> SPARC uses L7 (L7_mh_SP_save) for the same purpose of method handle
> support as x86 uses RBP (rbp_mh_SP_save).  So there's not a hard
> requirement for x86 to take over RBP.
> (Deep background:  This purpose, in method handle support, is to allow
> an adapter to make changes to the caller's SP.  The adapter is the
> initial callee from the caller, but may change argument shape, and
> tail-calls the ultimate callee.  Because it is a tail-call, the original
> caller must have a spot where his original SP can be preserved.  The
> preservation works because the original caller knows he is calling a
> MH.invoke method, which requires the extra argument preservation.  The
> repertoire of argument shape changes is quite small, actually; it is not
> a very general mechanism since the LF machinery was put in.  Perhaps the
> whole thing could be removed somehow, by finding alternative techniques
> for the few remaining changes.  OTOH, this SP-restoring mechanism may be
> helpful in doing more a general tail-call mechanism, and perhaps in
> managing int/comp mode changes more cleanly, so I'd like us to keep it.
>   And document it better.)
> Any register or stack slot will do for this purpose, as long as (i) its
> value can be recovered after the MH.invoke call returns to the caller,
> and (ii) its value can be dug up somehow during stack walking.  There
> are only a couple of places where stack walking code needs to sample the
> value, so they should be adjustable.
> Both x86 and SPARC use registers which are callee-save (or "non-volatile
> across calls") which satisfy properties (i) and (ii).  A standard stack
> slot (addressed based on caller's RBP) would probably also satisfy those
> properties.
> A variably-positioned stack slot would also work, which would require
> registering the position in each CodeBlob.  That's unpleasant extra
> detail, but it would align somewhat with the current logic which allows
> each CodeBlob (nmethod, actually) to advertise which call sites need the
> special processing (see the function is_method_handle_return(caller_pc)).
> I recommend reserving a dead word of space in every stack frame that
> makes MH.invoke calls, at a fixed position relative to that frame's RBP.
> — John

I perfectly agree that it is doable (and with your proposed approach).

I just wanted to be sure people were aware that the RFE is more complex 
than what the current changeset may suggest. We are not just taking 
about reviewing and integrating a complete changeset contributed by the 
community. There is more work needed, either by the community or by 
Oracle. This will require changes at least in C1 and C2 call sequences, 
in the stack walking, in the creation and sizing of compiled frames...



Bertrand Delsart,                     Grenoble Engineering Center
Oracle,         180 av. de l'Europe,          ZIRST de Montbonnot
38330 Montbonnot Saint Martin,                             FRANCE
bertrand.delsart at oracle.com             Phone : +33 4 76 18 81 23

NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient,
please contact the sender by reply email and destroy all copies of
the original message.

More information about the hotspot-compiler-dev mailing list