Skip to content

Commit 0b3592c

Browse files
committed
Move threshold values to Config
It's a more logical home for them than the Context object.
1 parent 70647c8 commit 0b3592c

File tree

5 files changed

+29
-24
lines changed

5 files changed

+29
-24
lines changed

src/dotty/tools/dotc/config/Config.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,23 @@ object Config {
7171

7272
/** Check that certain types cannot be created in erasedTypes phases */
7373
final val checkUnerased = true
74+
75+
76+
/** Initial size of superId table */
77+
final val InitialSuperIdsSize = 4096
78+
79+
/** Initial capacity of uniques HashMap */
80+
final val initialUniquesCapacity = 40000
81+
82+
/** How many recursive calls to NamedType#underlying are performed before logging starts. */
83+
final val LogPendingUnderlyingThreshold = 50
84+
85+
/** How many recursive calls to isSubType are performed before logging starts. */
86+
final val LogPendingSubTypesThreshold = 50
87+
88+
/** How many recursive calls to findMember are performed before logging names starts */
89+
final val LogPendingFindMemberThreshold = 20
90+
91+
/** Maximal number of outstanding recursive calls to findMember */
92+
final val PendingFindMemberLimit = LogPendingFindMemberThreshold * 2
7493
}

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import util.{FreshNameCreator, SimpleMap, SourceFile, NoSource}
2020
import typer._
2121
import Implicits.ContextualImplicits
2222
import config.Settings._
23+
import config.Config
2324
import reporting._
2425
import collection.mutable
2526
import collection.immutable.BitSet
@@ -508,7 +509,7 @@ object Contexts {
508509
def nextId = { _nextId += 1; _nextId }
509510

510511
/** A map from a superclass id to the typeref of the class that has it */
511-
private[core] var classOfId = new Array[ClassSymbol](InitialSuperIdsSize)
512+
private[core] var classOfId = new Array[ClassSymbol](Config.InitialSuperIdsSize)
512513

513514
/** A map from a the typeref of a class to its superclass id */
514515
private[core] val superIdOfClass = new mutable.AnyRefMap[ClassSymbol, Int]
@@ -529,7 +530,7 @@ object Contexts {
529530

530531
// Types state
531532
/** A table for hash consing unique types */
532-
private[core] val uniques = new util.HashSet[Type](initialUniquesCapacity) {
533+
private[core] val uniques = new util.HashSet[Type](Config.initialUniquesCapacity) {
533534
override def hash(x: Type): Int = x.hash
534535
}
535536

@@ -614,20 +615,4 @@ object Contexts {
614615
myBounds = myBounds.updated(sym, b)
615616
def bounds = myBounds
616617
}
617-
618-
/** Initial size of superId table */
619-
private final val InitialSuperIdsSize = 4096
620-
621-
/** Initial capacity of uniques HashMap */
622-
private[core] final val initialUniquesCapacity = 40000
623-
624-
/** How many recursive calls to NamedType#underlying are performed before
625-
* logging starts.
626-
*/
627-
private[core] final val LogPendingUnderlyingThreshold = 50
628-
629-
/** How many recursive calls to isSubType are performed before
630-
* logging starts.
631-
*/
632-
private[core] final val LogPendingSubTypesThreshold = 50
633618
}

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
9797
try {
9898
recCount = recCount + 1
9999
val result =
100-
if (recCount < LogPendingSubTypesThreshold) firstTry(tp1, tp2)
100+
if (recCount < Config.LogPendingSubTypesThreshold) firstTry(tp1, tp2)
101101
else monitoredIsSubType(tp1, tp2)
102102
recCount = recCount - 1
103103
if (!result) constraint = saved

src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ object Types {
14261426
def isTerm = isInstanceOf[TermRef]
14271427

14281428
/** Guard against cycles that can arise if given `op`
1429-
* follows info. The prblematic cases are a type alias to itself or
1429+
* follows info. The problematic cases are a type alias to itself or
14301430
* bounded by itself or a val typed as itself:
14311431
*
14321432
* type T <: T
@@ -1437,7 +1437,7 @@ object Types {
14371437
*/
14381438
final def controlled[T](op: => T)(implicit ctx: Context): T = try {
14391439
ctx.underlyingRecursions += 1
1440-
if (ctx.underlyingRecursions < LogPendingUnderlyingThreshold)
1440+
if (ctx.underlyingRecursions < Config.LogPendingUnderlyingThreshold)
14411441
op
14421442
else if (ctx.pendingUnderlying contains this)
14431443
throw CyclicReference(symbol)

src/dotty/tools/dotc/core/Uniques.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.tools.dotc
22
package core
33

44
import Types._, Contexts._, util.Stats._, Hashable._, Names._
5+
import config.Config
56
import util.HashSet
67

78
/** Defines operation `unique` for hash-consing types.
@@ -39,7 +40,7 @@ object Uniques {
3940
)
4041
*/
4142

42-
final class NamedTypeUniques extends HashSet[NamedType](initialUniquesCapacity) with Hashable {
43+
final class NamedTypeUniques extends HashSet[NamedType](Config.initialUniquesCapacity) with Hashable {
4344
override def hash(x: NamedType): Int = x.hash
4445

4546
private def findPrevious(h: Int, prefix: Type, name: Name): NamedType = {
@@ -65,7 +66,7 @@ object Uniques {
6566
}
6667
}
6768

68-
final class TypeAliasUniques extends HashSet[TypeAlias](initialUniquesCapacity) with Hashable {
69+
final class TypeAliasUniques extends HashSet[TypeAlias](Config.initialUniquesCapacity) with Hashable {
6970
override def hash(x: TypeAlias): Int = x.hash
7071

7172
private def findPrevious(h: Int, alias: Type, variance: Int): TypeAlias = {
@@ -90,7 +91,7 @@ object Uniques {
9091
}
9192
}
9293

93-
final class RefinedUniques extends HashSet[RefinedType](initialUniquesCapacity) with Hashable {
94+
final class RefinedUniques extends HashSet[RefinedType](Config.initialUniquesCapacity) with Hashable {
9495
override val hashSeed = classOf[CachedRefinedType].hashCode // some types start life as CachedRefinedTypes, need to have same hash seed
9596
override def hash(x: RefinedType): Int = x.hash
9697

0 commit comments

Comments
 (0)