diff options
author | Martin Odersky <odersky@gmail.com> | 2005-09-15 15:38:36 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-09-15 15:38:36 +0000 |
commit | 9e3c3c97318f8c567ff8e6cec0c8409ad95fce2c (patch) | |
tree | 8b3780c19d260dadf28500c8a58f30f63e16fbcb | |
parent | 4d3f8e6a9853d72fdd6b70fd30f3a32273086fe1 (diff) | |
download | scala-9e3c3c97318f8c567ff8e6cec0c8409ad95fce2c.tar.gz scala-9e3c3c97318f8c567ff8e6cec0c8409ad95fce2c.tar.bz2 scala-9e3c3c97318f8c567ff8e6cec0c8409ad95fce2c.zip |
*** empty log message ***
-rwxr-xr-x | sources/scala/tools/nsc/Global.scala | 20 | ||||
-rw-r--r-- | sources/scala/tools/nsc/Settings.scala | 1 | ||||
-rw-r--r-- | sources/scala/tools/nsc/ast/Trees.scala | 5 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Symbols.scala | 8 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Types.scala | 12 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/Flatten.scala | 3 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/Mixin.scala | 2 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/UnCurry.scala | 2 |
8 files changed, 36 insertions, 17 deletions
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala index 00d04b8b93..a53da84903 100755 --- a/sources/scala/tools/nsc/Global.scala +++ b/sources/scala/tools/nsc/Global.scala @@ -12,7 +12,7 @@ import scala.collection.mutable.{HashSet,HashMap} import symtab._; import symtab.classfile.{PickleBuffer, Pickler}; -import util.ListBuffer; +import util.{ListBuffer, Statistics}; import ast._; import ast.parser._; import typechecker._; @@ -62,6 +62,10 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable val global: Global.this.type = Global.this } + object statistics extends Statistics { + val global: Global.this.type = Global.this + } + val copy = new LazyTreeCopier(); type AttrInfo = Pair[Type, List[Any]]; @@ -73,7 +77,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable def error(msg: String) = reporter.error(null, msg); def warning(msg: String) = reporter.warning(null, msg); - private def inform(msg: String) = reporter.info(null, msg, true); + def inform(msg: String) = reporter.info(null, msg, true); def informProgress(msg: String) = if (settings.verbose.value) inform("[" + msg + "]"); @@ -342,6 +346,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable else checker.checkTrees; } + if (settings.statistics.value) statistics.print(phase); } if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false); @@ -364,7 +369,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable } } informTime("total", startTime); - informStatistics; } def compileLate(file: AbstractFile): unit = @@ -446,14 +450,4 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable val printer = new icodePrinter.TextPrinter(new PrintWriter(System.out, true)); icodes.classes.foreach(printer.printClass); } - - private def informStatistics = { - inform("#identifiers : " + analyzer.idcnt); - inform("#selections : " + analyzer.selcnt); - inform("#applications: " + analyzer.appcnt); - inform("#implicits : " + analyzer.implcnt); - inform("#typecreates : " + accesses); - inform("#uniquetypes : " + uniques); - inform("#collisions : " + collisions); - } } diff --git a/sources/scala/tools/nsc/Settings.scala b/sources/scala/tools/nsc/Settings.scala index b0e13f4374..4055c49345 100644 --- a/sources/scala/tools/nsc/Settings.scala +++ b/sources/scala/tools/nsc/Settings.scala @@ -27,6 +27,7 @@ class Settings(error: String => unit) { val separate = ChoiceSetting ("-separate", "Read symbol files for separate compilation", List("yes","no"), "default"); val target = ChoiceSetting ("-target", "Specify which backend to use", List("jvm", "msil"), "jvm"); val debug = BooleanSetting("-debug", "Output debugging messages"); + val statistics = BooleanSetting("-statistics", "Print compiler statistics"); val explaintypes = BooleanSetting("-explaintypes", "Explain type errors in more detail"); val interactive = BooleanSetting("-interactive", "Interactive mode"); val uniqid = BooleanSetting("-uniqid", "Print identifiers with unique names (debugging option)"); diff --git a/sources/scala/tools/nsc/ast/Trees.scala b/sources/scala/tools/nsc/ast/Trees.scala index 80c4b6edf5..79d5d212de 100644 --- a/sources/scala/tools/nsc/ast/Trees.scala +++ b/sources/scala/tools/nsc/ast/Trees.scala @@ -12,8 +12,13 @@ import symtab.Flags._; abstract class Trees: Global { + //statistics + var nodeCount = 0; + abstract class Tree { + nodeCount = nodeCount + 1; + var pos: int = Position.NOPOS; var tpe: Type = _; diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala index bc4d4b79f1..0a27a03948 100755 --- a/sources/scala/tools/nsc/symtab/Symbols.scala +++ b/sources/scala/tools/nsc/symtab/Symbols.scala @@ -13,6 +13,11 @@ abstract class Symbols: SymbolTable { private var ids = 0; + //for statistics: + def symbolCount = ids; + var typeSymbolCount = 0; + var classSymbolCount = 0; + val emptySymbolArray = new Array[Symbol](0); /** The class for all symbols */ @@ -787,6 +792,7 @@ abstract class Symbols: SymbolTable { } def cloneSymbolImpl(owner: Symbol): Symbol = new TypeSymbol(owner, pos, name); + typeSymbolCount = typeSymbolCount + 1; } /** A class for class symbols */ @@ -848,6 +854,8 @@ abstract class Symbols: SymbolTable { } override def sourceModule = if (isModuleClass) linkedModule else NoSymbol; + + classSymbolCount = classSymbolCount + 1; } /** A class for module class symbols diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala index cf8b9da1d7..366d9995b2 100755 --- a/sources/scala/tools/nsc/symtab/Types.scala +++ b/sources/scala/tools/nsc/symtab/Types.scala @@ -31,6 +31,11 @@ import Flags._; abstract class Types: SymbolTable { import definitions._; + //staticstics + var singletonClosureCount = 0; + var compoundClosureCount = 0; + var typerefClosureCount = 0; + private var explainSwitch = false; private var checkMalformedSwitch = true; @@ -385,7 +390,10 @@ abstract class Types: SymbolTable { def supertype: Type = singleDeref; override def isStable: boolean = true; override def widen: Type = singleDeref.widen; - override def closure: Array[Type] = addClosure(this, supertype.closure); + override def closure: Array[Type] = { + singletonClosureCount = singletonClosureCount + 1; + addClosure(this, supertype.closure); + } override def toString(): String = prefixString + "type"; } @@ -499,6 +507,7 @@ abstract class Types: SymbolTable { override def closure: Array[Type] = { def computeClosure: Array[Type] = try { + compoundClosureCount = compoundClosureCount + 1; //System.out.println("computing closure of " + symbol.tpe + " " + parents);//DEBUG addClosure(symbol.tpe, glbArray(parents map (.closure))); } catch { @@ -660,6 +669,7 @@ abstract class Types: SymbolTable { if (p != phase) { closurePhase = phase; if (!isValid(p)) { + typerefClosureCount = typerefClosureCount + 1; closureCache = if (sym.isAbstractType) addClosure(this, transform(bounds.hi).closure) else transform(sym.info.closure); diff --git a/sources/scala/tools/nsc/transform/Flatten.scala b/sources/scala/tools/nsc/transform/Flatten.scala index a94b0cf0e9..6a66c86c41 100755 --- a/sources/scala/tools/nsc/transform/Flatten.scala +++ b/sources/scala/tools/nsc/transform/Flatten.scala @@ -41,7 +41,8 @@ abstract class Flatten extends InfoTransform { if (clazz.isPackageClass) { atPhase(phase.next)(decls.toList foreach (decls1 enter)) } else { - atPhase(phase.next)(clazz.owner.info); + val oldowner = clazz.owner; + atPhase(phase.next)(oldowner.info); parents1 = List.mapConserve(parents)(this); for (val sym <- decls.toList) { if (sym.isTerm) decls1 enter sym diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala index 70700da57e..5c627fa2d0 100755 --- a/sources/scala/tools/nsc/transform/Mixin.scala +++ b/sources/scala/tools/nsc/transform/Mixin.scala @@ -190,7 +190,7 @@ abstract class Mixin extends InfoTransform { private def staticRef(sym: Symbol) = { sym.owner.info; if (sym.owner.sourceModule == NoSymbol) - assert(false, "" + sym.owner + " " + sym.owner.owner.info.decls);//debug + assert(false, "" + sym + " in " + sym.owner + " in " + sym.owner.owner + " " + sym.owner.owner.info.decls.toList);//debug Select(gen.mkRef(sym.owner.sourceModule), sym); } diff --git a/sources/scala/tools/nsc/transform/UnCurry.scala b/sources/scala/tools/nsc/transform/UnCurry.scala index ba70ab3bbc..a252c47d32 100755 --- a/sources/scala/tools/nsc/transform/UnCurry.scala +++ b/sources/scala/tools/nsc/transform/UnCurry.scala @@ -155,7 +155,7 @@ abstract class UnCurry extends InfoTransform { EmptyTree, Match(Ident(exname), cases)) } - System.out.println("rewrote try: " + catches + " ==> " + catchall); + if (settings.debug.value) log("rewrote try: " + catches + " ==> " + catchall); val catches1 = typer.atOwner(currentOwner).typedCases( tree, List(catchall), ThrowableClass.tpe, WildcardType); copy.Try(tree, body, catches1, finalizer) |