File tree 2 files changed +13
-1
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,12 @@ object Contexts {
313
313
final def withPhase (phase : Phase ): Context =
314
314
withPhase(phase.id)
315
315
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
+
316
322
// `creationTrace`-related code. To enable, uncomment the code below and the
317
323
// call to `setCreationTrace()` in this file.
318
324
/*
Original file line number Diff line number Diff line change @@ -797,7 +797,13 @@ object Denotations {
797
797
val transformer = ctx.base.denotTransformers(nextTransformerId)
798
798
// println(s"transforming $this with $transformer")
799
799
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.
801
807
catch {
802
808
case ex : CyclicReference =>
803
809
println(s " error while transforming $this" ) // DEBUG
You can’t perform that action at this time.
0 commit comments