File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,12 @@ object Contexts {
313313 final def withPhase (phase : Phase ): Context =
314314 withPhase(phase.id)
315315
316+ inline def evalAt [T ](phase : Phase )(inline op : Context ?=> T ): T =
317+ val saved = period
318+ this .asInstanceOf [FreshContext ].period = Period (runId, phase.id)
319+ try op(using this )
320+ finally period = saved
321+
316322 // `creationTrace`-related code. To enable, uncomment the code below and the
317323 // call to `setCreationTrace()` in this file.
318324 /*
Original file line number Diff line number Diff line change @@ -797,7 +797,13 @@ object Denotations {
797797 val transformer = ctx.base.denotTransformers(nextTransformerId)
798798 // println(s"transforming $this with $transformer")
799799 try
800- next = atPhase(transformer)(transformer.transform(cur))
800+ util.Stats .record(" denot transform" )
801+ next = ctx.evalAt(transformer)(transformer.transform(cur))
802+ // We temporarily update the context with the new phase instead of creating a
803+ // new one. This is done for performance. We cut down on about 30% of context
804+ // creations that way, and also avoid phase caches in contexts to get large.
805+ // To work correctly, we need to demand that the context with the new phase
806+ // is not retained in the result.
801807 catch {
802808 case ex : CyclicReference =>
803809 println(s " error while transforming $this" ) // DEBUG
You can’t perform that action at this time.
0 commit comments