scala.tools.nsc.backend.icode.analysis.TypeFlowAnalysis

MTFAGrowable

class MTFAGrowable extends MethodTFA

A full type-flow analysis on a method computes in- and out-flows for each basic block (that's what MethodTFA does).

For the purposes of Inliner, doing so guarantees that an abstract typestack-slot is available by the time an inlining candidate (a CALL_METHOD instruction) is visited. This subclass (MTFAGrowable) of MethodTFA also aims at performing such analysis on CALL_METHOD instructions, with some differences:

(a) early screening is performed while the type-flow is being computed (in an override of blockTransfer) by testing a subset of the conditions that Inliner checks later. The reasoning here is: if the early check fails at some iteration, there's no chance a follow-up iteration (with a yet more lub-ed typestack-slot) will succeed. Failure is sufficient to remove that particular CALL_METHOD from the typeflow's remainingCALLs. A forward note: in case inlining occurs at some basic block B, all blocks reachable from B get their CALL_METHOD instructions considered again as candidates (because of the more precise types that -- perhaps -- can be computed).

(b) in case the early check does not fail, no conclusive decision can be made, thus the CALL_METHOD stays isOnwatchlist.

In other words, remainingCALLs tracks those callsites that still remain as candidates for inlining, so that Inliner can focus on those. remainingCALLs also caches info about the typestack just before the callsite, so as to spare computing them again at inlining time.

Besides caching, a further optimization involves skipping those basic blocks whose in-flow and out-flow isn't needed anyway (as explained next). A basic block lacking a callsite in remainingCALLs, when visisted by the standard algorithm, won't cause any inlining. But as we know from the way type-flows are computed, computing the in- and out-flow for a basic block relies in general on those of other basic blocks. In detail, we want to focus on that sub-graph of the CFG such that control flow may reach a remaining candidate callsite. Those basic blocks not in that subgraph can be skipped altogether. That's why:

The rest of the story takes place in Inliner, which does not visit all of the method's basic blocks but only on those represented in remainingCALLs.

Source
TypeFlowAnalysis.scala
Linear Supertypes
MethodTFA, DataFlowAnalysis[TypeFlowAnalysis.this.typeFlowLattice.type], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MTFAGrowable
  2. MethodTFA
  3. DataFlowAnalysis
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MTFAGrowable()

Type Members

  1. case class Bind(l: Local, t: InferredType) extends Gen with Product with Serializable

  2. case class Const(t: TypeKind) extends InferredType with Product with Serializable

    A type that does not depend on input to the transfer function.

  3. abstract class Gen extends AnyRef

  4. abstract class InferredType extends AnyRef

  5. type P = BasicBlock

    A type for program points.

    A type for program points.

    Definition Classes
    MethodTFADataFlowAnalysis
  6. case class Push(t: InferredType) extends Gen with Product with Serializable

  7. class SimulatedStack extends AnyRef

  8. class TransferFunction extends (Elem) ⇒ Elem

    A flow transfer function of a basic block.

  9. case class TypeOfStackPos(n: Int) extends InferredType with Product with Serializable

    The type found at a stack position.

  10. case class TypeOfVar(l: Local) extends InferredType with Product with Serializable

    The type of a given local variable.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. val STRING: REFERENCE

    Definition Classes
    MethodTFA
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def backwardAnalysis(f: (P, Elem) ⇒ Elem): Unit

    .

    ...

    f

    ...

    Definition Classes
    DataFlowAnalysis
  9. final def blackballed(msym: Symbol): Boolean

    Annotations
    @inline()
  10. def blockTransfer(b: BasicBlock, in: Elem): Elem

    Definition Classes
    MTFAGrowableMethodTFA
  11. var callerLin: Traversable[BasicBlock]

  12. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. def conclusives(b: BasicBlock): List[CALL_METHOD]

  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  17. def forwardAnalysis(f: (P, Elem) ⇒ Elem): Unit

    Implements forward dataflow analysis: the transfer function is applied when inputs to a Program point change, to obtain the new output value.

    Implements forward dataflow analysis: the transfer function is applied when inputs to a Program point change, to obtain the new output value.

    f

    the transfer function.

    Definition Classes
    MTFAGrowableDataFlowAnalysis
  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def hasNoRelevantSuccs(x: BasicBlock): Boolean

  20. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  21. val in: Map[P, Elem]

    Definition Classes
    DataFlowAnalysis
  22. def init(m: IMethod): Unit

    Initialize the in/out maps for the analysis of the given method.

    Initialize the in/out maps for the analysis of the given method.

    Definition Classes
    MTFAGrowableMethodTFA
  23. def init(f: ⇒ Unit): Unit

    Definition Classes
    DataFlowAnalysis
  24. def interpret(in: Elem, i: Instruction): Elem

    Abstract interpretation for one instruction.

    Abstract interpretation for one instruction.

    Definition Classes
    MethodTFA
  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. val isOnWatchlist: Set[Instruction]

  27. def isWatching(x: BasicBlock): Boolean

  28. var iterations: Int

    the number of times we iterated before reaching a fixpoint.

    the number of times we iterated before reaching a fixpoint.

    Definition Classes
    DataFlowAnalysis
  29. def knownBeforehand(b: BasicBlock): List[CALL_METHOD]

  30. val knownNever: Set[Symbol]

  31. val knownSafe: Set[Symbol]

  32. val knownUnsafe: Set[Symbol]

  33. val lattice: TypeFlowAnalysis.this.typeFlowLattice.type

    Definition Classes
    MethodTFADataFlowAnalysis
  34. var method: IMethod

    Definition Classes
    MethodTFA
  35. def mutatingInterpret(out: Elem, i: Instruction): Elem

    Definition Classes
    MethodTFA
  36. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  37. final def notify(): Unit

    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  39. val out: Map[P, Elem]

    Definition Classes
    DataFlowAnalysis
  40. val preCandidates: Set[BasicBlock]

  41. def reinit(m: IMethod, staleOut: List[BasicBlock], inlined: Set[BasicBlock], staleIn: Set[BasicBlock]): Unit

    This method is invoked after one or more inlinings have been performed in basic blocks whose in-flow is non-bottom (this makes a difference later).

    This method is invoked after one or more inlinings have been performed in basic blocks whose in-flow is non-bottom (this makes a difference later). What we know about those inlinings is given by:

    • staleOut: These are the blocks where a callsite was inlined. For each callsite, all instructions in that block before the callsite were left in the block, and the rest moved to an afterBlock. The out-flow of these basic blocks is thus in general stale, that's why we'll add them to the TFA worklist.
    • inlined : These blocks were spliced into the method's CFG as part of inlining. Being new blocks, they haven't been visited yet by the typeflow analysis.
    • staleIn : These blocks are what doInline() calls afterBlocks, ie the new home for instructions that previously appearead after a callsite in a staleOut block.

    Based on the above information, we have to bring up-to-date the caches that forwardAnalysis and blockTransfer use to skip blocks and instructions. Those caches are relevantBBs and isOnPerimeter (for blocks) and isOnWatchlist and lastInstruction (for CALL_METHODs). Please notice that all inlined and staleIn blocks are reachable from staleOut blocks.

    The update takes place in two steps:

    (1) staleOut foreach { so => putOnRadar(linearizer linearizeAt (m, so)) } This results in initial populations for relevantBBs and isOnWatchlist. Because of the way isPreCandidate reuses previous decision-outcomes that are still valid, this already prunes some candidates standing no chance of being inlined.

    (2) populatePerimeter() Based on the CFG-subgraph determined in (1) as reflected in relevantBBs, this method detects some blocks whose typeflows aren't needed past a certain CALL_METHOD (not needed because none of its successors is relevant for the purposes of inlining, see hasNoRelevantSuccs). The blocks thus chosen are said to be "on the perimeter" of the CFG-subgraph. For each of them, its lastInstruction (after which no more typeflows are needed) is found.

  42. def reinit(f: ⇒ Unit): Unit

    Reinitialize, but keep the old solutions.

    Reinitialize, but keep the old solutions. Should be used when reanalyzing the same method, after some code transformation.

    Definition Classes
    DataFlowAnalysis
  43. val relevantBBs: Set[BasicBlock]

  44. val remainingCALLs: Map[CALL_METHOD, CallsiteInfo]

  45. def run(): Unit

    Definition Classes
    MTFAGrowableMethodTFADataFlowAnalysis
  46. var shrinkedWatchlist: Boolean

  47. var stat: Boolean

    collect statistics?

    collect statistics?

    Definition Classes
    DataFlowAnalysis
  48. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  49. def toString(): String

    Definition Classes
    AnyRef → Any
  50. val visited: HashSet[P]

    Definition Classes
    DataFlowAnalysis
  51. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  54. val worklist: Set[P]

    Definition Classes
    DataFlowAnalysis

Inherited from MethodTFA

Inherited from DataFlowAnalysis[TypeFlowAnalysis.this.typeFlowLattice.type]

Inherited from AnyRef

Inherited from Any