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

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

Issue 10537025: Prototype re-compiling methods in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use the results from the resolver when trying to detect final fields 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
Index: lib/compiler/implementation/ssa/optimize.dart
diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
index 9d2412b87b75e7ad39b3a502548b30c9142567b0..ab0b54f1d689146ea7508cf6ebb1c50005375343 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -27,11 +27,11 @@ class SsaOptimizerTask extends CompilerTask {
List<OptimizationPhase> phases = <OptimizationPhase>[
// Run trivial constant folding first to optimize
// some patterns useful for type conversion.
- new SsaConstantFolder(backend),
+ new SsaConstantFolder(backend, work),
new SsaTypeConversionInserter(compiler),
new SsaTypePropagator(compiler),
new SsaCheckInserter(backend),
- new SsaConstantFolder(backend),
+ new SsaConstantFolder(backend, work),
new SsaRedundantPhiEliminator(),
new SsaDeadPhiEliminator(),
new SsaGlobalValueNumberer(compiler),
@@ -90,10 +90,11 @@ class SsaOptimizerTask extends CompilerTask {
class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
final String name = "SsaConstantFolder";
final JavaScriptBackend backend;
+ final WorkItem work;
HGraph graph;
Compiler get compiler() => backend.compiler;
- SsaConstantFolder(this.backend);
+ SsaConstantFolder(this.backend, this.work);
void visitGraph(HGraph visitee) {
graph = visitee;
@@ -580,6 +581,27 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
if (modifiers != null) {
isFinalOrConst = modifiers.isFinal() || modifiers.isConst();
}
+ if (!compiler.resolverWorld.hasInvokedSetter(field, compiler)) {
+ // If no setter is ever used for this field it is only initialized in the
+ // initializer list.
+ isFinalOrConst = true;
+ }
+ if (!isFinalOrConst &&
+ !compiler.codegenWorld.hasInvokedSetter(field, compiler) &&
+ !compiler.codegenWorld.hasFieldSetter(field, compiler)) {
+ switch (compiler.pass) {
+ case 1:
+ compiler.enqueuer.codegen.registerRecompilationCandidate(
+ work.element);
+ break;
+ case 2:
+ // If field is not final or const but no setters are used then the
+ // field might be considered final anyway as it will be either
+ // un-initialized or initialized in the constructor initializer list.
+ isFinalOrConst = true;
+ break;
+ }
+ }
return new HFieldGet(field, node.inputs[0], isFinalOrConst: isFinalOrConst);
}
« lib/compiler/implementation/enqueue.dart ('K') | « lib/compiler/implementation/enqueue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698