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

Unified Diff: pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart

Issue 759193005: Add support for fields to the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dart2js-cps Created 6 years, 1 month 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: 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 f14ece5a98f9ee8b123bee06c896fb666b410602..4e287758b77138f11cb310f8955a746dc2c59dfb 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);

Powered by Google App Engine
This is Rietveld 408576698