com.google.monitoring.runtime.instrumentation
Class AllocationInstrumenter

java.lang.Object
  extended by com.google.monitoring.runtime.instrumentation.AllocationInstrumenter
All Implemented Interfaces:
ClassFileTransformer

public class AllocationInstrumenter
extends Object
implements ClassFileTransformer

Instruments bytecodes that allocate heap memory to call a recording hook. This will add a static invocation to a recorder function to any bytecode that looks like it will be allocating heap memory allowing users to implement heap profiling schemes.

Author:
Ami Fischman, Jeremy Manson

Method Summary
static byte[] instrument(byte[] originalBytes)
           
static byte[] instrument(byte[] originalBytes, String recorderClass, String recorderMethod)
          Given the bytes representing a class, go through all the bytecode in it and instrument any occurences of new/newarray/anewarray/multianewarray with pre- and post-allocation hooks.
static void premain(String agentArgs, Instrumentation inst)
           
 byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] origBytes)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

premain

public static void premain(String agentArgs,
                           Instrumentation inst)

transform

public byte[] transform(ClassLoader loader,
                        String className,
                        Class<?> classBeingRedefined,
                        ProtectionDomain protectionDomain,
                        byte[] origBytes)
Specified by:
transform in interface ClassFileTransformer

instrument

public static byte[] instrument(byte[] originalBytes,
                                String recorderClass,
                                String recorderMethod)
Given the bytes representing a class, go through all the bytecode in it and instrument any occurences of new/newarray/anewarray/multianewarray with pre- and post-allocation hooks. Even more fun, intercept calls to the reflection API's Array.newInstance() and instrument those too.

Parameters:
originalBytes - the original byte[] code.
recorderClass - the String internal name of the class containing the recorder method to run.
recorderMethod - the String name of the recorder method to run.
Returns:
the instrumented byte[] code.

instrument

public static byte[] instrument(byte[] originalBytes)
See Also:
documentation for the 3-arg version. This is a convenience version that uses the recorder in this class.


Copyright © 2009-2011 Google, Inc.. All Rights Reserved.