Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
59 src/insane/alias/PointToAnalysis.scala
@@ -17,14 +17,16 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
import global._
import PointToGraphs._
- object PTAnalysisModes extends Enumeration {
- val PreciseAnalysis = Value("PreciseAnalysis")
- val BluntAnalysis = Value("BluntAnalysis")
- val ReductionAnalysis = Value("ReductionAnalysis")
+ sealed abstract class PTAnalysisModes {
+
}
- type AnalysisMode = PTAnalysisModes.Value
- import PTAnalysisModes._
+ object PreciseAnalysis extends PTAnalysisModes
+ object BluntAnalysis extends PTAnalysisModes
+ object ReductionAnalysis extends PTAnalysisModes
+ object ConditionalAnalysis extends PTAnalysisModes
+
+ type AnalysisMode = PTAnalysisModes
class PointToAnalysisPhase extends SubPhase {
@@ -296,7 +298,7 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
reporter.decIndent()
- fun.flatPTCFGs += sig -> oldCFG
+ fun.flatPTCFGs += sig -> oldCFG
fun.flatPTCFGsTime += sig -> (fun.flatPTCFGsTime(sig) + (System.currentTimeMillis - tStart))
settings.ifDebug {
@@ -476,6 +478,11 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
val targetsToConsider = targets.groupBy(_.sym).map{ case (sym, urs) => UnresolvedTargetInfo(sym, urs.map(_.sig).reduce(_ combine _)) }.toSet.filter(t => !excludedTargets(t.sym))
analysisMode match {
+ case ConditionalAnalysis =>
+ // In this mode, we always find one target, the pure method
+ // corresponding to aam.meth, we will inline it in a blunt fashion
+ Left(Set(ResolvedTargetInfo(buildPureEffect(aam.meth), TypeSignature.fromDeclaration(aam.meth))), BluntAnalysis)
+
case PreciseAnalysis =>
if (targets.isEmpty) {
Right("no target could be found", true, true)
@@ -1830,7 +1837,8 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
settings.ifVerbose {
reporter.warn("Gave up while analyzing "+fun.uniqueName +" (Reason was: "+reason+") (level: "+level+", stack size: "+analysisStack.size+")")
}
- reporter.msg("Bleh: "+aue.getStackTrace)
+
+ aue.printStackTrace
oResult = Some(constructFlatCFG(fun, aa.cfg, TopPTEnv))
} else {
@@ -1850,8 +1858,8 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
}
}
- settings.ifDebug {
- if (analysisStack.size > 0) {
+ if (analysisStack.size > 0) {
+ settings.ifDebug {
oResult match {
case Some(result) =>
if (result.isTop) {
@@ -1878,8 +1886,11 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
reporter.debug("Got no result.. will retry")
}
- reporter.msg("... continuing analyzing "+analysisStack.top.cfg.symbol.fullName)
+ }
+
+ reporter.msg("... continuing analyzing "+analysisStack.top.cfg.symbol.fullName)
+ settings.ifDebug {
withDebugCounter { cnt =>
dumpCFG(analysisStack.top.cfg, "continue-"+cnt+".dot")
}
@@ -2153,13 +2164,29 @@ trait PointToAnalysis extends PointToGraphsDefs with PointToEnvs with PointToLat
workList = fun :: workList
} else {
// Finished analyzing fun
- numberAnalyzed += 1
-
- if (cfgAfter.isFlat && cfgAfter.isPure) {
- lastPures.append(fun.symbol)
- numberPure += 1
+ resultsStats.total += 1
+
+ val category = if (cfgAfter.isFlat) {
+ if (cfgAfter.isTop) {
+ resultsStats.top +=1
+ "top "
+ } else if (cfgAfter.isBottom) {
+ resultsStats.bot +=1
+ "bottom "
+ } else if (cfgAfter.isPure) {
+ resultsStats.pure +=1
+ "pure "
+ } else {
+ resultsStats.impure +=1
+ "impure "
+ }
+ } else {
+ resultsStats.condImpure +=1
+ "condImpure"
}
+ lastResults.append((fun.symbol, category))
+
ptProgressBar.tick
ptProgressBar.draw()
}
View
8 src/insane/alias/PointToEnvs.scala
@@ -773,7 +773,13 @@ trait PointToEnvs extends PointToGraphsDefs {
}
}
- val nodesGrouped: Map[DupNodeID, Set[Node]] = ptGraph.V.filter(n => n.isInstanceOf[INode] || n.isInstanceOf[LNode]).groupBy(DupNode.fromNode _)
+ def groupingCandidate(n: Node): Boolean = n match {
+ case _: INode => true
+ case LNode(from, _, _, _) if from != GBNode => true
+ case _ => false
+ }
+
+ val nodesGrouped: Map[DupNodeID, Set[Node]] = ptGraph.V.filter(groupingCandidate).groupBy(DupNode.fromNode _)
var newEnv = this
View
7 src/insane/alias/PointToGraphsDefs.scala
@@ -325,16 +325,19 @@ trait PointToGraphsDefs {
def pureEffectBuilder(ctx: (FunctionCFG, PTEnv)) = {
val (cfg, env) = ctx
+ var newEnv = env
val retval = cfg.retval
val retInfo = TypeInfo.subtypeOf(retval.tpe)
val retNode = if (isGroundTypeInfo(retInfo)) {
typeToLitNode(retval.tpe)
} else {
- INode(NoUniqueID, false, cfg.retval.tpe.typeSymbol)
+ val lnode = LNode(GBNode, NoField, NoUniqueID, SigEntry.fromTypeInfo(retInfo))
+ newEnv = newEnv.addOEdge(GBNode, NoField, lnode)
+ lnode
}
- val newEnv = env.addNode(retNode).setL(retval, Set(retNode))
+ newEnv = newEnv.addNode(retNode).setL(retval, Set(retNode))
(cfg, newEnv)
}
View
2 src/insane/types/TypeSignatures.scala
@@ -64,7 +64,7 @@ trait TypeSignatures { self: AnalysisComponent =>
val res = if (!fieldsSig.isEmpty) {
// We have at least one field that is precise
- FieldsSigEntry(info, fieldsSig.toMap)
+ FieldsSigEntry(info, fieldsSig.toMap).limitDepth(depth)
} else {
sig
}
View
23 src/insane/utils/Context.scala
@@ -97,10 +97,17 @@ trait Context {
var analysisStack = Stack[AnalysisContext]()
var currentContext: AnalysisContext = null
- var lastPures = new RingBuffer[Symbol](10)
+ var lastResults = new RingBuffer[(Symbol, String)](10)
- var numberPure = 0
- var numberAnalyzed = 0
+ case class ResultStats(var pure: Int = 0,
+ var impure: Int = 0,
+ var condPure: Int = 0,
+ var condImpure: Int = 0,
+ var bot: Int = 0,
+ var top: Int = 0,
+ var total: Int = 0)
+
+ var resultsStats = ResultStats()
def dumpAnalysisStack() {
println(" ** Dumping Analysis Stacktrace: **")
@@ -118,10 +125,14 @@ trait Context {
debugOutput.println(str)
}
- o("#pure/#analyzed: "+numberPure+"/"+numberAnalyzed)
+ def n(i: Integer) = {
+ String.format("%4d", i)
+ }
+
+ o("#P: "+n(resultsStats.pure)+" | #IP: "+n(resultsStats.impure)+" | #CP: "+n(resultsStats.condPure)+" | #CIP: "+n(resultsStats.condImpure)+" | #B: "+n(resultsStats.bot)+" | #T: "+n(resultsStats.top)+" | #T: "+n(resultsStats.total))
- for (sym <- lastPures.contents) {
- o(" -> "+uniqueFunctionName(sym))
+ for ((sym, result) <- lastResults.contents) {
+ o(" -> ["+result+"] "+uniqueFunctionName(sym))
}
//o("Detected as recursive: ")

No commit comments for this range

Something went wrong with that request. Please try again.