How to retrieve the receiver object of method call

Peng Du imdupeng at gmail.com
Wed Apr 7 22:59:46 PDT 2010


Hi,

I have been fighting with this problem for yet another day with no luck.
The error case happens when both the caller and callee are in compiled
Java frames. The backtrace tells me a SIGSEGV happens at this line:

====
in frame.cpp:1132:
oop r = *caller.oopmapreg_to_location(reg, reg_map)
====

as oopmapreg_to_location() returned a NULL which is dereferenced.

Can someone comment on the error? Thank you!

-Peng


On Wed, Apr 7, 2010 at 2:02 AM, Peng Du <imdupeng at gmail.com> wrote:

> Hello,
>
> What is the right way to get the receiver object of a Java method call in
> the
> VM code, considering both the caller, callee can either be interpreted or
> compiled?
>
> I tried using the "frame" class and it does have many methods for querying
> an interpreted frame, e.g. interpreter_callee_receiver(). But not for
> compiled
> frame.
>
> By learning related code in SharedRuntime, I wrote the following method. It
>
> works for some calls but fails for the others. Can someone point out what
> I have done wrong with the code?
>
> Thanks!
>
> ================
> static oop retrieve_receiver(JavaThread *thread) {
>     HandleMark rm(Thread::current());
>     frame stub = thread->last_frame();
>
>     if (!stub.is_java_frame())
>       stub = stub.java_sender();
>
>     RegisterMap reg_map(thread);
>     frame caller = stub.sender(&reg_map);
>
>     if (caller.is_compiled_frame()) {
>       return caller.retrieve_receiver(&reg_map);
>     }
>     else { // interpreted
>         methodOop method;
>         if (stub.is_compiled_frame())
>             method = thread->callee_target(); // i2c will set this?
>         else
>             method = stub.interpreter_frame_method();
>
>         return caller.interpreter_callee_receiver(method->signature());
>     }
> }
>
>
> - Peng
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20100408/e683c31f/attachment.html 


More information about the hotspot-dev mailing list