nagy.mostafa at gmail.com
Thu Jul 3 11:51:35 PDT 2008
Yes, I thought about bytecode rewriting but I didn't want to go that way
for two reasons:
1 - I am not sure what kind of optimizations the compiler will perform,
so my instrumentation might be reordered. In other words, since I am
inserting only calls to some java hooks in the bytecode and these calls
have no dependency with the call I am trying to instrument, the compiler
might choose to move my instrumentations around.
2 - I might be interested in profiling for some jvm internal data. So
bytecode rewriting wouldn't help.
I will see what I can do.
Tom Rodriguez wrote:
> InterpreterRuntime::resolve_invoke would be a good instrumentation
> point, though you'd have to modify the code in the generated
> interpreter to always enter that code instead of only the first time a
> call site is resolved. Start in the code for
> TemplateTable::_invokevirtual and friends and step through that code
> to see how it works. Obviously you'd have to disable the compilers
> since your trick only works in the interpreter.
> Have you considered using bytecode rewriting to capture whatever it is
> you're after?
> On Jul 3, 2008, at 11:11 AM, Nagy Mostafa wrote:
>> Thanks, Tim.
>> Yes, I know I can use JVMTI for the task, but I also wanted to
>> collect call-site and some other specific info (e.g. field access)
>> information. Can the JVM pass information about call site bytecode
>> index/pointer to JVMTI ?
>> - nagy
>> On Wed, Jul 2, 2008 at 3:05 PM, Tim Bell <Tim.Bell at sun.com> wrote:
>> Nagy1981 wrote:
>> Hi, I am trying to modify the hotspot interpreter to collect some
>> profile data.
>> The main thing I want to do is build a call-tree. I want to add a
>> hook to
>> the interpreter whenever an invoke_* bytecode operation is about to
>> such that my call-tree gets updated. Can you please guide me to the
>> part of
>> the code where control is passed from the interpreter to the assembly
>> corresponding to a bytecode operation. All I can find is parts where the
>> assembly code get generated, but I can't figure out where it is
>> Have you looked at the javadoc for the JVMTI_EVENT_METHOD_ENTRY event?
>> Does this supply the functionality you need? It would be easier to
>> write a JVM TI agent  to collect this information than it would be
>> to modify the interpreter.
>> If you still want to modify the JVM code, read over jvmtiExport.cpp.
>> Look for
>> void JvmtiExport::post_method_entry()
>> If you still want to modify the JVM, look over the code base for
>> calls to post_method_entry() and that should give you an idea where
>> to start.
>> Hope this helps - Tim Bell
>>  The JVM Tool Interface (JVM TI): How VM Agents Work
More information about the hotspot-dev