From 24a95aa44a02d438d4df179a6475edfc690f9d9a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 May 2015 19:30:01 +0200 Subject: Move threshold values to Config It's a more logical home for them than the Context object. --- src/dotty/tools/dotc/config/Config.scala | 19 +++++++++++++++++++ src/dotty/tools/dotc/core/Contexts.scala | 21 +++------------------ src/dotty/tools/dotc/core/TypeComparer.scala | 2 +- src/dotty/tools/dotc/core/Types.scala | 4 ++-- src/dotty/tools/dotc/core/Uniques.scala | 7 ++++--- 5 files changed, 29 insertions(+), 24 deletions(-) (limited to 'src/dotty') diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala index 38ebca078..c00b06913 100644 --- a/src/dotty/tools/dotc/config/Config.scala +++ b/src/dotty/tools/dotc/config/Config.scala @@ -71,4 +71,23 @@ object Config { /** Check that certain types cannot be created in erasedTypes phases */ final val checkUnerased = true + + + /** Initial size of superId table */ + final val InitialSuperIdsSize = 4096 + + /** Initial capacity of uniques HashMap */ + final val initialUniquesCapacity = 40000 + + /** How many recursive calls to NamedType#underlying are performed before logging starts. */ + final val LogPendingUnderlyingThreshold = 50 + + /** How many recursive calls to isSubType are performed before logging starts. */ + final val LogPendingSubTypesThreshold = 50 + + /** How many recursive calls to findMember are performed before logging names starts */ + final val LogPendingFindMemberThreshold = 20 + + /** Maximal number of outstanding recursive calls to findMember */ + final val PendingFindMemberLimit = LogPendingFindMemberThreshold * 2 } diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 5d2750aa8..88923d31d 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -20,6 +20,7 @@ import util.{FreshNameCreator, SimpleMap, SourceFile, NoSource} import typer._ import Implicits.ContextualImplicits import config.Settings._ +import config.Config import reporting._ import collection.mutable import collection.immutable.BitSet @@ -508,7 +509,7 @@ object Contexts { def nextId = { _nextId += 1; _nextId } /** A map from a superclass id to the typeref of the class that has it */ - private[core] var classOfId = new Array[ClassSymbol](InitialSuperIdsSize) + private[core] var classOfId = new Array[ClassSymbol](Config.InitialSuperIdsSize) /** A map from a the typeref of a class to its superclass id */ private[core] val superIdOfClass = new mutable.AnyRefMap[ClassSymbol, Int] @@ -529,7 +530,7 @@ object Contexts { // Types state /** A table for hash consing unique types */ - private[core] val uniques = new util.HashSet[Type](initialUniquesCapacity) { + private[core] val uniques = new util.HashSet[Type](Config.initialUniquesCapacity) { override def hash(x: Type): Int = x.hash } @@ -614,20 +615,4 @@ object Contexts { myBounds = myBounds.updated(sym, b) def bounds = myBounds } - - /** Initial size of superId table */ - private final val InitialSuperIdsSize = 4096 - - /** Initial capacity of uniques HashMap */ - private[core] final val initialUniquesCapacity = 40000 - - /** How many recursive calls to NamedType#underlying are performed before - * logging starts. - */ - private[core] final val LogPendingUnderlyingThreshold = 50 - - /** How many recursive calls to isSubType are performed before - * logging starts. - */ - private[core] final val LogPendingSubTypesThreshold = 50 } diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 89c3958af..671e4556f 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -97,7 +97,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi try { recCount = recCount + 1 val result = - if (recCount < LogPendingSubTypesThreshold) firstTry(tp1, tp2) + if (recCount < Config.LogPendingSubTypesThreshold) firstTry(tp1, tp2) else monitoredIsSubType(tp1, tp2) recCount = recCount - 1 if (!result) constraint = saved diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 6e18f4a50..d5e0e3eba 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1426,7 +1426,7 @@ object Types { def isTerm = isInstanceOf[TermRef] /** Guard against cycles that can arise if given `op` - * follows info. The prblematic cases are a type alias to itself or + * follows info. The problematic cases are a type alias to itself or * bounded by itself or a val typed as itself: * * type T <: T @@ -1437,7 +1437,7 @@ object Types { */ final def controlled[T](op: => T)(implicit ctx: Context): T = try { ctx.underlyingRecursions += 1 - if (ctx.underlyingRecursions < LogPendingUnderlyingThreshold) + if (ctx.underlyingRecursions < Config.LogPendingUnderlyingThreshold) op else if (ctx.pendingUnderlying contains this) throw CyclicReference(symbol) diff --git a/src/dotty/tools/dotc/core/Uniques.scala b/src/dotty/tools/dotc/core/Uniques.scala index c24b0cabc..b00508d60 100644 --- a/src/dotty/tools/dotc/core/Uniques.scala +++ b/src/dotty/tools/dotc/core/Uniques.scala @@ -2,6 +2,7 @@ package dotty.tools.dotc package core import Types._, Contexts._, util.Stats._, Hashable._, Names._ +import config.Config import util.HashSet /** Defines operation `unique` for hash-consing types. @@ -39,7 +40,7 @@ object Uniques { ) */ - final class NamedTypeUniques extends HashSet[NamedType](initialUniquesCapacity) with Hashable { + final class NamedTypeUniques extends HashSet[NamedType](Config.initialUniquesCapacity) with Hashable { override def hash(x: NamedType): Int = x.hash private def findPrevious(h: Int, prefix: Type, name: Name): NamedType = { @@ -65,7 +66,7 @@ object Uniques { } } - final class TypeAliasUniques extends HashSet[TypeAlias](initialUniquesCapacity) with Hashable { + final class TypeAliasUniques extends HashSet[TypeAlias](Config.initialUniquesCapacity) with Hashable { override def hash(x: TypeAlias): Int = x.hash private def findPrevious(h: Int, alias: Type, variance: Int): TypeAlias = { @@ -90,7 +91,7 @@ object Uniques { } } - final class RefinedUniques extends HashSet[RefinedType](initialUniquesCapacity) with Hashable { + final class RefinedUniques extends HashSet[RefinedType](Config.initialUniquesCapacity) with Hashable { override val hashSeed = classOf[CachedRefinedType].hashCode // some types start life as CachedRefinedTypes, need to have same hash seed override def hash(x: RefinedType): Int = x.hash -- cgit v1.2.3