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

Conversation

abeln
Copy link
Contributor

@abeln abeln commented May 31, 2017

Move the assert after the declaration of the phases.

Tested:
Compiled one program and nothing blew up.

Move the assert after the declaration of the phases.

Tested:
Compiled one program and nothing blew 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.

@@ -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?

@abeln abeln closed this May 31, 2017
@abeln abeln deleted the move-assert branch June 7, 2017 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants