How to retrieve the receiver object of method call

Tom Rodriguez tom.rodriguez at
Thu Apr 8 14:19:12 PDT 2010

On Apr 8, 2010, at 2:11 PM, Peng Du wrote:

> On 04/08/2010 04:02 PM, Tom Rodriguez wrote:
>> In what context are you trying to find the receiver for compiled code?  The only place where you are guaranteed to be able to find it is at a call site in the generated code of the caller.  In other contexts you'd have to jump through some hoops to find it as local 0 and even then we might not consider it to be live so you might not be able to find it.  You'd have to use some code like the vframeStream or vframeArray logic to find the root method on the compiled method and look at local 0.
> Thanks, Tom
> In my case, it is inside the callee that I need to get its receiver. What if
> the current method is guaranteed not to be inlined? Can I find the receiver 
> by directly looking at the callee's local 0, instead of walking vframes? 

Well, you kind of have to look at the compiled frame as a set of vframes to get access to the locals unless you want to build it all yourself.  Basically you'd grab the PcDesc for the pc and look at the debug info to find the mapping from local 0 of the root of the compiled frame to some register or stack slot.  This requires having a proper RegisterMap and being at a pc that has debug info, which is pretty much only call sites.  If you want to be able to get it at arbitrary pcs then you are out of luck.

Why can't you just arrange to grab the value you need directly instead of trying to get at it introspectively?


> Thanks
> -Peng

More information about the hotspot-dev mailing list