Skip to content

Commit

Permalink
use more descriptive names
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Oct 25, 2023
1 parent 51abd42 commit e92a834
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
38 changes: 19 additions & 19 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint

def doAdvanceUnit()(using Context): Unit =
trackProgress: progress =>
progress.unitc += 1 // trace that we completed a unit in the current (sub)phase
progress.currentUnitCount += 1 // trace that we completed a unit in the current (sub)phase
progress.refreshProgress()

def doAdvanceLate()(using Context): Unit =
trackProgress: progress =>
progress.latec += 1 // trace that we completed a late compilation
progress.currentLateUnitCount += 1 // trace that we completed a late compilation
progress.refreshProgress()

private def doEnterPhase(currentPhase: Phase)(using Context): Unit =
Expand All @@ -210,22 +210,22 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint

private def doAdvancePhase(currentPhase: Phase, wasRan: Boolean)(using Context): Unit =
trackProgress: progress =>
progress.unitc = 0 // reset unit count in current (sub)phase
progress.subtraversalc = 0 // reset subphase index to initial
progress.seen += 1 // trace that we've seen a (sub)phase
progress.currentUnitCount = 0 // reset unit count in current (sub)phase
progress.currentCompletedSubtraversalCount = 0 // reset subphase index to initial
progress.seenPhaseCount += 1 // trace that we've seen a (sub)phase
if wasRan then
// add an extra traversal now that we completed a (sub)phase
progress.traversalc += 1
progress.completedTraversalCount += 1
else
// no subphases were ran, remove traversals from expected total
progress.totalTraversals -= currentPhase.traversals

private def doAdvanceSubPhase()(using Context): Unit =
trackProgress: progress =>
progress.unitc = 0 // reset unit count in current (sub)phase
progress.seen += 1 // trace that we've seen a (sub)phase
progress.traversalc += 1 // add an extra traversal now that we completed a (sub)phase
progress.subtraversalc += 1 // record that we've seen a subphase
progress.currentUnitCount = 0 // reset unit count in current (sub)phase
progress.seenPhaseCount += 1 // trace that we've seen a (sub)phase
progress.completedTraversalCount += 1 // add an extra traversal now that we completed a (sub)phase
progress.currentCompletedSubtraversalCount += 1 // record that we've seen a subphase
if !progress.isCancelled() then
progress.tickSubphase()

Expand Down Expand Up @@ -498,12 +498,12 @@ object Run {
private class Progress(cb: ProgressCallback, private val run: Run, val initialTraversals: Int):
export cb.{cancel, isCancelled}

private[Run] var totalTraversals: Int = initialTraversals // track how many phases we expect to run
private[Run] var unitc: Int = 0 // current unit count in the current (sub)phase
private[Run] var latec: Int = 0 // current late unit count
private[Run] var traversalc: Int = 0 // completed traversals over all files
private[Run] var subtraversalc: Int = 0 // completed subphases in the current phase
private[Run] var seen: Int = 0 // how many phases we've seen so far
var totalTraversals: Int = initialTraversals // track how many phases we expect to run
var currentUnitCount: Int = 0 // current unit count in the current (sub)phase
var currentLateUnitCount: Int = 0 // current late unit count
var completedTraversalCount: Int = 0 // completed traversals over all files
var currentCompletedSubtraversalCount: Int = 0 // completed subphases in the current phase
var seenPhaseCount: Int = 0 // how many phases we've seen so far

private var currPhase: Phase = uninitialized // initialized by enterPhase
private var subPhases: SubPhases = uninitialized // initialized by enterPhase
Expand All @@ -519,21 +519,21 @@ object Run {

/** Compute the current (sub)phase name and next (sub)phase name */
private[Run] def tickSubphase()(using Context): Unit =
val index = subtraversalc
val index = currentCompletedSubtraversalCount
val s = subPhases
currPhaseName = s.subPhase(index)
nextPhaseName =
if index + 1 < s.all.size then s.subPhase(index + 1)
else s.next match
case None => "<end>"
case Some(next0) => next0.subPhase(0)
if seen > 0 then
if seenPhaseCount > 0 then
refreshProgress()


/** Counts the number of completed full traversals over files, plus the number of units in the current phase */
private def currentProgress(): Int =
traversalc * work() + unitc + latec
completedTraversalCount * work() + currentUnitCount + currentLateUnitCount

/**Total progress is computed as the sum of
* - the number of traversals we expect to make over all files
Expand Down
5 changes: 0 additions & 5 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ object Contexts {
val local = progressCallback
if local != null then op(local)

def cancelSignalRecorded: Boolean =
val local = progressCallback
val noSignalRecieved = local == null || !local.isCancelled
!noSignalRecieved // if true then cancel request was recorded

/** The current plain printer */
def printerFn: Context => Printer = store(printerFnLoc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dotty.tools.dotc.CompilationUnit;

public interface ProgressCallback {
/** Record that the cancellation signal has been recieved during the Zinc run. */
/** Record that the cancellation signal has been received during the Zinc run. */
default void cancel() {}

/** Report on if there was a cancellation signal for the current Zinc run. */
Expand Down

0 comments on commit e92a834

Please sign in to comment.