diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-12-31 12:37:14 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-12-31 12:37:14 +0000 |
commit | 31d2746757a6385f6935eae6ffaf59bb98352488 (patch) | |
tree | f8e69a3dca89f882a451e0b92ca38510de09f510 /src | |
parent | c7262dd1a2812f4cabb4c6dafcfc6fc0d4664195 (diff) | |
download | scala-31d2746757a6385f6935eae6ffaf59bb98352488.tar.gz scala-31d2746757a6385f6935eae6ffaf59bb98352488.tar.bz2 scala-31d2746757a6385f6935eae6ffaf59bb98352488.zip |
Remove symbols from the cache once they have be...
Remove symbols from the cache once they have been used to retrieve the
corresponding definition tree. no review.
Diffstat (limited to 'src')
4 files changed, 28 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index ca45f1dda9..244319a5ff 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -665,8 +665,10 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable if (settings.YprofileRes.value) { System.gc(); - println("Saving snapshot") + print("Saving snapshot..") profiler.captureSnapshot() + println("[saved]") + specializeTypes.printSpecStats() } /** Whether compilation should stop at or skip the phase with given name. */ diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 9640814216..e106ad1f9d 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -540,14 +540,14 @@ self => } } val result = locals.values.toList - if (debugIDE) for (m <- result) println(m) +// if (debugIDE) for (m <- result) println(m) result } def getTypeCompletion(pos: Position, response: Response[List[Member]]) { informIDE("getTypeCompletion " + pos) respondGradually(response) { typeMembers(pos) } - if (debugIDE) typeMembers(pos) + //if (debugIDE) typeMembers(pos) } def typeMembers(pos: Position): Stream[List[TypeMember]] = { diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 7f5f4cc1b1..1926d856be 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -159,7 +159,7 @@ abstract class SymbolLoaders { root.setInfo(new PackageClassInfoType(new Scope(), root)) val sourcepaths = classpath.sourcepaths - for (classRep <- classpath.classes ; if doLoad(classRep)) { + for (classRep <- classpath.classes if doLoad(classRep)) { ((classRep.binary, classRep.source) : @unchecked) match { case (Some(bin), Some(src)) if needCompile(bin, src) => enterToplevelsFromSource(root, classRep.name, src) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 6df4595022..650e52c9d6 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -452,7 +452,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { log("specializedClass: " + cls) for (m <- normMembers if needsSpecialization(outerEnv ++ env, m) && satisfiable(fullEnv)) { if (settings.debug.value) log(" * looking at: " + m) - if (!m.isDeferred) concreteSpecMethods += m + if (!m.isDeferred) addConcreteSpecMethod(m) // specialized members have to be overridable. if (m.hasFlag(PRIVATE)) @@ -506,7 +506,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val specVal = specializedOverload(cls, m, env) - concreteSpecMethods += m + addConcreteSpecMethod(m) specVal.asInstanceOf[TermSymbol].setAlias(m) enterMember(specVal) @@ -662,7 +662,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { if (settings.debug.value) log("specializeMember %s with tps: %s stvars(sym): %s".format(sym, tps, specializedTypeVars(sym))) val tps1 = if (sym.isConstructor) tps filter (tp => sym.info.paramTypes.contains(tp)) else tps val tps2 = tps1 intersect specializedTypeVars(sym).toList - if (!sym.isDeferred) concreteSpecMethods += sym + if (!sym.isDeferred) addConcreteSpecMethod(sym) specializeOn(tps2) map {m => info(m) = SpecialOverload(sym, typeEnv(m)); m} } else @@ -746,7 +746,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val om = specializedOverload(clazz, overridden, env) log("Added specialized overload for %s in env: %s with type: %s".format(overriding.fullName, env, om.info)) typeEnv(om) = env - concreteSpecMethods += overriding + addConcreteSpecMethod(overriding) if (!overriding.isDeferred) { // concrete method // if the override is a normalized member, 'om' gets the implementation from // its original target, and adds the environment of the normalized member (that is, @@ -1019,6 +1019,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { body(tree.symbol) = rhs // body(tree.symbol) = tree // whole method parameters(tree.symbol) = vparamss map (_ map (_.symbol)) + concreteSpecMethods -= tree.symbol } // no need to descend further down inside method bodies case ValDef(mods, name, tpt, rhs) if concreteSpecMethods(tree.symbol) => @@ -1089,7 +1090,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { if (settings.debug.value) log("[%s] looking at Select: %s sym: %s: %s [tree.tpe: %s]".format(tree.pos.line, tree, symbol, symbol.info, tree.tpe)) - if (!specializedTypeVars(symbol.info).isEmpty && name != nme.CONSTRUCTOR) { + if (specializedTypeVars(symbol.info).nonEmpty && name != nme.CONSTRUCTOR) { val env = unify(symbol.tpe, tree.tpe, emptyEnv) if (settings.debug.value) log("checking for rerouting: " + tree + " with sym.tpe: " + symbol.tpe + " tree.tpe: " + tree.tpe + " env: " + env) if (!env.isEmpty) { @@ -1415,6 +1416,16 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Concrete methods that use a specialized type, or override such methods. */ private val concreteSpecMethods: mutable.Set[Symbol] = new mutable.HashSet + /** Add method m to the set of symbols for which we need an implementation tree + * in the tree transformer. + * + * @note This field is part of the specializeTypes subcomponent, so any symbols + * that here are not garbage collected at the end of a compiler run! + */ + def addConcreteSpecMethod(m: Symbol) { + if (currentRun.compiles(m)) concreteSpecMethods += m + } + private def makeArguments(fun: Symbol, vparams: List[Symbol]): List[Tree] = { def needsCast(tp1: Type, tp2: Type): Boolean = !(tp1 <:< tp2) @@ -1451,4 +1462,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } + def printSpecStats() { + println(" concreteSpecMembers: %7d".format(concreteSpecMethods.size)) + println(" overloads: %7d".format(overloads.size)) + println(" typeEnv: %7d".format(typeEnv.size)) + println(" info: %7d".format(info.size)) + } } |