| Index: pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart b/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
|
| index f7f4bc11f85c3efc266f176252819e12c26571e0..46b64375a718b5d976f74e66cc012164ad02b423 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
|
| @@ -8,16 +8,13 @@ part of dart2js.optimizers;
|
| * [[ShrinkingReducer]] applies shrinking reductions to CPS terms as described
|
| * in 'Compiling with Continuations, Continued' by Andrew Kennedy.
|
| */
|
| -class ShrinkingReducer implements Pass {
|
| +class ShrinkingReducer extends Pass {
|
| _RedexVisitor _redexVisitor;
|
| Set<_ReductionTask> _worklist;
|
|
|
| static final _DeletedNode _DELETED = new _DeletedNode();
|
|
|
| - /// Applies shrinking reductions to root, mutating root in the process.
|
| - void rewrite(FunctionDefinition root) {
|
| - if (root.isAbstract) return;
|
| -
|
| + void rewriteExecutableDefinition(ExecutableDefinition root) {
|
| _worklist = new Set<_ReductionTask>();
|
| _redexVisitor = new _RedexVisitor(_worklist);
|
|
|
| @@ -25,7 +22,7 @@ class ShrinkingReducer implements Pass {
|
| new ParentVisitor().visit(root);
|
|
|
| // Sweep over the term, collecting redexes into the worklist.
|
| - _redexVisitor.visitFunctionDefinition(root);
|
| + _redexVisitor.visit(root);
|
|
|
| // Process the worklist.
|
| while (_worklist.isNotEmpty) {
|
| @@ -35,6 +32,17 @@ class ShrinkingReducer implements Pass {
|
| }
|
| }
|
|
|
| + /// Applies shrinking reductions to root, mutating root in the process.
|
| + void rewriteFieldDefinition(FieldDefinition root) {
|
| + rewriteExecutableDefinition(root);
|
| + }
|
| +
|
| + /// Applies shrinking reductions to root, mutating root in the process.
|
| + void rewriteFunctionDefinition(FunctionDefinition root) {
|
| + if (root.isAbstract) return;
|
| + rewriteExecutableDefinition(root);
|
| + }
|
| +
|
| /// Removes the given node from the CPS graph, replacing it with its body
|
| /// and marking it as deleted. The node's parent must be a [[InteriorNode]].
|
| void _removeNode(InteriorNode node) {
|
| @@ -295,6 +303,10 @@ class _RemovalRedexVisitor extends _RedexVisitor {
|
| /// Traverses the CPS term and sets node.parent for each visited node.
|
| class ParentVisitor extends RecursiveVisitor {
|
|
|
| + processFieldDefinition(FieldDefinition node) {
|
| + node.body.parent = node;
|
| + }
|
| +
|
| processFunctionDefinition(FunctionDefinition node) {
|
| node.body.parent = node;
|
| node.parameters.forEach((Parameter p) => p.parent = node);
|
|
|