<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Tony,<br>
<br>
Have you explored doing this using Dynamic Bytecode Instrumentation
using JVMTI's redefineClass(Class[] classes<b>, </b>byte[][] newBC)
method.<br>
<br>
<a class="moz-txt-link-freetext" href="http://java.sun.com/developer/technicalArticles/J2SE/jvm_ti/">http://java.sun.com/developer/technicalArticles/J2SE/jvm_ti/</a><br>
<a class="moz-txt-link-freetext" href="http://weblogs.java.net/blog/kellyohair/archive/2005/05/bytecode_instru.html">http://weblogs.java.net/blog/kellyohair/archive/2005/05/bytecode_instru.html</a><br>
<br>
Thanks,<br>
Poonam<br>
<br>
On 11/22/2010 12:49 PM, Tony Guan wrote:
<blockquote
cite="mid:AANLkTikg8W7f4MxRqUhJyt5+1HVnTNcvzsdRupkoiKr8@mail.gmail.com"
type="cite">
<pre wrap="">Dear all,
I want to do something special once a method M is called for some type
of class C, mainly to changed the policy of gc.
Currently, I am intercepting SharedRuntime::dtrace_method_entry() to
insert my own code inside hotspot. While this works, the performance
is really terrible. Because I have to compare each method call with
the right one, and the string comparison happens for every method call
under the class type C.
So I am looking for a way to insert some code at the beginning of a
CERTAIN method call, to avoid the need of instrumenting or monitoring
EVERY method call.
I understand that this can be done with some java agent, but my
implementation need to be able to call into the JVM, so that the GC
behavior can be changed. That means I need to let the hotspot know
once method M of class C is called, not a standalone java program.
Currently I want to mark the class and the method upon class loading,
and to do the comparison in SharedRuntime::dtrace_method_entry(). This
should avoid the need to do the string comparison, but still need to
monitor every method call, which is an overhead that we really want to
get rid of.
Thanks a lot!
Tony
</pre>
</blockquote>
</body>
</html>