-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Optimizations in Namer and Typer #5875
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
Changes from all commits
6c080c2
cb36b86
1fa0e25
533349d
3d883db
78713a9
63cdb12
92cb12b
0d68418
b23d9f4
4d9a367
fe8b2ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,11 +171,12 @@ abstract class SymbolTable extends macros.Universe | |
final val NoRunId = 0 | ||
|
||
// sigh, this has to be public or enteringPhase doesn't inline. | ||
var phStack: List[Phase] = Nil | ||
var phStack: Array[Phase] = new Array(128) | ||
var phStackIndex = 0 | ||
private[this] var ph: Phase = NoPhase | ||
private[this] var per = NoPeriod | ||
|
||
final def atPhaseStack: List[Phase] = phStack | ||
final def atPhaseStack: List[Phase] = List.tabulate(phStackIndex)(i => phStack(i)) | ||
final def phase: Phase = { | ||
if (Statistics.hotEnabled) | ||
Statistics.incCounter(SymbolTableStats.phaseCounter) | ||
|
@@ -196,11 +197,13 @@ abstract class SymbolTable extends macros.Universe | |
final def pushPhase(ph: Phase): Phase = { | ||
val current = phase | ||
phase = ph | ||
phStack ::= ph | ||
phStack(phStackIndex) = ph | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bounds check, just in case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was happy to let an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alternative would be to use an |
||
phStackIndex += 1 | ||
current | ||
} | ||
final def popPhase(ph: Phase) { | ||
phStack = phStack.tail | ||
phStack(phStackIndex) = null | ||
phStackIndex -= 1 | ||
phase = ph | ||
} | ||
|
||
|
@@ -231,9 +234,12 @@ abstract class SymbolTable extends macros.Universe | |
|
||
/** Perform given operation at given phase. */ | ||
@inline final def enteringPhase[T](ph: Phase)(op: => T): T = { | ||
val saved = pushPhase(ph) | ||
try op | ||
finally popPhase(saved) | ||
if (ph eq phase) op // opt | ||
else { | ||
val saved = pushPhase(ph) | ||
try op | ||
finally popPhase(saved) | ||
} | ||
} | ||
|
||
final def findPhaseWithName(phaseName: String): Phase = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Only store phase name?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storage wise, there isn't a difference, both are just already allocated
Object
refs.If we store the phase name, we have to eagerly call the virtual
Phase.name
inphase_=
, even though under normal circumstances we don't use the result.In general, It would be good to avoid retaining
Phase
-s as fields inGlobal
so they are eligible for GC after theRun
that spawned them has been collected. But we know we'll end up with an empty phase stack here at the end of the run, so it doesn't make a practical difference.