How to retrieve the receiver object of method call
Tom Rodriguez
tom.rodriguez at oracle.com
Thu Apr 8 14:02:37 PDT 2010
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.
tom
On Apr 7, 2010, at 10:59 PM, Peng Du wrote:
> 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(®_map);
>
> if (caller.is_compiled_frame()) {
> return caller.retrieve_receiver(®_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
>
More information about the hotspot-dev
mailing list