Skip to content

Commit 159486a

Browse files
committed
Move plugins to ContextBase
Plugins creates two variables which are the same for all contexts in a run. So they should go to ContextBase, not contexts. For background: We are creating upwards of 500'000 contexts per second. So every variable in there counts.
1 parent 1236d8c commit 159486a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
164164
if (ctx.settings.YtestPickler.value) List("pickler")
165165
else ctx.settings.YstopAfter.value
166166

167-
val pluginPlan = ctx.addPluginPhases(ctx.base.phasePlan)
167+
val pluginPlan = ctx.base.addPluginPhases(ctx.base.phasePlan)
168168
val phases = ctx.base.squashPhases(pluginPlan,
169169
ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, stopAfter, ctx.settings.Ycheck.value)
170170
ctx.base.usePhases(phases)

compiler/src/dotty/tools/dotc/config/CompilerCommand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ object CompilerCommand {
127127
if (help.value) usageMessage
128128
else if (Xhelp.value) xusageMessage
129129
else if (Yhelp.value) yusageMessage
130-
else if (showPlugins.value) ctx.pluginDescriptions
130+
else if (showPlugins.value) ctx.base.pluginDescriptions
131131
else if (XshowPhases.value) phasesMessage
132132
else ""
133133
}

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ object Contexts {
102102
with SymDenotations
103103
with Reporting
104104
with NamerContextOps
105-
with Plugins
106105
with Cloneable { thiscontext =>
107106

108107
given Context = this
@@ -661,7 +660,8 @@ object Contexts {
661660
*/
662661
class ContextBase extends ContextState
663662
with Denotations.DenotationsBase
664-
with Phases.PhasesBase {
663+
with Phases.PhasesBase
664+
with Plugins {
665665

666666
/** The applicable settings */
667667
val settings: ScalaSettings = new ScalaSettings

compiler/src/dotty/tools/dotc/plugins/Plugins.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import config.Printers.plugins.{ println => debug }
1616
* Updated 2009/1/2 by Anders Bach Nielsen: Added features to implement SIP 00002
1717
*/
1818
trait Plugins {
19-
self: Context =>
19+
self: ContextBase =>
2020

2121
/** Load a rough list of the plugins. For speed, it
2222
* does not instantiate a compiler run. Therefore it cannot
@@ -35,8 +35,8 @@ trait Plugins {
3535
// Explicit parameterization of recover to avoid -Xlint warning about inferred Any
3636
errors foreach (_.recover[Any] {
3737
// legacy behavior ignores altogether, so at least warn devs
38-
case e: MissingPluginException => warning(e.getMessage)
39-
case e: Exception => inform(e.getMessage)
38+
case e: MissingPluginException => ctx.warning(e.getMessage)
39+
case e: Exception => ctx.inform(e.getMessage)
4040
})
4141

4242
goods map (_.get)
@@ -65,7 +65,7 @@ trait Plugins {
6565
def withoutPlug = pick(tail, plugNames)
6666
def withPlug = plug :: pick(tail, plugNames + plug.name)
6767

68-
def note(msg: String): Unit = if (ctx.settings.verbose.value) inform(msg format plug.name)
68+
def note(msg: String): Unit = if (ctx.settings.verbose.value) ctx.inform(msg format plug.name)
6969
def fail(msg: String) = { note(msg) ; withoutPlug }
7070

7171
if (plugNames contains plug.name)
@@ -103,11 +103,11 @@ trait Plugins {
103103
else _plugins
104104

105105
/** A description of all the plugins that are loaded */
106-
def pluginDescriptions: String =
106+
def pluginDescriptions(using Context): String =
107107
roughPluginsList map (x => "%s - %s".format(x.name, x.description)) mkString "\n"
108108

109109
/** Summary of the options for all loaded plugins */
110-
def pluginOptionsHelp: String =
110+
def pluginOptionsHelp(using Context): String =
111111
(for (plug <- roughPluginsList ; help <- plug.optionsHelp) yield {
112112
"\nOptions for plugin '%s':\n%s\n".format(plug.name, help)
113113
}).mkString

0 commit comments

Comments
 (0)