Chromium Code Reviews| Index: lib/compiler/implementation/compiler.dart |
| diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart |
| index afc6146a8de6b700c1aabf4723fd20e30cc94d49..fc158eb064d52f5d15d82014b437dac24ee99923 100644 |
| --- a/lib/compiler/implementation/compiler.dart |
| +++ b/lib/compiler/implementation/compiler.dart |
| @@ -169,7 +169,6 @@ class Compiler implements DiagnosticListener { |
| Backend backend; |
| ConstantHandler constantHandler; |
| EnqueueTask enqueuer; |
| - int pass = 1; |
| static final SourceString MAIN = const SourceString('main'); |
| static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| @@ -179,7 +178,12 @@ class Compiler implements DiagnosticListener { |
| const SourceString('startRootIsolate'); |
| bool enabledNoSuchMethod = false; |
| - Stopwatch codegenProgress; |
| + Stopwatch progress; |
| + |
| + static final int PHASE_RESOLVING = 0; |
| + static final int PHASE_COMPILING = 1; |
| + static final int PHASE_RECOMPILING = 2; |
| + int phase; |
|
ahe
2012/06/15 14:33:16
I agree, this field is a compiler.phase. Perhaps w
Søren Gjesse
2012/06/18 06:40:36
Added scanning.
|
| Compiler([this.tracer = const Tracer(), |
| this.enableTypeAssertions = false, |
| @@ -188,7 +192,7 @@ class Compiler implements DiagnosticListener { |
| validateUnparse = false]) |
| : libraries = new Map<String, LibraryElement>(), |
| world = new World(), |
| - codegenProgress = new Stopwatch.start() { |
| + progress = new Stopwatch.start() { |
| namer = new Namer(this); |
| constantHandler = new ConstantHandler(this); |
| scanner = new ScannerTask(this); |
| @@ -421,14 +425,17 @@ class Compiler implements DiagnosticListener { |
| world.populate(this, libraries.getValues()); |
| log('Resolving...'); |
| + phase = PHASE_RESOLVING; |
| backend.enqueueHelpers(enqueuer.resolution); |
| processQueue(enqueuer.resolution, main); |
| log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); |
| log('Compiling...'); |
| + phase = PHASE_COMPILING; |
| processQueue(enqueuer.codegen, main); |
| log("Recompiling ${enqueuer.codegen.recompilationCandidates.length} " |
| "methods..."); |
| + phase = PHASE_RECOMPILING; |
| processRecompilationQueue(enqueuer.codegen); |
| log('Compiled ${codegenWorld.generatedCode.length} methods.'); |
| @@ -440,7 +447,7 @@ class Compiler implements DiagnosticListener { |
| processQueue(Enqueuer world, Element main) { |
| backend.processNativeClasses(world, libraries.getValues()); |
| world.addToWorkList(main); |
| - codegenProgress.reset(); |
| + progress.reset(); |
| world.forEach((WorkItem work) { |
| withCurrentElement(work.element, () => work.run(this, world)); |
| }); |
| @@ -450,11 +457,11 @@ class Compiler implements DiagnosticListener { |
| } |
| processRecompilationQueue(Enqueuer world) { |
| - pass = 2; |
| + assert(phase == PHASE_RECOMPILING); |
| while (!world.recompilationCandidates.isEmpty()) { |
| WorkItem work = world.recompilationCandidates.next(); |
| - var oldCode = world.universe.generatedCode[work.element]; |
| world.universe.generatedCode.remove(work.element); |
| + var oldCode = world.universe.generatedCode[work.element]; |
| withCurrentElement(work.element, () => work.run(this, world)); |
| var newCode = world.universe.generatedCode[work.element]; |
| if (REPORT_PASS2_OPTIMIZATIONS && newCode != oldCode) { |
| @@ -533,6 +540,14 @@ class Compiler implements DiagnosticListener { |
| TreeElements analyze(WorkItem work, Enqueuer world) { |
| if (work.isAnalyzed()) return work.resolutionTree; |
| + if (progress.elapsedInMs() > 500) { |
| + // TODO(ahe): Add structured diagnostics to the compiler API and |
| + // use it to separate this from the --verbose option. |
| + if (phase == PHASE_RESOLVING) { |
| + log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); |
|
ahe
2012/06/15 14:33:16
Nice, but the line is too long :-)
Søren Gjesse
2012/06/18 06:40:36
Done.
|
| + progress.reset(); |
| + } |
| + } |
| Element element = work.element; |
| TreeElements result = world.getCachedElements(element); |
| if (result !== null) return result; |
| @@ -547,11 +562,15 @@ class Compiler implements DiagnosticListener { |
| String codegen(WorkItem work, Enqueuer world) { |
| if (world !== enqueuer.codegen) return null; |
| - if (codegenProgress.elapsedInMs() > 500) { |
| + if (progress.elapsedInMs() > 500) { |
| // TODO(ahe): Add structured diagnostics to the compiler API and |
| // use it to separate this from the --verbose option. |
| - log('Compiled ${codegenWorld.generatedCode.length} methods.'); |
| - codegenProgress.reset(); |
| + if (phase == PHASE_COMPILING) { |
| + log('Compiled ${codegenWorld.generatedCode.length} methods.'); |
| + } else { |
| + log('Recompiled ${world.recompilationCandidates.processed} methods.'); |
| + } |
| + progress.reset(); |
| } |
| if (work.element.kind.category == ElementCategory.VARIABLE) { |
| constantHandler.compileWorkItem(work); |