diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-01-29 20:52:10 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-10-18 17:35:59 +0200 |
commit | b2bd146c993a2d92819c741bf8786d843daea5db (patch) | |
tree | 98a4ba5011ab2826cc2bc31ca517c11e6bdb0a42 /src/reflect/scala/reflect/internal/pickling | |
parent | 0c358219923d0133b70fdf1638b29bcc5ac456d7 (diff) | |
download | scala-b2bd146c993a2d92819c741bf8786d843daea5db.tar.gz scala-b2bd146c993a2d92819c741bf8786d843daea5db.tar.bz2 scala-b2bd146c993a2d92819c741bf8786d843daea5db.zip |
reflection no longer uses enteringPhase and friends
Mentioned methods mutate the global `atPhaseStack` variable, which can
easily lead to imbalances and, ultimately, to the empty stack error.
Luckily for us, there's only one dummy phase, SomePhase, which is used
by runtime reflection, so there is absolutely zero need to invoke atPhase
in non-compiler reflexive universes.
The cleanest solution would be to override `atPhase` for runtime reflection,
but it's @inline final, so I didn't want to pay performance penalties for
something that's used three times in runtime reflection (during unpickling, in
reflection-specific completers and in `Symbol.typeParams/unsafeTypeParams`).
Therefore I added overrideable analogues of `atPhase` and `atPhaseNotLaterThan`
which are called from the aforementioned code shared between the compiler and
runtime reflection. I also had to duplicate the code of `Symbol.XXXtypeParams`
(only in SynchronizedSymbols, not in normal Symbols) again due to those
methods being very performance-sensitive.
Diffstat (limited to 'src/reflect/scala/reflect/internal/pickling')
-rw-r--r-- | src/reflect/scala/reflect/internal/pickling/UnPickler.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index c4f1f0cf96..a6c34935ad 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -659,7 +659,7 @@ abstract class UnPickler { override def complete(sym: Symbol) : Unit = try { val tp = at(i, () => readType(sym.isTerm)) // after NMT_TRANSITION, revert `() => readType(sym.isTerm)` to `readType` if (p ne null) - enteringPhase(p) (sym setInfo tp) + slowButSafeEnteringPhase(p) (sym setInfo tp) if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) } @@ -677,7 +677,7 @@ abstract class UnPickler { super.complete(sym) var alias = at(j, readSymbol) if (alias.isOverloaded) - alias = enteringPhase(picklerPhase)((alias suchThat (alt => sym.tpe =:= sym.owner.thisType.memberType(alt)))) + alias = slowButSafeEnteringPhase(picklerPhase)((alias suchThat (alt => sym.tpe =:= sym.owner.thisType.memberType(alt)))) sym.asInstanceOf[TermSymbol].setAlias(alias) } |