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

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

Issue 10537025: Prototype re-compiling methods in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created a datastructure for representing "queue2" 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 | lib/compiler/implementation/enqueue.dart » ('j') | lib/compiler/implementation/universe.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 077728977bfaf55e1091c1fb3140c7e4f0d21939..63100c9a549f3a501caad2eae838d8d8506fe74c 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -111,6 +111,8 @@ class Compiler implements DiagnosticListener {
return f();
} catch (CompilerCancelledException ex) {
throw;
+ } catch (Pass2BailoutException ex) {
+ throw;
} catch (var ex) {
unhandledExceptionOnElement(element);
throw;
@@ -130,6 +132,7 @@ 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');
@@ -381,6 +384,25 @@ class Compiler implements DiagnosticListener {
withCurrentElement(work.element, () => work.run(this, world));
}
world.queueIsClosed = true;
+ log("Recompilation candidates queue length: "
+ "${world.recompilationCandidates.length}");
+ pass = 2;
+ while (!world.recompilationCandidates.isEmpty()) {
+ WorkItem work = world.recompilationCandidates.next();
+ var oldCode = world.universe.generatedCode[work.element];
+ world.universe.generatedCode.remove(work.element);
+ try {
+ withCurrentElement(work.element, () => work.run(this, world));
+ } catch (Pass2BailoutException ex) {
+ world.universe.generatedCode[work.element] = oldCode;
+ }
+ var newCode = world.universe.generatedCode[work.element];
+ if (newCode != oldCode) {
+ log("PASS 2 OPTIMIZATION:");
+ log("Before: $oldCode");
+ log("After: $newCode");
+ }
+ }
assert(world.checkNoEnqueuedInvokedInstanceMethods());
world.registerFieldClosureInvocations();
}
@@ -463,6 +485,7 @@ class Compiler implements DiagnosticListener {
if (message.message.kind === MessageKind.METHOD_NOT_FOUND) return;
}
SourceSpan span = spanFromNode(node);
+
reportDiagnostic(span, "${magenta('warning:')} $message", false);
}
@@ -560,6 +583,15 @@ class CompilerCancelledException implements Exception {
}
}
+class Pass2BailoutException implements Exception {
+ final String reason;
+ Pass2BailoutException(this.reason);
+
+ String toString() {
+ return 'Pass 2 not supported: $reason';
+ }
+}
+
class Tracer {
final bool enabled = false;
« no previous file with comments | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | lib/compiler/implementation/universe.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698