|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.softevo.jdynpur.eval.PurityTraceAnalyser
public class PurityTraceAnalyser
This class implements dynamic purity analysis of an execution trace file. The main idea of the analysis is as follows:
Nested Class Summary | |
---|---|
static class |
PurityTraceAnalyser.ParameterMutabilityInformation
|
Field Summary | |
---|---|
protected boolean |
excludeAPIMethodsFromResults
Flag indicating if API methods should be excluded from the result data structures. |
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
executedMethodIdentifiers
The set of executed MethodIdentifiers . |
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> |
executedMethodIds
The set of executed methods. |
protected org.softevo.util.ObjectIdMapper<org.softevo.util.asm.FieldIdentifier> |
fieldIdentifierMap
|
protected java.lang.String |
fileName
The name of the trace file to be analyzed. |
protected org.softevo.util.asm.MethodIdentifierMapGenerator |
identifierMap
Identifier map used for this trace. |
protected boolean |
ignoreEffectsOfStaticInitializers
Flag indicating if the effects of static initializers should be ignored. |
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
impureMethodIdentifiers
The set of MethodIdentifiers known to be impure. |
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> |
impureMethodIds
The set of method ids known to be impure. |
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> |
methodsModifyingThisObject
The set of methods known to modify the object they were invoked on. |
protected java.util.Vector<java.lang.Long> |
mutabilityChangeEntries
|
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,PurityTraceAnalyser.ParameterMutabilityInformation> |
parameterMutabilityInformation
|
protected boolean |
printResults
Flag if pure method identifiers should be printed to System.out . |
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
pureMethodIdentifiers
The set of MethodIdentifiers known to be pure. |
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> |
pureMethodIds
The set of method ids that might be pure. |
protected java.util.Vector<java.lang.Long> |
purityChangeEntries
|
protected PurityResults |
results
|
protected java.lang.String |
resultsFileName
Name of the file where results are saved. |
protected boolean |
saveResults
Flag if results shall be saved. |
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
thisModifyingMethodIdentifiers
The set of MethodIdentifiers modifying a this object. |
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashSet<java.lang.Integer>>> |
threadIdToCreatedObjectSetStackMap
A map of thread ids to a stack of object identifiers created in a method. |
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.Integer>> |
threadIdToMethodCallStackMap
A map of thread ids to a method call stack. |
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashSet<java.lang.Integer>>> |
threadIdToModifiedObjectSetStackMap
A map of thread ids to a stack of object identifiers modified in a method. |
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashMap<java.lang.Integer,java.lang.Integer>>> |
threadIdToParameterSetStackMap
|
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.Integer>> |
threadIdToThisStackMap
A map of thread ids to a stack of this object identifiers for active non-static methods. |
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.String>> |
threadIdToThisTypeMap
A map of thread ids to a stack of this type for active non-static methods. |
protected boolean |
verbose
Flag for verbose output. |
Constructor Summary | |
---|---|
PurityTraceAnalyser(java.lang.String fileName,
java.lang.String resultsFileName,
boolean saveResults,
boolean analyseParameterMutability)
Creates a new purity analyser for a trace file. |
Method Summary | |
---|---|
protected void |
addToHashMap(java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> map,
int methodId,
java.lang.String className)
|
void |
analyse(boolean verbose,
boolean printResults)
Starts analysis of the trace. |
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
convertMap(java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> map)
|
protected java.util.Stack<java.util.HashSet<java.lang.Integer>> |
getCreatedObjectSetStack(int threadId)
Gets the created object set stack for a given thread. |
java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
getExecutedMethodIdentifiers()
Gets the set of executed methods. |
java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
getImpureMethodIdentifiers()
Gets the set of impure methods. |
protected java.util.Stack<java.lang.Integer> |
getMethodCallStack(int threadId)
Gets the method call stack for a given thread. |
protected java.util.Stack<java.util.HashSet<java.lang.Integer>> |
getModifiedObjectSetStack(int threadId)
Gets the modified object set stack for a given thread. |
java.util.HashMap<org.softevo.util.asm.MethodIdentifier,PurityTraceAnalyser.ParameterMutabilityInformation> |
getParameterMutabilityInformation()
|
protected java.util.Stack<java.util.HashMap<java.lang.Integer,java.lang.Integer>> |
getParameterSetStack(int threadId)
|
java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
getPureMethodIdentifiers()
Gets the set of pure methods. |
PurityResults |
getResults()
|
java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> |
getThisModifyingMethodIdentifiers()
Gets the set of executed methods. |
protected java.util.Stack<java.lang.Integer> |
getThisObjectStack(int threadId)
Gets the this object stack for a given thread. |
protected java.util.Stack<java.lang.String> |
getThisTypeStack(int threadId)
|
protected java.util.HashSet<java.lang.Integer> |
getTransitiveStateForObject(int objectId)
|
protected void |
handleArrayCreation(int objectId,
int threadId)
Called to handle an array creation event. |
protected void |
handleArrayModification(int objectId,
int threadId)
Called to handle an array modification event. |
protected void |
handleDynamicMethodEnd(int methodId,
int threadId)
Handles end of a dynamic method. |
protected void |
handleDynamicMethodStart(int methodId,
int thisObjectId,
int threadId,
java.lang.String className)
Handles start of a dynamic method. |
protected void |
handleFieldWrite(int objectId,
int threadId)
Called to handle a field write event. |
protected void |
handleMethodEnd(int methodId,
int threadId,
java.lang.String className)
Handles method end events. |
protected void |
handleMethodStart(int methodId,
int threadId,
java.lang.String className)
Handles a method start event. |
protected void |
handleObjectArrayModification(int threadId,
int changedObjectId,
int arrayIndex,
int newObjectId)
|
protected void |
handleObjectCreation(int objectId,
int threadId)
Handles object creation event. |
protected void |
handleObjectFieldWrite(int fieldId,
int threadId,
int changedObjectId,
int newValueObjectId)
|
protected void |
handleParameter(int index,
int threadId,
int objectId)
|
protected void |
handleStaticFieldWrite(int threadId)
Called to handle a static field write event. |
protected void |
handleStaticMethodEnd(int methodId,
int threadId)
Handles end of a static method. |
protected void |
handleStaticMethodStart(int methodId,
int threadId)
Handles start of a static method. |
protected void |
handleTraceEnd()
This method is called upon end of the trace. |
protected boolean |
isAPIMethod(int methodId)
This method checks if the integer passed identifies a user or an API method. |
static void |
main(java.lang.String[] args)
Launches purity trace analysis. |
protected void |
processParameterModification(java.util.HashMap<java.lang.Integer,java.lang.Integer> parameters,
java.util.HashSet<java.lang.Integer> modifiedObjects,
int methodId,
java.lang.String className)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String fileName
protected java.lang.String resultsFileName
protected org.softevo.util.asm.MethodIdentifierMapGenerator identifierMap
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> impureMethodIds
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> pureMethodIds
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> executedMethodIds
protected java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> methodsModifyingThisObject
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> pureMethodIdentifiers
MethodIdentifiers
known to be pure.
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> thisModifyingMethodIdentifiers
MethodIdentifiers
modifying a this object.
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> impureMethodIdentifiers
MethodIdentifiers
known to be impure.
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> executedMethodIdentifiers
MethodIdentifiers
.
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashSet<java.lang.Integer>>> threadIdToCreatedObjectSetStackMap
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashMap<java.lang.Integer,java.lang.Integer>>> threadIdToParameterSetStackMap
protected org.softevo.util.ObjectIdMapper<org.softevo.util.asm.FieldIdentifier> fieldIdentifierMap
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.util.HashSet<java.lang.Integer>>> threadIdToModifiedObjectSetStackMap
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.Integer>> threadIdToMethodCallStackMap
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.Integer>> threadIdToThisStackMap
protected java.util.HashMap<java.lang.Integer,java.util.Stack<java.lang.String>> threadIdToThisTypeMap
protected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,PurityTraceAnalyser.ParameterMutabilityInformation> parameterMutabilityInformation
protected java.util.Vector<java.lang.Long> mutabilityChangeEntries
protected java.util.Vector<java.lang.Long> purityChangeEntries
protected PurityResults results
protected boolean verbose
protected boolean printResults
System.out
.
protected boolean saveResults
protected boolean excludeAPIMethodsFromResults
protected boolean ignoreEffectsOfStaticInitializers
Constructor Detail |
---|
public PurityTraceAnalyser(java.lang.String fileName, java.lang.String resultsFileName, boolean saveResults, boolean analyseParameterMutability)
fileName
- the name of the traceidentifierMap
- the identifier map generated together with the traceMethod Detail |
---|
public void analyse(boolean verbose, boolean printResults) throws java.io.IOException
verbose
- flag if output shall be verboseprintResults
- flag if results should be printed to System.out
java.io.IOException
- if an exception occurs reading from the traceprotected java.util.HashSet<java.lang.Integer> getTransitiveStateForObject(int objectId)
protected void handleObjectArrayModification(int threadId, int changedObjectId, int arrayIndex, int newObjectId)
protected void handleObjectFieldWrite(int fieldId, int threadId, int changedObjectId, int newValueObjectId)
protected void handleParameter(int index, int threadId, int objectId)
protected java.util.Stack<java.lang.String> getThisTypeStack(int threadId)
protected java.util.Stack<java.lang.Integer> getThisObjectStack(int threadId)
threadId
- the id of the thread
protected java.util.Stack<java.lang.Integer> getMethodCallStack(int threadId)
threadId
- the id of the thread
protected java.util.Stack<java.util.HashSet<java.lang.Integer>> getCreatedObjectSetStack(int threadId)
threadId
- the id of the thread
protected java.util.Stack<java.util.HashSet<java.lang.Integer>> getModifiedObjectSetStack(int threadId)
threadId
- the id of the thread
protected java.util.Stack<java.util.HashMap<java.lang.Integer,java.lang.Integer>> getParameterSetStack(int threadId)
protected boolean isAPIMethod(int methodId)
methodId
- the method identifierprotected java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> convertMap(java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> map)
protected void handleTraceEnd()
System.out
if the
printResults
flag is set.
protected void handleArrayCreation(int objectId, int threadId)
objectId
- the id of the new arraythreadId
- the thread idprotected void handleArrayModification(int objectId, int threadId)
objectId
- the id of the modified arraythreadId
- the thread idprotected void handleStaticFieldWrite(int threadId)
threadId
- the thread idprotected void handleFieldWrite(int objectId, int threadId)
threadId
- the thread idobjectId
- id of the modified objectprotected void handleObjectCreation(int objectId, int threadId)
objectId
- the id of the new objectthreadId
- the thread idprotected void addToHashMap(java.util.HashMap<java.lang.Integer,java.util.HashSet<java.lang.String>> map, int methodId, java.lang.String className)
protected void handleMethodStart(int methodId, int threadId, java.lang.String className)
methodId
- the id of the method invokedthreadId
- the thread idprotected void handleDynamicMethodStart(int methodId, int thisObjectId, int threadId, java.lang.String className)
handleMethodStart
, this method also modifieds the
thisObjectStack
.
methodId
- the method identifierthisObjectId
- the identifier of the this objectthreadId
- the id of the threadprotected void handleStaticMethodStart(int methodId, int threadId)
handleMethodStart
methodId
- the identifier of the methodthreadId
- the thread idprotected void handleStaticMethodEnd(int methodId, int threadId)
handleMethodEnd
.
methodId
- the id of the methodthreadId
- the thread idprotected void handleDynamicMethodEnd(int methodId, int threadId)
handleMethodEnd
, this method also modifies the
thisObjectStack
methodId
- the id of the methodthreadId
- the thread idprotected void handleMethodEnd(int methodId, int threadId, java.lang.String className)
methodId
- the id of the methodthreadId
- the thread idprotected void processParameterModification(java.util.HashMap<java.lang.Integer,java.lang.Integer> parameters, java.util.HashSet<java.lang.Integer> modifiedObjects, int methodId, java.lang.String className)
public static void main(java.lang.String[] args) throws java.io.IOException
args
- command line arguments
java.io.IOException
public java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> getImpureMethodIdentifiers()
public java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> getPureMethodIdentifiers()
public java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> getThisModifyingMethodIdentifiers()
public java.util.HashMap<org.softevo.util.asm.MethodIdentifier,java.util.HashSet<java.lang.String>> getExecutedMethodIdentifiers()
public PurityResults getResults()
public java.util.HashMap<org.softevo.util.asm.MethodIdentifier,PurityTraceAnalyser.ParameterMutabilityInformation> getParameterMutabilityInformation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |