Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: dart/lib/compiler/implementation/compiler.dart

Issue 10542073: RFC: Resolution based tree-shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/compiler.dart
diff --git a/dart/lib/compiler/implementation/compiler.dart b/dart/lib/compiler/implementation/compiler.dart
index 2b4679c73003466009e44e4fbf641bcc0d964b2b..755d053a379d863723d88a6de467ecf5347cafed 100644
--- a/dart/lib/compiler/implementation/compiler.dart
+++ b/dart/lib/compiler/implementation/compiler.dart
@@ -15,7 +15,17 @@ class WorkItem {
String run(Compiler compiler, Enqueuer world) {
String code = world.universe.generatedCode[element];
if (code !== null) return code;
- if (!isAnalyzed()) compiler.analyze(this);
+ if (!isAnalyzed()) {
+ resolutionTree = world.getCachedElements(element);
kasperl 2012/06/12 05:50:12 So getCachedElements has the side-effect that this
ahe 2012/06/12 06:22:48 getCachedElements does not have side-effects. Assi
+ if (!isAnalyzed()) compiler.analyze(this);
+ }
+ if (world.isFirstQueue) {
+ world.resolvedElements[element] = resolutionTree;
+ return null;
+ }
+ if (resolutionTree === null) {
+ compiler.internalError('Error: unresolved element', element: element);
+ }
return compiler.codegen(this);
}
}
@@ -366,31 +376,40 @@ class Compiler implements DiagnosticListener {
// should know this.
world.populate(this, libraries.getValues());
- // Not yet ready to process the enqueuer.resolution queue...
- // processQueue(enqueuer.resolution);
+ log('Resolving');
+ processQueue(enqueuer.resolution, main);
+ log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
+
+ log('Compiling');
processQueue(enqueuer.codegen, main);
backend.assembleProgram();
- if (!enqueuer.codegen.queue.isEmpty()) {
- internalErrorOnElement(enqueuer.codegen.queue.first().element,
- "work list is not empty");
- }
+ enqueuer.codegen.forEach((WorkItem work) {
+ internalErrorOnElement(work.element, "work list is not empty");
+ });
}
processQueue(Enqueuer world, Element main) {
backend.processNativeClasses(world, libraries.getValues());
world.addToWorkList(main);
codegenProgress.reset();
- while (!world.queue.isEmpty()) {
- WorkItem work = world.queue.removeLast();
+ world.forEach((WorkItem work) {
withCurrentElement(work.element, () => work.run(this, world));
- }
+ });
world.queueIsClosed = true;
assert(world.checkNoEnqueuedInvokedInstanceMethods());
world.registerFieldClosureInvocations();
}
TreeElements analyzeElement(Element element) {
+ if (element is AbstractFieldElement) {
+ return null;
+ }
+ final int allowed = ElementCategory.VARIABLE | ElementCategory.FUNCTION
+ | ElementCategory.FACTORY;
+ if (!element.isAccessor() && (element.kind.category & allowed) == 0) {
+ return null;
+ }
assert(parser !== null);
Node tree = parser.parse(element);
validator.validate(tree);
@@ -509,11 +528,16 @@ class Compiler implements DiagnosticListener {
element = currentElement;
}
Token position = element.position();
+ Uri uri = element.getCompilationUnit().script.uri;
if (position === null) {
- Uri uri = element.getCompilationUnit().script.uri;
return new SourceSpan(uri, 0, 0);
+ } else {
+ return SourceSpan.withOffsets(
+ position, position,
+ (beginOffset, endOffset) {
+ return new SourceSpan(uri, beginOffset, endOffset);
+ });
}
- return spanFromTokens(position, position);
}
Script readScript(Uri uri, [ScriptTag node]) {
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698