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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 958603002: Added VariableUse expression to tree IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/tree_ir_builder.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
index 3181b59be3448c22e0a9d4ccfecf4ca6c5606f53..2cb82d4669ea05b9bbdd40b4e656de25763463d8 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -82,14 +82,17 @@ class Builder extends cps_ir.Visitor<Node> {
return variable;
}
- Variable getMutableVariableReference(
- cps_ir.Reference<cps_ir.MutableVariable> reference) {
- if (reference.definition.host != currentElement) {
- return parent.getMutableVariableReference(reference);
+ Variable getMutableVariable(cps_ir.MutableVariable mutableVariable) {
+ if (mutableVariable.host != currentElement) {
+ return parent.getMutableVariable(mutableVariable);
}
- Variable variable = local2mutable[reference.definition];
- ++variable.readCount;
- return variable;
+ return local2mutable[mutableVariable];
+ }
+
+ VariableUse getMutableVariableReference(
Kevin Millikin (Google) 2015/02/26 12:43:18 There's probably no good reason to use Reference i
asgerf 2015/02/27 12:05:19 Done.
+ cps_ir.Reference<cps_ir.MutableVariable> reference) {
+ Variable variable = getMutableVariable(reference.definition);
+ return new VariableUse(variable);
}
/// Obtains the variable representing the given primitive. Returns null for
@@ -117,8 +120,7 @@ class Builder extends cps_ir.Visitor<Node> {
CURRENT_ELEMENT_SPANNABLE,
"Reference to ${reference.definition} has no register");
}
- ++variable.readCount;
- return variable;
+ return new VariableUse(variable);
}
ExecutableDefinition build(cps_ir.ExecutableDefinition node) {
@@ -159,14 +161,8 @@ class Builder extends cps_ir.Visitor<Node> {
FunctionDefinition buildFunction(cps_ir.FunctionDefinition node) {
currentElement = node.element;
- List<Variable> parameters = <Variable>[];
- for (cps_ir.Definition p in node.parameters) {
- Variable parameter = addFunctionParameter(p);
- assert(parameter != null);
- ++parameter.writeCount; // Being a parameter counts as a write.
- parameters.add(parameter);
- }
-
+ List<Variable> parameters =
+ node.parameters.map(addFunctionParameter).toList();
Statement body;
if (!node.isAbstract) {
returnContinuation = node.body.returnContinuation;
@@ -180,13 +176,8 @@ class Builder extends cps_ir.Visitor<Node> {
ConstructorDefinition buildConstructor(cps_ir.ConstructorDefinition node) {
currentElement = node.element;
- List<Variable> parameters = <Variable>[];
- for (cps_ir.Definition p in node.parameters) {
- Variable parameter = addFunctionParameter(p);
- assert(parameter != null);
- ++parameter.writeCount; // Being a parameter counts as a write.
- parameters.add(parameter);
- }
+ List<Variable> parameters =
+ node.parameters.map(addFunctionParameter).toList();
List<Initializer> initializers;
Statement body;
if (!node.isAbstract) {
@@ -271,12 +262,10 @@ class Builder extends cps_ir.Visitor<Node> {
Statement first, current;
void addAssignment(Variable dst, Variable src) {
- ++src.readCount;
- // `dst.writeCount` will be updated by the Assign constructor.
if (first == null) {
- first = current = new Assign(dst, src, null);
+ first = current = new Assign(dst, new VariableUse(src), null);
} else {
- current = current.next = new Assign(dst, src, null);
+ current = current.next = new Assign(dst, new VariableUse(src), null);
}
}
@@ -454,7 +443,7 @@ class Builder extends cps_ir.Visitor<Node> {
}
Statement visitSetMutableVariable(cps_ir.SetMutableVariable node) {
- Variable variable = getMutableVariableReference(node.variable);
+ Variable variable = getMutableVariable(node.variable.definition);
Expression value = getVariableReference(node.value);
return new Assign(variable, value, visit(node.body));
}
@@ -490,7 +479,7 @@ class Builder extends cps_ir.Visitor<Node> {
assert(node.arguments.length == 1);
return new Return(getVariableReference(node.arguments.single));
} else {
- List<Expression> arguments = translatePhiArguments(node.arguments);
+ List<Variable> arguments = translatePhiArguments(node.arguments);
return buildPhiAssignments(cont.parameters, arguments,
() {
// Translate invocations of recursive and non-recursive

Powered by Google App Engine
This is Rietveld 408576698