aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-22 10:58:18 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-24 18:56:48 +0100
commitafb74449e0443d321da4b79e776eab376fdc51b1 (patch)
treea8f9101da583018b398f18c8b95c9e5fd18e5110 /src/dotty/tools/dotc
parenta4e2a6ed89c33f8c79c7129cc493bff0f84e044c (diff)
downloaddotty-afb74449e0443d321da4b79e776eab376fdc51b1.tar.gz
dotty-afb74449e0443d321da4b79e776eab376fdc51b1.tar.bz2
dotty-afb74449e0443d321da4b79e776eab376fdc51b1.zip
More statistics for created and retained trees
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala12
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala2
-rw-r--r--src/dotty/tools/dotc/typer/FrontEnd.scala5
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala4
4 files changed, 20 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index f4f1260f4..12a635ce6 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -297,6 +297,18 @@ object Trees {
def orElse[U >: Untyped <: T](that: => Tree[U]): Tree[U] =
if (this eq genericEmptyTree) that else this
+ /** The number of nodes in this tree */
+ def treeSize: Int = {
+ var s = 1
+ def addSize(elem: Any): Unit = elem match {
+ case t: Tree[_] => s += t.treeSize
+ case ts: List[_] => ts foreach addSize
+ case _ =>
+ }
+ productIterator foreach addSize
+ s
+ }
+
override def toText(printer: Printer) = printer.toText(this)
override def hashCode(): Int = System.identityHashCode(this)
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index e8ccbf38a..720d0b41d 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -195,7 +195,7 @@ class TypeComparer(initctx: Context) extends DotClass {
val saved = constraint
val savedSuccessCount = successCount
val savedTotalCount = totalCount
- if (Stats.monitored) Stats.record(s"isSubType ${tp1.show} <:< ${tp2.show}")
+ //if (Stats.monitored) Stats.record(s"isSubType ${tp1.show} <:< ${tp2.show}")
try {
recCount += 1
/* !!! DEBUG
diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala
index 1cea9fe7c..0161c1f6f 100644
--- a/src/dotty/tools/dotc/typer/FrontEnd.scala
+++ b/src/dotty/tools/dotc/typer/FrontEnd.scala
@@ -6,6 +6,7 @@ import Phases._
import Contexts._
import parsing.Parsers.Parser
import config.Printers._
+import util.Stats._
class FrontEnd extends Phase {
@@ -35,13 +36,17 @@ class FrontEnd extends Phase {
val unit = ctx.compilationUnit
unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
typr.println("typed: "+unit.source)
+ record("retainedUntypedTrees", unit.untpdTree.treeSize)
+ record("retainedTypedTrees", unit.tpdTree.treeSize)
}
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): Unit = {
val unitContexts = units map (unit => ctx.fresh.withCompilationUnit(unit))
unitContexts foreach (parse(_))
+ record("parsedTrees", ast.Trees.ntrees)
unitContexts foreach (enterSyms(_))
unitContexts foreach (typeCheck(_))
+ record("totalTrees", ast.Trees.ntrees)
}
override def run(implicit ctx: Context): Unit = {
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 25721ad74..49792cb73 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -28,7 +28,7 @@ import util.SourcePosition
import collection.mutable
import annotation.tailrec
import Implicits._
-import util.Stats.track
+import util.Stats.{track, record}
import config.Printers._
import language.implicitConversions
@@ -959,7 +959,7 @@ class Typer extends Namer with Applications with Implicits {
}
def typedUnadapted(initTree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = {
-
+ record("typedUnadapted")
val xtree = expanded(initTree)
xtree.removeAttachment(TypedAhead) match {
case Some(ttree) => ttree