Setting JVMTI Capabilities when VM is in "Live Phase"
Daniel D. Daugherty
daniel.daugherty at oracle.com
Fri Aug 12 23:04:25 UTC 2016
On 8/12/16 4:21 PM, Leela Mohan wrote:
> Hi experts,
>
> It looks like, we don't disallow setting capabilities when VM is in
> "JVMTI_PHASE_LIVE". And, I notice, for every new compilation of method,
> ciEnv caches the JVMTI state and expects those assumptions to be true
> during the compilation. Otherwise, dump the compiled method.
>
> However, we don't seem to do anything with the methods which were compiled
> before setting the capability.
>
> What is the understanding?
>
> Thanks,
> Leela
Hi Leela,
I'm guessing that you are talking about this capability:
http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#jvmtiCapabilities.can_generate_compiled_method_load_events
and this event:
http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#CompiledMethodLoad
The can_generate_compiled_method_load_events capability needs to be added
in order to generate CompiledMethodLoad events. Capabilities are added via
http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#AddCapabilities
which can be called from different JVM/TI phases. Different VM
implementations
can require that certain capabilities can only be added in certain
JVM/TI phases.
However, if AddCapabilities() does not return a JVM/TI error when a
capability
is added in a phase, e.g., the live phase, then you can safely assume that
the capability has been added.
In your example, it sounds like the capability is added in the live phase
because you are seeing events generated for newly compiled methods. In order
to see synthetic events for methods that were compiled before you added the
capability, your agent needs to use a different function:
http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#GenerateEvents
The documentation for Compiled Method Load has this line:
> These events can be sent after their initial occurrence with
GenerateEvents.
and that sounds just like your situation.
Hope this helps.
Dan
More information about the hotspot-compiler-dev
mailing list