aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Denotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-26 11:01:02 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-26 11:03:33 +0100
commit32c041c8b40df3007783240493ed4c4708ec80db (patch)
treecc3a72cee58a4b8cdeb50674d8120fde0a3ebf66 /src/dotty/tools/dotc/core/Denotations.scala
parent311136b60d2de17f46b643d84a949b8f77411c0f (diff)
downloaddotty-32c041c8b40df3007783240493ed4c4708ec80db.tar.gz
dotty-32c041c8b40df3007783240493ed4c4708ec80db.tar.bz2
dotty-32c041c8b40df3007783240493ed4c4708ec80db.zip
Performance tweak: Denotation.symbol is a parameter.
This avoids the megamorphic dispatch on symbol before. Looked promising in the profiler (symbol showed up at 9%) but does not seem to gain much in practice. Still, can't hurt to do it.
Diffstat (limited to 'src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 137bbed34..06ab17a52 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -89,11 +89,10 @@ object Denotations {
* val y = x.f
*
* Then the denotation of `y` is `SingleDenotation(NoSymbol, A | B)`.
+ *
+ * @param symbol The referencing symbol, or NoSymbol is none exists
*/
- abstract class Denotation extends util.DotClass with printing.Showable {
-
- /** The referencing symbol, exists only for non-overloaded denotations */
- def symbol: Symbol
+ abstract class Denotation(val symbol: Symbol) extends util.DotClass with printing.Showable {
/** The type info of the denotation, exists only for non-overloaded denotations */
def info(implicit ctx: Context): Type
@@ -320,8 +319,7 @@ object Denotations {
/** An overloaded denotation consisting of the alternatives of both given denotations.
*/
- case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation {
- final def symbol: Symbol = NoSymbol
+ case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol) {
final def infoOrCompleter = multiHasNot("info")
final def info(implicit ctx: Context) = infoOrCompleter
final def validFor = denot1.validFor & denot2.validFor
@@ -360,7 +358,7 @@ object Denotations {
}
/** A non-overloaded denotation */
- abstract class SingleDenotation extends Denotation with PreDenotation {
+ abstract class SingleDenotation(symbol: Symbol) extends Denotation(symbol) with PreDenotation {
def hasUniqueSym: Boolean
protected def newLikeThis(symbol: Symbol, info: Type): SingleDenotation
@@ -590,34 +588,33 @@ object Denotations {
}
}
- abstract class NonSymSingleDenotation extends SingleDenotation {
+ abstract class NonSymSingleDenotation(symbol: Symbol) extends SingleDenotation(symbol) {
def infoOrCompleter: Type
def info(implicit ctx: Context) = infoOrCompleter
def isType = infoOrCompleter.isInstanceOf[TypeType]
}
class UniqueRefDenotation(
- val symbol: Symbol,
+ symbol: Symbol,
val infoOrCompleter: Type,
- initValidFor: Period) extends NonSymSingleDenotation {
+ initValidFor: Period) extends NonSymSingleDenotation(symbol) {
validFor = initValidFor
override def hasUniqueSym: Boolean = true
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
}
class JointRefDenotation(
- val symbol: Symbol,
+ symbol: Symbol,
val infoOrCompleter: Type,
- initValidFor: Period) extends NonSymSingleDenotation {
+ initValidFor: Period) extends NonSymSingleDenotation(symbol) {
validFor = initValidFor
override def hasUniqueSym = false
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor)
}
- class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation {
+ class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol) {
override def exists = false
override def hasUniqueSym = false
- def symbol = NoSymbol
def infoOrCompleter = NoType
validFor = Period.allInRun(ctx.runId)
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = this