Chapter 1. Developing a new JIT agent

Table of Contents

1. Overview
2. Implementing JIT support for a new virtual machine

OProfile includes a header file and library that are intended to be used by developers who wish to extend OProfile's JIT support to other non-supported virtual machines. This developer guide describes these development files and how to use them.

1. Overview

OProfile already includes some implementations that use the JIT support, e.g., the Java Virtual Machine Toolkit Interface (JVMTI) library, libjvmti_oprofile.so. In developing a new implementation, you will likely follow a similar (if not identical) procedure as was used in developing the JVMTI library. Following are the high level steps to follow:

  1. Ensure your virtual machine provides an API that, at minimum, can provide the following information about dynamically compiled code:
    • Notification when compilation occurs
    • Name of the symbol (i.e., function or class/method, etc.)
    • Address in anonymous memory where the compiled code was loaded
    • Length of the compiled code segment
  2. Write an agent library that communicates with your VM to obtain compiled code notifications. Invoke the required functions from opagent.h (Section 2, “Implementing JIT support for a new virtual machine”) and link your library with libopagent.so (installed at <oprofile_install_dir>/lib/oprofile).