diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-11-08 11:14:59 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-11-08 14:31:16 +1000 |
commit | 44dac961782aa1193493c181e8423d7751c013ee (patch) | |
tree | 356ad7f4c5b32f7dd1ade2ccfa464e9235d6fcc7 /src/reflect/scala/reflect/internal/tpe/TypeMaps.scala | |
parent | 10c609e750a7089055b126e6231e5ddb2f2e8623 (diff) | |
download | scala-44dac961782aa1193493c181e8423d7751c013ee.tar.gz scala-44dac961782aa1193493c181e8423d7751c013ee.tar.bz2 scala-44dac961782aa1193493c181e8423d7751c013ee.zip |
Avoid name table pollution with fresh existentials
During large compilations runs, the large numbers of globally unique
fresh names for existentials captured from prefixes of `asSeenFrom`.
is a) somewhat wasteful (all these names are interned in the name table)
, and, b) form a pathological case for the current implementation of
`Names#hashValue`, which leads to overfull hash-buckets in the name table.
`hashValue` should probably be improved, but my attempts to do so have
shown a small performance degradation in some benchmarks. So this commit
starts by being more frugal with these names, only uniquely naming
within an `asSeenFrom` operation.
References scala/scala-dev#246
Diffstat (limited to 'src/reflect/scala/reflect/internal/tpe/TypeMaps.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/tpe/TypeMaps.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index ba4f2bec4b..08219c0634 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -512,6 +512,8 @@ private[internal] trait TypeMaps { && isBaseClassOfEnclosingClass(sym.owner) ) + private var capturedThisIds= 0 + private def nextCapturedThisId() = { capturedThisIds += 1; capturedThisIds } /** Creates an existential representing a type parameter which appears * in the prefix of a ThisType. */ @@ -519,7 +521,7 @@ private[internal] trait TypeMaps { capturedParams find (_.owner == clazz) match { case Some(p) => p.tpe case _ => - val qvar = clazz freshExistential nme.SINGLETON_SUFFIX setInfo singletonBounds(pre) + val qvar = clazz.freshExistential(nme.SINGLETON_SUFFIX, nextCapturedThisId()) setInfo singletonBounds(pre) _capturedParams ::= qvar debuglog(s"Captured This(${clazz.fullNameString}) seen from $seenFromPrefix: ${qvar.defString}") qvar.tpe |