dotty.tools.dotc.transform.TreeTransforms

TreeTransform

Related Doc: package TreeTransforms

abstract class TreeTransform extends DotClass

The base class of tree transforms. For each kind of tree K, there are two methods which can be overridden:

prepareForK // return a new TreeTransform which gets applied to the K // node and its children transformK // transform node of type K

If a transform does not need to visit a node or any of its children, it signals this fact by returning a NoTransform from a prepare method.

If all transforms in a group are NoTransforms, the tree is no longer traversed.

Performance analysis: Taking the dotty compiler frontend as a use case, we are aiming for a warm performance of about 4000 lines / sec. This means 6 seconds for a codebase of 24'000 lines. Of these the frontend consumes over 2.5 seconds, erasure and code generation will most likely consume over 1 second each. So we would have about 1 sec for all other transformations in our budget. Of this second, let's assume a maximum of 20% for the general dispatch overhead as opposed to the concrete work done in transformations. So that leaves us with 0.2sec, or roughly 600M processor cycles.

Now, to the amount of work that needs to be done. The codebase produces of about 250'000 trees after typechecking. Transformations are likely to make this bigger so let's assume 300K trees on average. We estimate to have about 100 micro-transformations. Let's say 5 transformation groups of 20 micro-transformations each. (by comparison, scalac has in excess of 20 phases, and most phases do multiple transformations). There are then 30M visits of a node by a transformation. Each visit has a budget of 20 processor cycles.

A more detailed breakdown: I assume that about one third of all transformations have real work to do for each node. This might look high, but keep in mind that the most common nodes are Idents and Selects, and most transformations touch these. By contrast the amount of work for generating new transformations should be negligible.

So, in 400 clock cycles we need to (1) perform a pattern match according to the type of node, (2) generate new transformations if applicable, (3) reconstitute the tree node from the result of transforming the children, and (4) chain 7 out of 20 transformations over the resulting tree node. I believe the current algorithm is suitable for achieving this goal, but there can be no wasted cycles anywhere.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. TreeTransform
  2. DotClass
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TreeTransform()

Abstract Value Members

  1. abstract def phase: MiniPhase

Concrete Value Members

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

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def atGroupEnd[T](action: (Context) ⇒ T)(implicit ctx: Context, info: TransformerInfo): T

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  16. def prepareForAlternative(tree: ast.tpd.Alternative)(implicit ctx: Context): TreeTransform

  17. def prepareForApply(tree: ast.tpd.Apply)(implicit ctx: Context): TreeTransform

  18. def prepareForAssign(tree: ast.tpd.Assign)(implicit ctx: Context): TreeTransform

  19. def prepareForBind(tree: ast.tpd.Bind)(implicit ctx: Context): TreeTransform

  20. def prepareForBlock(tree: ast.tpd.Block)(implicit ctx: Context): TreeTransform

  21. def prepareForCaseDef(tree: ast.tpd.CaseDef)(implicit ctx: Context): TreeTransform

  22. def prepareForClosure(tree: ast.tpd.Closure)(implicit ctx: Context): TreeTransform

  23. def prepareForDefDef(tree: ast.tpd.DefDef)(implicit ctx: Context): TreeTransform

  24. def prepareForIdent(tree: ast.tpd.Ident)(implicit ctx: Context): TreeTransform

  25. def prepareForIf(tree: ast.tpd.If)(implicit ctx: Context): TreeTransform

  26. def prepareForLiteral(tree: ast.tpd.Literal)(implicit ctx: Context): TreeTransform

  27. def prepareForMatch(tree: ast.tpd.Match)(implicit ctx: Context): TreeTransform

  28. def prepareForNew(tree: ast.tpd.New)(implicit ctx: Context): TreeTransform

  29. def prepareForPackageDef(tree: ast.tpd.PackageDef)(implicit ctx: Context): TreeTransform

  30. def prepareForPair(tree: ast.tpd.Pair)(implicit ctx: Context): TreeTransform

  31. def prepareForReturn(tree: ast.tpd.Return)(implicit ctx: Context): TreeTransform

  32. def prepareForSelect(tree: ast.tpd.Select)(implicit ctx: Context): TreeTransform

  33. def prepareForSelectFromTypeTree(tree: ast.tpd.SelectFromTypeTree)(implicit ctx: Context): TreeTransform

  34. def prepareForSeqLiteral(tree: ast.tpd.SeqLiteral)(implicit ctx: Context): TreeTransform

  35. def prepareForStats(trees: List[ast.tpd.Tree])(implicit ctx: Context): TreeTransform

  36. def prepareForSuper(tree: ast.tpd.Super)(implicit ctx: Context): TreeTransform

  37. def prepareForTemplate(tree: ast.tpd.Template)(implicit ctx: Context): TreeTransform

  38. def prepareForThis(tree: ast.tpd.This)(implicit ctx: Context): TreeTransform

  39. def prepareForTry(tree: ast.tpd.Try)(implicit ctx: Context): TreeTransform

  40. def prepareForTypeApply(tree: ast.tpd.TypeApply)(implicit ctx: Context): TreeTransform

  41. def prepareForTypeDef(tree: ast.tpd.TypeDef)(implicit ctx: Context): TreeTransform

  42. def prepareForTypeTree(tree: ast.tpd.TypeTree)(implicit ctx: Context): TreeTransform

  43. def prepareForTyped(tree: ast.tpd.Typed)(implicit ctx: Context): TreeTransform

  44. def prepareForUnApply(tree: ast.tpd.UnApply)(implicit ctx: Context): TreeTransform

  45. def prepareForUnit(tree: ast.tpd.Tree)(implicit ctx: Context): TreeTransform

  46. def prepareForValDef(tree: ast.tpd.ValDef)(implicit ctx: Context): TreeTransform

  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  48. def toString(): String

    Definition Classes
    AnyRef → Any
  49. def transform(tree: ast.tpd.Tree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

    Transform tree using all transforms of current group (including this one)

  50. def transformAlternative(tree: ast.tpd.Alternative)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  51. def transformApply(tree: ast.tpd.Apply)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  52. def transformAssign(tree: ast.tpd.Assign)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  53. def transformBind(tree: ast.tpd.Bind)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  54. def transformBlock(tree: ast.tpd.Block)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  55. def transformCaseDef(tree: ast.tpd.CaseDef)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  56. def transformClosure(tree: ast.tpd.Closure)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  57. def transformDefDef(tree: ast.tpd.DefDef)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  58. def transformFollowing(tree: ast.tpd.Tree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

    Transform single node using all transforms following the current one in this group

  59. def transformFollowingDeep(tree: ast.tpd.Tree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

    Transform subtree using all transforms following the current one in this group

  60. def transformIdent(tree: ast.tpd.Ident)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  61. def transformIf(tree: ast.tpd.If)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  62. def transformLiteral(tree: ast.tpd.Literal)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  63. def transformMatch(tree: ast.tpd.Match)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  64. def transformNew(tree: ast.tpd.New)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  65. def transformOther(tree: ast.tpd.Tree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  66. def transformPackageDef(tree: ast.tpd.PackageDef)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  67. def transformPair(tree: ast.tpd.Pair)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  68. def transformReturn(tree: ast.tpd.Return)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  69. def transformSelect(tree: ast.tpd.Select)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  70. def transformSelectFromTypeTree(tree: ast.tpd.SelectFromTypeTree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  71. def transformSeqLiteral(tree: ast.tpd.SeqLiteral)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  72. def transformStats(trees: List[ast.tpd.Tree])(implicit ctx: Context, info: TransformerInfo): List[ast.tpd.Tree]

  73. def transformSuper(tree: ast.tpd.Super)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  74. def transformTemplate(tree: ast.tpd.Template)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  75. def transformThis(tree: ast.tpd.This)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  76. def transformTry(tree: ast.tpd.Try)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  77. def transformTypeApply(tree: ast.tpd.TypeApply)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  78. def transformTypeDef(tree: ast.tpd.TypeDef)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  79. def transformTypeTree(tree: ast.tpd.TypeTree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  80. def transformTyped(tree: ast.tpd.Typed)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  81. def transformUnApply(tree: ast.tpd.UnApply)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  82. def transformUnit(tree: ast.tpd.Tree)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  83. def transformValDef(tree: ast.tpd.ValDef)(implicit ctx: Context, info: TransformerInfo): ast.tpd.Tree

  84. def treeTransformPhase: Phase

  85. def unsupported(methodName: String): Nothing

    Throws an UnsupportedOperationException with the given method name.

    Throws an UnsupportedOperationException with the given method name.

    Definition Classes
    DotClass
  86. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from DotClass

Inherited from AnyRef

Inherited from Any

Ungrouped