aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-11 08:55:17 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:13 +0200
commitbec4f9d2cbf7fe000efb849abd5d86a34a0a084a (patch)
treef9c50589892507c2cbce0dac6b8ed79aaa81d8fc /compiler
parenta5b6bd6ac30b3ef618314ee8eff7b1d71b0fe131 (diff)
downloaddotty-bec4f9d2cbf7fe000efb849abd5d86a34a0a084a.tar.gz
dotty-bec4f9d2cbf7fe000efb849abd5d86a34a0a084a.tar.bz2
dotty-bec4f9d2cbf7fe000efb849abd5d86a34a0a084a.zip
Better documentation of sharable structures in Names, NameKinds
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/core/NameKinds.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/core/Names.scala3
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
index bee39adaa..0f08e4701 100644
--- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala
+++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
@@ -13,6 +13,9 @@ import collection.mutable
object NameKinds {
+ // These are sharable since all NameKinds are created eagerly at the start of the program
+ // before any concurrent threads are forked. for this to work, NameKinds should never
+ // be created lazily or in modules that start running after compilers are forked.
@sharable private val simpleNameKinds = new mutable.HashMap[Int, ClassifiedNameKind]
@sharable private val qualifiedNameKinds = new mutable.HashMap[Int, QualifiedNameKind]
@sharable private val uniqueNameKinds = new mutable.HashMap[String, UniqueNameKind]
diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala
index cef55a482..a72a02844 100644
--- a/compiler/src/dotty/tools/dotc/core/Names.scala
+++ b/compiler/src/dotty/tools/dotc/core/Names.scala
@@ -134,7 +134,8 @@ object Names {
def info: NameInfo = SimpleTermNameKind.info
def underlying: TermName = unsupported("underlying")
- @sharable private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
+ @sharable // because of synchronized block in `and`
+ private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
SimpleMap.Empty[NameInfo]
private def getDerived(info: NameInfo): DerivedTermName /* | Null */= derivedNames match {