capturing method entry/exit efficiently
Peter B. Kessler
Peter.Kessler at Sun.COM
Thu Sep 3 10:47:23 PDT 2009
Since hotspot-gc-use at openjdk.java.net is the HotSpot GC users mailing list, you might not be reaching the people who can help you with your project. I would suggest asking on the hotspot-runtime-dev at openjdk-java.net for help with the interpreter (e.g., TemplateTable), or hotspot-compiler-dev at openjdk.java.net for help with the runtime compiler, or serviceability-dev at openjdk.java.net for help with the monitoring frameworks (e.g., JVMTI). But the garbage collectors don't have anything to do with method entry or exit.
You might also want to look at bytecode rewriting, e.g., via your own classloader, to add instrumentation to method entries and exits for the methods of the classes you are interested in. I think there are tools available that make bytecode rewriting not as difficult as it sounds.
Tony Guan wrote:
> Dear all,
> One update for yesterday's mail is that I am now able to add some
> call_vm() code in TemplateTable::invokespecial(), to get my own code
> executed. This is much economy in compared with JVMTI. But I just
> cannot find a suitable place for monitoring the method_exit.
> Any idea about that? And still, the compiled method is still a nightmare for me.
>> Dear all,
>> My current research project with hotspot requires me to do something
>> particular whenever a method(interpreted or compiled) is invoked. I
>> need to know the thread and the method at the invocation time. What I
>> am trying to do is to do some VM hacking based on the methods called.
>> Question 1: Can I use BCI to achieve this?
>> I am now able to capture the method_entry/exit events by writing a
>> JVMTI agent, but it's not what I really need to do. By using JVMTI,
>> performance is deteriorated a lot. And I am not sure if the compiled
>> method can still be captured. (Though I know java1.5 has some JVMPI
>> support in the compilation part, but not in java1.7. Am I right?).
>> Question 2: I am trying find a way to enable the
>> notify_method_enry/exit by partly simulating an JVMTI agent, that
>> means that I modify several parts in the hotspot without actually use
>> an external JVMTI agent. Is it feasible? (in terms of perfomance)
>> Question 3: Is there some better way to capture the method_entry/exit event?
>> Thanks for diluting the question marks in my mind!
>> Tony (Xiaohua Guan)
>> hotspot-gc-use mailing list
>> hotspot-gc-use at openjdk.java.net
>> End of hotspot-gc-use Digest, Vol 21, Issue 1
More information about the hotspot-gc-use