edu.rice.cs.cunit.instrumentors.delay
Class CallOnObjectNotifyStrategy

java.lang.Object
  extended by edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
      extended by edu.rice.cs.cunit.instrumentors.delay.CallOnObjectNotifyStrategy
All Implemented Interfaces:
IInstrumentationStrategy

public class CallOnObjectNotifyStrategy
extends AInsertAtOpcodeStrategy

Instrumentation strategy that adds a delay before calls to Object.notify and Object.notifyAll.

Author:
Mathias Ricken

Field Summary
protected  java.lang.String _className
          Name of the class containing the method to be called.
protected  java.lang.String _methodName
          Name of the method to be called.
protected  java.lang.String _postVarClassName
          Name of the class containing the post-enabled flag.
protected  java.lang.String _postVarName
          Name of the post-enabled flag.
protected  java.lang.String _preVarClassName
          Name of the class containing the pre-enabled flag.
protected  java.lang.String _preVarName
          Name of the pre-enabled flag.
 
Fields inherited from class edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
_afterOpcodePredicate, _beforeOpcodePredicate, _classPredicate, _methodPredicate, OPCODE_NEVER
 
Constructor Summary
CallOnObjectNotifyStrategy(java.lang.String className, java.lang.String methodName, java.lang.String preVarClassName, java.lang.String preVarName, java.lang.String postVarClassName, java.lang.String postVarName)
          Create a new strategy.
 
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)
          Add instructions to call SyncPointBuffer.randomDelay after calls to Object.notify and Object.notifyAll.
 void insertInstructionsBefore(ClassFile cf, MethodInfo mi, InstructionList il)
          Add instructions to call SyncPointBuffer.randomDelay before calls to Object.notify and Object.notifyAll.
 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

_className

protected java.lang.String _className
Name of the class containing the method to be called.


_methodName

protected java.lang.String _methodName
Name of the method to be called.


_preVarClassName

protected java.lang.String _preVarClassName
Name of the class containing the pre-enabled flag.


_preVarName

protected java.lang.String _preVarName
Name of the pre-enabled flag.


_postVarClassName

protected java.lang.String _postVarClassName
Name of the class containing the post-enabled flag.


_postVarName

protected java.lang.String _postVarName
Name of the post-enabled flag.

Constructor Detail

CallOnObjectNotifyStrategy

public CallOnObjectNotifyStrategy(java.lang.String className,
                                  java.lang.String methodName,
                                  java.lang.String preVarClassName,
                                  java.lang.String preVarName,
                                  java.lang.String postVarClassName,
                                  java.lang.String postVarName)
Create a new strategy.

Parameters:
className - name of the class containing the method to be called
methodName - name of the method to be called
preVarClassName - name of the class containing the pre-enabled flag
preVarName - name of the pre-enabled flag
postVarClassName - name of the class containing the post-enabled flag
postVarName - name of the post-enabled flag
Method Detail

insertInstructionsBefore

public void insertInstructionsBefore(ClassFile cf,
                                     MethodInfo mi,
                                     InstructionList il)
Add instructions to call SyncPointBuffer.randomDelay before calls to Object.notify and Object.notifyAll.

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)
Add instructions to call SyncPointBuffer.randomDelay after calls to Object.notify and Object.notifyAll.

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