How to compare thecaller thread object and callee's holder?
David Holmes
David.Holmes at oracle.com
Thu Apr 22 18:27:22 PDT 2010
Tony Guan said the following on 04/23/10 08:50:
> Thanks you for the reply. By "holder" of a method, I mean the object
> whose class owns the method interested.
Ok. I didn't understand how the "thread" was related to the holder.
> Given that from the dtrace functionality, I already know the current
> thread, and the methodOoopDesc* of the called method, I need to
> identify the caller object and the callee object from the two
> parameters passed to the dtrace_method_entry:
>
> JRT_LEAF(int, SharedRuntime::dtrace_method_entry( JavaThread* thread,
> methodOopDesc* method)) in shareRuntime.cpp
>
Ah that's a much more specific question :) But I'm afraid I can't answer
it with certainty (I don't think you can get either easily) but the
compiler folk (cc'ed) will have a much better idea.
David
-----
> for a callee method, we may refer it as receiver.
> and for a caller, let's just name it as a caller object, sorry for the
> vague term I borrowed from the source code of hotspot. The following
> code shows more accurately what I want:
>
> class B{
> methodB(){
> ...
> }
> }
>
> class A{
>
> void methodA()
> {
> B objectB=new B();
> objectB.methodB(); //*****here is what I am at
>
> }
> static public main(args)
> {
> A objectA=new A();
> A.methodA();
> }
>
> }
>
> Now, as we are calling objectB.methodB() from A.methodA(), all I need
> is to find out objectA and objectB from within the JVM.
>
> Given that from the dtrace functionality, I already know the current
> thread, and the methodOoopDesc* of the called method, I need to
> identify the caller object and the callee object from the two
> parameters passed to the dtrace_method_entry:
>
> JRT_LEAF(int, SharedRuntime::dtrace_method_entry( JavaThread* thread,
> methodOopDesc* method)) in shareRuntime.cpp
>
> Thanks!
>
> Tony (Xiaohua Guan)
>
>
>
> On Wed, Apr 21, 2010 at 8:11 PM, David Holmes <David.Holmes at oracle.com> wrote:
>> Tony,
>>
>> Tony Guan said the following on 04/22/10 00:06:
>>> a quick question: given a caller thread object( JavaThread* thread)
>>> and the method to be called by the thread (methodOopDesc* method), how
>>> do I know that the holder of the "method" is from the same caller
>>> object or not?
>> I don't understand what you mean here by "holder"?
>>
>>> The reason why I am asking is:
>>> in
>>> JRT_LEAF(int, SharedRuntime::dtrace_method_entry( JavaThread*
>>> thread, methodOopDesc* method)) in shareRuntime.cpp
>>>
>>> I want to check if the method called will start another thread or not,
>>> so I need to compare the holders of the caller and callee.
>> Again I don't know what the "holder" is here. If a method starts a thread
>> then that new thread doesn't necessarily have any connection back to the
>> method from which it was started.
>>
>>> So one more question: is there any other way to achieve this?
>> I think you would have to add code in the thread start routine (of the JVM)
>> and have the before/after method hooks to do this eg:
>>
>> before-method: set flag showing current thread is interested in thread
>> start
>> start-thread: check if current thread interested in thread start and if so
>> bump a counter
>> after-method: check counter and clear flag
>>
>> David Holmes
>>
More information about the hotspot-compiler-dev
mailing list