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

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

public class CallOnThreadJoinStrategy
extends AInsertAtOpcodeStrategy

Instrumentation strategy that adds code to java.lang.Thread.join to call SyncPointBuffer.randomDelay.

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 _varClassName
          Name of the class containing the enabled flag.
protected  java.lang.String _varName
          Name of the enabled flag.
 
Fields inherited from class edu.rice.cs.cunit.instrumentors.util.AInsertAtOpcodeStrategy
_afterOpcodePredicate, _beforeOpcodePredicate, _classPredicate, _methodPredicate, OPCODE_NEVER
 
Constructor Summary
CallOnThreadJoinStrategy(java.lang.String className, java.lang.String methodName, java.lang.String varClassName, java.lang.String varName)
          Create a new strategy.
 
Method Summary
 void done()
          Instrumentation of all classes is done.
 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.delayThreadExit.
 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
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.


_varClassName

protected java.lang.String _varClassName
Name of the class containing the enabled flag.


_varName

protected java.lang.String _varName
Name of the enabled flag.

Constructor Detail

CallOnThreadJoinStrategy

public CallOnThreadJoinStrategy(java.lang.String className,
                                java.lang.String methodName,
                                java.lang.String varClassName,
                                java.lang.String varName)
Create a new strategy.

Parameters:
className - name of the class containing the method to be called
methodName - name of the method to be called
varClassName - name of the class containing the enabled flag
varName - name of the enabled flag
Method Detail

insertInstructionsBefore

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

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

done

public void done()
Instrumentation of all classes is done.

Specified by:
done in interface IInstrumentationStrategy
Overrides:
done in class AInsertAtOpcodeStrategy