Skip to content

Fix #2636: assert in Run.scala is inefficient #2640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Compiler {
* - after erasure, asSeenFrom is the identity, so every reference has a
* plain SymDenotation, as opposed to a UniqueRefDenotation.
*/
def phases: List[List[Phase]] =
List(
def phases: List[List[Phase]] = {
val allPhases = List(
List(new FrontEnd), // Compiler frontend: scanner, parser, namer, typer
List(new sbt.ExtractDependencies), // Sends information on classes' dependencies to sbt via callbacks
List(new PostTyper), // Additional checks and cleanups after type checking
Expand Down Expand Up @@ -109,6 +109,9 @@ class Compiler {
new LabelDefs), // Converts calls to labels to jumps
List(new GenBCode) // Generate JVM bytecode
)
assert(allPhases.last.last.id <= Periods.MaxPossiblePhaseId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that compiler plugins may (in future) override\filter\change phases somehow. This means that this is wrong place to test the phase-plan, because it may still change. Phases have not been combine or initialized.

Additionally, Transforms require their own periods, and they will not be set here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ are phase ids set here at all? isn't allPhases.last.last.id not yet initialized here?

allPhases
}

var runId = 1
def nextRunId = {
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import scala.util.control.NonFatal
/** A compiler run. Exports various methods to compile source files */
class Run(comp: Compiler)(implicit ctx: Context) {

assert(comp.phases.last.last.id <= Periods.MaxPossiblePhaseId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New runs are rarely created, this is not a performance critical place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this isn't needed then.

assert(ctx.runId <= Periods.MaxPossibleRunId)

var units: List[CompilationUnit] = _
Expand Down