edu.rice.cs.cunit.instrumentors.record
Class CompactRecordBufferCodeStrategy

java.lang.Object
  extended by edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
      extended by edu.rice.cs.cunit.instrumentors.record.CompactRecordBufferCodeStrategy
All Implemented Interfaces:
IInstrumentationStrategy
Direct Known Subclasses:
CompactRecordThreadExitStrategy, CompactRecordThreadStartStrategy

public class CompactRecordBufferCodeStrategy
extends AInsertAtOpcodeStrategy

Instrumentation strategy that adds code to call SyncPointBuffer.compactAdd and write a code-tid pair.

Author:
Mathias Ricken

Field Summary
protected  long _code
          Code to write to the buffer.
 
Fields inherited from class edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
_afterOpcodePredicate, _beforeOpcodePredicate, _classPredicate, _methodPredicate, OPCODE_NEVER
 
Constructor Summary
CompactRecordBufferCodeStrategy(IPredicate<ClassFile> classPredicate, IPredicate.Binary<ClassFile,MethodInfo> methodPredicate, IPredicate.Ternary<ClassFile,MethodInfo,InstructionList> opcodePredicate, long code)
          Create a new strategy with the specified predicates.
 
Method Summary
 boolean insertEndOfMethod(ClassFile cf, MethodInfo mi, InstructionList il, boolean insertBefore, boolean insertAfter)
          Insert instructions at the end of the method.
 void insertInstructionsAfter(ClassFile cf, MethodInfo mi, InstructionList il)
          Insert instructions after.
 void insertInstructionsBefore(ClassFile cf, MethodInfo mi, InstructionList il)
          Add instructions to call SyncPointBuffer.
 void modifyStackAndLocals(ClassFile cf, MethodInfo mi, InstructionList il, boolean insertBefore, boolean insertAfter, boolean insertEndOfMethod)
          Modify the stack size and number of local variables so that the added instructions can execute.
 
Methods inherited from class edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
done, instrument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_code

protected long _code
Code to write to the buffer.

Constructor Detail

CompactRecordBufferCodeStrategy

public CompactRecordBufferCodeStrategy(IPredicate<ClassFile> classPredicate,
                                       IPredicate.Binary<ClassFile,MethodInfo> methodPredicate,
                                       IPredicate.Ternary<ClassFile,MethodInfo,InstructionList> opcodePredicate,
                                       long code)
Create a new strategy with the specified predicates.

Parameters:
classPredicate - predicate that decides if this class should be instrumented
methodPredicate - predicate that decides if this method should be instrumented
opcodePredicate - predicate that decides if this opcode should be instrumented
code - code to write to the buffer
Method Detail

insertInstructionsBefore

public void insertInstructionsBefore(ClassFile cf,
                                     MethodInfo mi,
                                     InstructionList il)
Add instructions to call SyncPointBuffer. compactThreadExit.

Specified by:
insertInstructionsBefore in class AInsertAtOpcodeStrategy
Parameters:
cf - class file
mi - method information
il - instruction list

insertInstructionsAfter

public void insertInstructionsAfter(ClassFile cf,
                                    MethodInfo mi,
                                    InstructionList il)
Insert instructions after.

Specified by:
insertInstructionsAfter in class AInsertAtOpcodeStrategy
Parameters:
cf - class file
mi - method information
il - instruction list

insertEndOfMethod

public boolean insertEndOfMethod(ClassFile cf,
                                 MethodInfo mi,
                                 InstructionList il,
                                 boolean insertBefore,
                                 boolean insertAfter)
Insert instructions at the end of the method. NOTE: The method is expected to move exactly to the last instruction that was inserted. If it moves to a place before the instruction, an infinite loop may occur. If it moves to a place after the instruction, future inserts may not occur.

Specified by:
insertEndOfMethod in class AInsertAtOpcodeStrategy
Parameters:
cf - class file
mi - method information
il - instruction list
insertBefore - true if code was inserted before an opcode
insertAfter - true if code was inserted after an opcode
Returns:
true if code was inserted

modifyStackAndLocals

public void modifyStackAndLocals(ClassFile cf,
                                 MethodInfo mi,
                                 InstructionList il,
                                 boolean insertBefore,
                                 boolean insertAfter,
                                 boolean insertEndOfMethod)
Modify the stack size and number of local variables so that the added instructions can execute. Called only once per method.

Specified by:
modifyStackAndLocals in class AInsertAtOpcodeStrategy
Parameters:
cf - class file
mi - method information
il - instruction list
insertBefore - true if code was inserted before an opcode
insertAfter - true if code was inserted after an opcode
insertEndOfMethod - true if code was inserted at the end of the method