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

Unified Diff: pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart

Issue 1155463005: dart2js cps: Remove dart2dart from cps pipeline and clean up. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Skip tests specific to the dart backend Created 5 years, 7 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: pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart b/pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart
index 79bf831d9d890d17b02f1f1f066371ff0df2d208..141e646e796b4f50a59c9db10328eaebbbe12efd 100644
--- a/pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart
+++ b/pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart
@@ -15,9 +15,9 @@ import '../tree_ir_nodes.dart';
class VariableMerger extends RecursiveVisitor implements Pass {
String get passName => 'Variable merger';
- void rewrite(RootNode node) {
+ void rewrite(FunctionDefinition node) {
rewriteFunction(node);
- node.forEachBody(visitStatement);
+ visitStatement(node.body);
}
@override
@@ -27,15 +27,13 @@ class VariableMerger extends RecursiveVisitor implements Pass {
/// Rewrites the given function.
/// This is called for the outermost function and inner functions.
- void rewriteFunction(RootNode node) {
- node.forEachBody((Statement body) {
- BlockGraphBuilder builder = new BlockGraphBuilder();
- builder.build(node.parameters, body);
- _computeLiveness(builder.blocks);
- Map<Variable, Variable> subst =
- _computeRegisterAllocation(builder.blocks, node.parameters);
- new SubstituteVariables(subst).apply(node);
- });
+ void rewriteFunction(FunctionDefinition node) {
+ BlockGraphBuilder builder = new BlockGraphBuilder();
+ builder.build(node);
+ _computeLiveness(builder.blocks);
+ Map<Variable, Variable> subst =
+ _computeRegisterAllocation(builder.blocks, node.parameters);
+ new SubstituteVariables(subst).apply(node);
}
}
@@ -108,10 +106,10 @@ class BlockGraphBuilder extends RecursiveVisitor {
/// them from the control-flow graph entirely.
Set<Variable> _ignoredVariables = new Set<Variable>();
- void build(List<Variable> parameters, Statement body) {
+ void build(FunctionDefinition node) {
_currentBlock = newBlock();
- parameters.forEach(write);
- visitStatement(body);
+ node.parameters.forEach(write);
+ visitStatement(node.body);
}
@override
@@ -164,11 +162,6 @@ class BlockGraphBuilder extends RecursiveVisitor {
read(node.variable);
}
- visitVariableDeclaration(VariableDeclaration node) {
- assert(node.variable.isCaptured);
- visitStatement(node.next);
- }
-
visitAssign(Assign node) {
visitExpression(node.value);
write(node.variable);
@@ -243,12 +236,6 @@ class BlockGraphBuilder extends RecursiveVisitor {
branchFrom(afterCondition);
visitExpression(node.right);
}
-
- visitFunctionDeclaration(FunctionDeclaration node) {
- // The function variable is final, hence cannot be merged.
- ignoreVariable(node.variable);
- visitStatement(node.next);
- }
}
/// Computes liveness information of the given control-flow graph.
@@ -492,11 +479,11 @@ class SubstituteVariables extends RecursiveTransformer {
return w;
}
- void apply(RootNode node) {
+ void apply(FunctionDefinition node) {
for (int i = 0; i < node.parameters.length; ++i) {
node.parameters[i] = replaceWrite(node.parameters[i]);
}
- node.replaceEachBody(visitStatement);
+ node.body = visitStatement(node.body);
}
@override
@@ -535,15 +522,4 @@ class SubstituteVariables extends RecursiveTransformer {
}
return node;
}
-
- Statement visitVariableDeclaration(VariableDeclaration node) {
- // VariableDeclaration is only used for captured variables, which are never
- // merged, so this is not strictly necessary. But it's nicer if this class
- // works for arbitrary substitution maps.
- node.variable = replaceWrite(node.variable);
- node.value = visitExpression(node.value);
- node.next = visitStatement(node.next);
- return node;
- }
-
}
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698