Skip to content

Avoid creating most trees in GenBCode #3085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,26 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}.bits

def isQualifierSafeToElide(qual: Tree): Boolean = tpd.isIdempotentExpr(qual)

private val desugared = new java.util.IdentityHashMap[Type, tpd.Select]

def desugarIdent(i: Ident): Option[tpd.Select] = {
i.tpe match {
case TermRef(prefix: TermRef, name) =>
Some(tpd.ref(prefix).select(i.symbol))
case TermRef(prefix: ThisType, name) =>
Some(tpd.This(prefix.cls).select(i.symbol))
case TermRef(NoPrefix, name) =>
if (i.symbol is Flags.Method) Some(This(i.symbol.topLevelClass).select(i.symbol)) // workaround #342 todo: remove after fixed
else None
case _ => None
var found = desugared.get(i.tpe)
if (found == null) {
i.tpe match {
case TermRef(prefix: TermRef, name) =>
found = tpd.ref(prefix).select(i.symbol)
case TermRef(prefix: ThisType, name) =>
found = tpd.This(prefix.cls).select(i.symbol)
case TermRef(NoPrefix, name) =>
if (i.symbol is Flags.Method) found = This(i.symbol.topLevelClass).select(i.symbol) // workaround #342 todo: remove after fixed
case _ =>
}
if (found != null) desugared.put(i.tpe, found)
}
if (found == null) None else Some(found)
}

def getLabelDefOwners(tree: Tree): Map[Tree, List[LabelDef]] = {
// for each rhs of a defdef returns LabelDefs inside this DefDef
val res = new collection.mutable.HashMap[Tree, List[LabelDef]]()
Expand Down Expand Up @@ -892,8 +900,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def parents: List[Type] = tp.parents
}



object Assign extends AssignDeconstructor {
def _1: Tree = field.lhs
def _2: Tree = field.rhs
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ class Run(comp: Compiler, ictx: Context) {
}
}
ctx.informTime(s"$phase ", start)
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
for (unit <- units)
Stats.record(s"retained typed trees at end of $phase", unit.tpdTree.treeSize)
}
if (!ctx.reporter.hasErrors) Rewrites.writeBack()
for (unit <- units)
Stats.record("retained typed trees at end", unit.tpdTree.treeSize)
Stats.record("total trees at end", ast.Trees.ntrees)
}

private sealed trait PrintedTree
Expand Down