| Index: pkg/compiler/lib/src/cps_ir/constant_propagation.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/constant_propagation.dart b/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
|
| index fcf5c1b8bb482cf7e31a748ef1afb5b0aba3b3a2..a6da66be1402f03f61a67e6027f9931f3c076170 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
|
| @@ -12,7 +12,7 @@ part of dart2js.optimizers;
|
| * Implemented according to 'Constant Propagation with Conditional Branches'
|
| * by Wegman, Zadeck.
|
| */
|
| -class ConstantPropagator implements Pass {
|
| +class ConstantPropagator extends Pass {
|
|
|
| // Required for type determination in analysis of TypeOperator expressions.
|
| final dart2js.Compiler _compiler;
|
| @@ -23,11 +23,8 @@ class ConstantPropagator implements Pass {
|
|
|
| ConstantPropagator(this._compiler, this._constantSystem);
|
|
|
| - void rewrite(FunctionDefinition root) {
|
| - if (root.isAbstract) return;
|
| -
|
| + void _rewriteExecutableDefinition(ExecutableDefinition root) {
|
| // Set all parent pointers.
|
| -
|
| new ParentVisitor().visit(root);
|
|
|
| // Analyze. In this phase, the entire term is analyzed for reachability
|
| @@ -45,6 +42,16 @@ class ConstantPropagator implements Pass {
|
| analyzer.reachableNodes, analyzer.node2value);
|
| transformer.transform(root);
|
| }
|
| +
|
| + void rewriteFunctionDefinition(FunctionDefinition root) {
|
| + if (root.isAbstract) return;
|
| + _rewriteExecutableDefinition(root);
|
| + }
|
| +
|
| + void rewriteFieldDefinition(FieldDefinition root) {
|
| + _rewriteExecutableDefinition(root);
|
| + }
|
| +
|
| }
|
|
|
| /**
|
| @@ -58,8 +65,8 @@ class _TransformingVisitor extends RecursiveVisitor {
|
|
|
| _TransformingVisitor(this.reachable, this.node2value);
|
|
|
| - void transform(FunctionDefinition root) {
|
| - visitFunctionDefinition(root);
|
| + void transform(ExecutableDefinition root) {
|
| + visit(root);
|
| }
|
|
|
| /// Given an expression with a known constant result and a continuation,
|
| @@ -226,7 +233,7 @@ class _ConstPropagationVisitor extends Visitor {
|
|
|
| _ConstPropagationVisitor(this.compiler, this.constantSystem);
|
|
|
| - void analyze(FunctionDefinition root) {
|
| + void analyze(ExecutableDefinition root) {
|
| reachableNodes.clear();
|
| defWorkset.clear();
|
| nodeWorklist.clear();
|
| @@ -304,6 +311,10 @@ class _ConstPropagationVisitor extends Visitor {
|
| setReachable(node.body);
|
| }
|
|
|
| + void visitFieldDefinition(FieldDefinition node) {
|
| + setReachable(node.body);
|
| + }
|
| +
|
| // Expressions.
|
|
|
| void visitLetPrim(LetPrim node) {
|
|
|