The JIT (Just-In-Time) Profiling API provides functionality to report information about just-in-time generated code that can be used by performance tools. You need to insert JIT Profiling API calls in the code generator to report information before JIT-compiled code goes to execution. This information is collected at runtime and used by tools like Intel® VTune™ Amplifier to display performance metrics associated with JIT-compiled code.

You can use the JIT Profiling API to profile such environments as dynamic JIT compilation of JavaScript code traces, JIT execution in OpenCL™ applications, Java*/.NET* managed execution environments, and custom ISV JIT engines.

The standard VTune Amplifier installation contains a static part (as a static library and source files) and a profiler object. The JIT engine generating code during runtime communicates with a profiler object through the static part. During runtime, the JIT engine reports the information about JIT-compiled code stored in a trace file by the profiler object. After collection, the VTune Amplifier uses the generated trace file to resolve the JIT-compiled code. If the VTune Amplifier is not installed, profiling is disabled.

Use the JIT Profiling API to:

JIT profiling is supported with the Launch Application target option for event based sampling.

Profiling Trace-based and Method-based JIT-compiled Code

This is the most common scenario for using JIT Profiling API to profile trace-based and method-based JIT-compiled code:

#include <jitprofiling.h>

if (iJIT_IsProfilingActive() != iJIT_SAMPLING_ON) {

iJIT_Method_Load jmethod = {0};
jmethod.method_id = iJIT_GetNewMethodID();
jmethod.method_name = "method_name";
jmethod.class_file_name = "class_name";
jmethod.source_file_name = "source_file_name";
jmethod.method_load_address = code_addr;
jmethod.method_size = code_size;


Usage Tips

  • If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an already reported method, then such a method becomes invalid and its memory region is treated as unloaded. VTune Amplifier displays the metrics collected by the method until it is overwritten.

  • If supplied line number information contains multiple source lines for the same assembly instruction (code location), then VTune Amplifier picks up the first line number.

  • Dynamically generated code can be associated with a module name. Use the iJIT_Method_Load_V2 structure.

    • If you register a function with the same method ID multiple times, specifying different module names, then the VTune Amplifier picks up the module name registered first. If you want to distinguish the same function between different JIT engines, supply different method IDs for each function. Other symbolic information (for example, source file) can be identical.

Analyzing Split Functions

You can use the JIT Profiling API to analyze split functions (multiple joint or disjoint code regions belonging to the same function) including re-JITting with potential overlapping of code regions in time, which is common in resource-limited environments.

 #include <jitprofiling.h>
 unsigned int method_id = iJIT_GetNewMethodID();
 iJIT_Method_Load a = {0};
 a.method_id = method_id;
 a.method_load_address = 0x100;
 a.method_size = 0x20;
 iJIT_Method_Load b = {0};
 b.method_id = method_id;
 b.method_load_address = 0x200;
 b.method_size = 0x30;

Usage Tips

  • If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an already reported method, then such a method becomes invalid and its memory region is treated as unloaded.

  • All code regions reported with the same method ID are considered as belonging to the same method. Symbolic information (method name, source file name) will be taken from the first notification, and all subsequent notifications with the same method ID will be processed only for line number table information. So, the VTune Amplifier will map samples to a source line using the line number table from the current notification while taking the source file name from the very first one.

    • If you register a second code region with a different source file name and the same method ID, this information will be saved and will not be considered as an extension of the first code region, but VTune Amplifier will use the source file of the first code region and map performance metrics incorrectly.

    • If you register a second code region with the same source file as for the first region and the same method ID, the source file will be discarded but VTune Amplifier will map metrics to the source file correctly.

    • If you register a second code region with a null source file and the same method ID, provided line number info will be associated with the source file of the first code region.

Exploring Inline Functions

You can use the JIT Profiling API to explore inline functions including multi-level hierarchy of nested inline methods that shows how performance metrics are distributed through them.

#include <jitprofiling.h>

  //                                    method_id   parent_id
  //   [-- c --]                          3000        2000
  //                  [---- d -----]      2001        1000
  //  [---- b ----]                       2000        1000
  // [------------ a ----------------]    1000         n/a
iJIT_Method_Load a = {0};
a.method_id = 1000;
iJIT_Method_Inline_Load b = {0};
b.method_id = 2000;
b.parent_method_id = 1000;

iJIT_Method_Inline_Load c = {0};
c.method_id = 3000;
c.parent_method_id = 2000;

iJIT_Method_Inline_Load d = {0};
d.method_id = 2001;
d.parent_method_id = 1000;


Usage Tips

  • Each inline (iJIT_Method_Inline_Load) method should be associated with two method IDs: one for itself; one for its immediate parent.

  • Address regions of inline methods of the same parent method cannot overlap each other.

  • Execution of the parent method must not be started until it and all its inline methods are reported.

  • In case of nested inline methods an order of iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important.

  • If any event overwrites either inline method or top parent method, then the parent, including inline methods, becomes invalid and its memory region is treated as unloaded.

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.
Seleccione el color del botón adhesivo: 
Orange (only for download buttons)