class L1PurityAnalysis extends AbstractPurityAnalysis
An inter-procedural analysis to determine a method's purity.
- Source
- L1PurityAnalysis.scala
- Note
This analysis is sound only up to the usual standards, i.e. it does not cope with VirtualMachineErrors and may be unsound in the presence of native code, reflection or
,sun.misc.Unsafe
. Calls to native methods are generally handled soundly as they are considered org.opalj.br.fpcf.properties.ImpureByAnalysis. There are no soundness guarantees in the presence of load-time transformation. Soundness in general depends on the soundness of the analyses that compute properties used by this analysis, e.g. field mutability.This analysis is sound even if the three address code hierarchy is not flat, it will produce better results for a flat hierarchy, though. This is because it will not assess the types of expressions other than org.opalj.tac.Vars.
,This analysis derives all purity levels except for the
Externally
variants. A configurable DomainSpecificRater is used to identify calls, expressions and exceptions that areLBDPure
instead ofLBImpure
or anySideEffectFree
purity level. Compared to theL0PurityAnalysis
, it deals with all methods, even if their reference type parameters are mutable. It can handle accesses of (effectively) final instance fields, array loads, array length and virtual/interface calls. Array stores and field writes as well as (useless) synchronization on locally created, non-escaping objects/arrays are also handled. Newly allocated objects/arrays returned from callees are not identified.
- Alphabetic
- By Inheritance
- L1PurityAnalysis
- AbstractPurityAnalysis
- FPCFAnalysis
- ProjectBasedAnalysis
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait AnalysisState extends AnyRef
The state of the analysis.
The state of the analysis. Analyses are expected to extend this trait with the information they need.
lbPurity - The current minimum possible purity level for the method ubPurity - The current maximum purity level for the method method - The currently analyzed method context - The corresponding Context to report results for declClass - The declaring class of the currently analyzed method code - The code of the currently analyzed method
- Definition Classes
- AbstractPurityAnalysis
- class State extends AnalysisState
Holds the state of this analysis.
- type StateType = State
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- type V = DUVar[ValueInformation]
The type of the TAC domain.
The type of the TAC domain.
- Definition Classes
- AbstractPurityAnalysis
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def atMost(newLevel: Purity)(implicit state: StateType): Unit
Reduces the minPurity and maxPurity of the current method to at most the given purity level.
Reduces the minPurity and maxPurity of the current method to at most the given purity level.
- Definition Classes
- AbstractPurityAnalysis
- def baseMethodPurity(context: Context): ProperPropertyComputationResult
Retrieves and commits the methods purity as calculated for its declaring class type for the current DefinedMethod that represents the non-overwritten method in a subtype.
Retrieves and commits the methods purity as calculated for its declaring class type for the current DefinedMethod that represents the non-overwritten method in a subtype.
- Definition Classes
- AbstractPurityAnalysis
- final def ch: ClassHierarchy
- Definition Classes
- ProjectBasedAnalysis
- def checkFieldAssignability(ep: EOptionP[Field, FieldAssignability], objRef: Option[Expr[V]])(implicit state: StateType): Unit
Examines the influence that a given field mutability has on the method's purity.
Examines the influence that a given field mutability has on the method's purity.
- Definition Classes
- AbstractPurityAnalysis
- def checkMethodPurity(ep: EOptionP[Context, Purity], params: Seq[Expr[V]])(implicit state: State): Boolean
Examines the influence of the purity property of a method on the examined method's purity.
Examines the influence of the purity property of a method on the examined method's purity.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- Note
Adds dependendies when necessary.
- def checkPurityOfCallees(calleesEOptP: EOptionP[DeclaredMethod, Callees])(implicit state: StateType): Boolean
Examines the effect that the purity of all potential callees has on the purity of the method.
Examines the effect that the purity of all potential callees has on the purity of the method.
- Definition Classes
- AbstractPurityAnalysis
- def checkPurityOfExpr(expr: Expr[V])(implicit state: StateType): Boolean
Examines an expression for its influence on the method's purity.
Examines an expression for its influence on the method's purity. This method will return false for impure expressions, so evaluation can be terminated early.
- Definition Classes
- AbstractPurityAnalysis
- def checkPurityOfFieldRef(fieldRef: FieldRead[V])(implicit state: StateType): Unit
Examines whether a field read influences a method's purity.
Examines whether a field read influences a method's purity. Reading values from fields that are not (effectively) final may cause nondeterministic behavior, so the method can only be side-effect free.
- Definition Classes
- AbstractPurityAnalysis
- def checkPurityOfMethod(callee: Context, params: Seq[Expr[V]])(implicit state: StateType): Boolean
- Definition Classes
- AbstractPurityAnalysis
- def checkPurityOfReturn(returnValue: Expr[V])(implicit state: StateType): Unit
Examines the effect of returning a value on the method's purity.
Examines the effect of returning a value on the method's purity. Returning a reference to a mutable object or array may cause nondeterministic behavior as the object/array may be modified between invocations of the method, so the method can only be side-effect free. E.g., a given parameter which references a mutable object is returned (and not otherwise accessed).
- Definition Classes
- AbstractPurityAnalysis
- def checkPurityOfStmt(stmt: Stmt[V])(implicit state: StateType): Boolean
Examines a statement for its influence on the method's purity.
Examines a statement for its influence on the method's purity. This method will return false for impure statements, so evaluation can be terminated early.
- Definition Classes
- AbstractPurityAnalysis
- def checkTypeImmutability(ep: EOptionP[ObjectType, Property], returnValue: Expr[V])(implicit state: StateType): Boolean
Examines the effect that the mutability of a returned value's type has on the method's purity.
Examines the effect that the mutability of a returned value's type has on the method's purity.
- Definition Classes
- AbstractPurityAnalysis
- implicit final def classHierarchy: ClassHierarchy
- Definition Classes
- ProjectBasedAnalysis
- def cleanupDependees()(implicit state: State): Unit
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- val configuredPurity: ConfiguredPurity
- Definition Classes
- AbstractPurityAnalysis
- def continuation(eps: SomeEPS)(implicit state: State): ProperPropertyComputationResult
Continuation to handle updates to properties of dependees.
Continuation to handle updates to properties of dependees. Dependees may be
- methods called (for their purity)
- fields read (for their mutability)
- classes files for class types returned (for their mutability)
- implicit val declaredMethods: DeclaredMethods
- Attributes
- protected[this]
- Definition Classes
- AbstractPurityAnalysis
- def determineMethodPurity(cfg: CFG[Stmt[V], TACStmts[V]])(implicit state: State): ProperPropertyComputationResult
Determines the purity of a method once TACAI is available.
- def determinePurity(context: Context): ProperPropertyComputationResult
Determines the purity of the given method.
Determines the purity of the given method.
- context
A method call context
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def doDeterminePurity(e: Entity): ProperPropertyComputationResult
Called when the analysis is scheduled lazily.
Called when the analysis is scheduled lazily.
- Definition Classes
- AbstractPurityAnalysis
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def getCall(stmt: Stmt[V]): Call[V]
- Definition Classes
- AbstractPurityAnalysis
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def getTACAI(method: Method)(implicit state: StateType): Option[TACode[TACMethodParameter, V]]
Returns the TACode for a method if available, registering dependencies as necessary.
Returns the TACode for a method if available, registering dependencies as necessary.
- Definition Classes
- AbstractPurityAnalysis
- def handleCalleesUpdate(callees: EOptionP[DeclaredMethod, Callees])(implicit state: StateType): Unit
If the callees property is not yet final, adds the necessary dependee.
If the callees property is not yet final, adds the necessary dependee.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def handleTACAI(ep: EOptionP[Method, properties.TACAI])(implicit state: State): Unit
Handles what to do if the TACAI is not yet final.
Handles what to do if the TACAI is not yet final.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def handleUnknownFieldAssignability(ep: EOptionP[Field, FieldAssignability], objRef: Option[Expr[V]])(implicit state: State): Unit
If the given objRef is not local, adds the dependee necessary if the field mutability is not known yet.
If the given objRef is not local, adds the dependee necessary if the field mutability is not known yet.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def handleUnknownTypeImmutability(ep: EOptionP[ObjectType, Property], expr: Expr[V])(implicit state: State): Unit
If the given expression is not local, adds the dependee necessary if the type mutability is not known yet.
If the given expression is not local, adds the dependee necessary if the type mutability is not known yet.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def isDomainSpecificCall(call: Call[V], receiver: Option[Expr[V]])(implicit state: StateType): Boolean
Examines whether a call constitutes a domain-specific action using the domain-specific rater.
Examines whether a call constitutes a domain-specific action using the domain-specific rater. If it is, the maxPurity will be reduced to at most the domain-specific purity returned by the domain-specific rater.
- Definition Classes
- AbstractPurityAnalysis
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLocal(expr: Expr[V], otherwise: Purity, excludedDefSites: IntTrieSet = EmptyIntTrieSet)(implicit state: State): Boolean
Checks if a reference was created locally, hence actions on it might not influence purity.
Checks if a reference was created locally, hence actions on it might not influence purity.
- otherwise
The maxPurity will be reduced to at most this level if the expression is not local.
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- Note
Fresh references can be treated as non-escaping as the analysis result will be impure if anything escapes the method via parameters, static field assignments or calls.
- def isSourceOfImmediateException(origin: ValueOrigin)(implicit state: StateType): Boolean
Checks whether the statement, which is the origin of an exception, directly created the exception or if the VM instantiated the exception.
Checks whether the statement, which is the origin of an exception, directly created the exception or if the VM instantiated the exception. Here, we are only concerned about the exceptions thrown by the instructions not about exceptions that are transitively thrown; e.g. if a method is called. TODO We need this method because currently, for exceptions that terminate the method, no definitions are recorded. Once this is done, use that information instead to determine whether it may be an immediate exception or not.
- Definition Classes
- AbstractPurityAnalysis
- implicit final def logContext: LogContext
- Definition Classes
- ProjectBasedAnalysis
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- implicit final def p: SomeProject
- Definition Classes
- ProjectBasedAnalysis
- val project: SomeProject
- Definition Classes
- L1PurityAnalysis → ProjectBasedAnalysis
- implicit final val propertyStore: PropertyStore
- Definition Classes
- FPCFAnalysis
- final def ps: PropertyStore
- Definition Classes
- FPCFAnalysis
- val rater: DomainSpecificRater
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- val raterFqn: String
- Definition Classes
- L1PurityAnalysis → AbstractPurityAnalysis
- def reducePurityLB(newLevel: Purity)(implicit state: StateType): Unit
Reduces the maxPurity of the current method to at most the given purity level.
Reduces the maxPurity of the current method to at most the given purity level.
- Definition Classes
- AbstractPurityAnalysis
- def resolveDomainSpecificRater(fqn: String): DomainSpecificRater
- Definition Classes
- AbstractPurityAnalysis
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- implicit val typeIterator: TypeIterator
- Attributes
- protected[this]
- Definition Classes
- AbstractPurityAnalysis
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated