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

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

Issue 1743283002: dart2js cps: Use definitions by default, not references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix doc comments and long lines Created 4 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 a9c283184802fcba3a8755457a2472b3dd16263e..324f45f2b3fde2cb330595186fed02b34b229ed7 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -396,7 +396,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
NodeCallback visitLetMutable(cps_ir.LetMutable node) {
Variable variable = addMutableVariable(node.variable);
- Expression value = getVariableUse(node.value);
+ Expression value = getVariableUse(node.valueRef);
return (Statement next) => Assign.makeStatement(variable, value, next);
}
@@ -406,7 +406,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
// (not a function like interior and call expressions).
Statement visitThrow(cps_ir.Throw node) {
- Expression value = getVariableUse(node.value);
+ Expression value = getVariableUse(node.valueRef);
return new Throw(value);
}
@@ -420,13 +420,13 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
// arguments to formal parameter variables, followed by the body if
// the continuation is singly reference or a break if it is multiply
// referenced.
- cps_ir.Continuation cont = node.continuation.definition;
+ cps_ir.Continuation cont = node.continuation;
if (cont == returnContinuation) {
- assert(node.arguments.length == 1);
- return new Return(getVariableUse(node.arguments.single),
+ assert(node.argumentRefs.length == 1);
+ return new Return(getVariableUse(node.argumentRefs.single),
sourceInformation: node.sourceInformation);
} else {
- List<Expression> arguments = translateArguments(node.arguments);
+ List<Expression> arguments = translateArguments(node.argumentRefs);
return buildPhiAssignments(cont.parameters, arguments,
() {
// Translate invocations of recursive and non-recursive
@@ -456,7 +456,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
/// Translates a branch condition to a tree expression.
Expression translateCondition(cps_ir.Branch branch) {
- Expression value = getVariableUse(branch.condition);
+ Expression value = getVariableUse(branch.conditionRef);
if (branch.isStrictCheck) {
return new ApplyBuiltinOperator(
BuiltinOperator.StrictEq,
@@ -469,12 +469,12 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Statement visitBranch(cps_ir.Branch node) {
Expression condition = translateCondition(node);
Statement thenStatement, elseStatement;
- cps_ir.Continuation cont = node.trueContinuation.definition;
+ cps_ir.Continuation cont = node.trueContinuation;
assert(cont.parameters.isEmpty);
thenStatement = cont.hasExactlyOneUse
? translateExpression(cont.body)
: new Break(labels[cont]);
- cont = node.falseContinuation.definition;
+ cont = node.falseContinuation;
assert(cont.parameters.isEmpty);
elseStatement = cont.hasExactlyOneUse
? translateExpression(cont.body)
@@ -489,13 +489,13 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
//
Expression visitSetField(cps_ir.SetField node) {
- return new SetField(getVariableUse(node.object),
+ return new SetField(getVariableUse(node.objectRef),
node.field,
- getVariableUse(node.value));
+ getVariableUse(node.valueRef));
}
Expression visitInterceptor(cps_ir.Interceptor node) {
- return new Interceptor(getVariableUse(node.input),
+ return new Interceptor(getVariableUse(node.inputRef),
node.interceptedClasses,
node.sourceInformation);
}
@@ -503,14 +503,14 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitCreateInstance(cps_ir.CreateInstance node) {
return new CreateInstance(
node.classElement,
- translateArguments(node.arguments),
- getVariableUseOrNull(node.typeInformation),
+ translateArguments(node.argumentRefs),
+ getVariableUseOrNull(node.typeInformationRef),
node.sourceInformation);
}
Expression visitGetField(cps_ir.GetField node) {
- return new GetField(getVariableUse(node.object), node.field,
- objectIsNotNull: !node.object.definition.type.isNullable);
+ return new GetField(getVariableUse(node.objectRef), node.field,
+ objectIsNotNull: !node.object.type.isNullable);
}
Expression visitCreateBox(cps_ir.CreateBox node) {
@@ -520,16 +520,16 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
return new CreateInvocationMirror(
node.selector,
- translateArguments(node.arguments));
+ translateArguments(node.argumentRefs));
}
Expression visitGetMutable(cps_ir.GetMutable node) {
- return getMutableVariableUse(node.variable);
+ return getMutableVariableUse(node.variableRef);
}
Expression visitSetMutable(cps_ir.SetMutable node) {
- Variable variable = getMutableVariable(node.variable.definition);
- Expression value = getVariableUse(node.value);
+ Variable variable = getMutableVariable(node.variable);
+ Expression value = getVariableUse(node.valueRef);
return new Assign(variable, value);
}
@@ -540,18 +540,18 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitLiteralList(cps_ir.LiteralList node) {
return new LiteralList(
node.dartType,
- translateArguments(node.values));
+ translateArguments(node.valueRefs));
}
Expression visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) {
return new ReifyRuntimeType(
- getVariableUse(node.value), node.sourceInformation);
+ getVariableUse(node.valueRef), node.sourceInformation);
}
Expression visitReadTypeVariable(cps_ir.ReadTypeVariable node) {
return new ReadTypeVariable(
node.variable,
- getVariableUse(node.target),
+ getVariableUse(node.targetRef),
node.sourceInformation);
}
@@ -559,17 +559,17 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
return new TypeExpression(
node.kind,
node.dartType,
- node.arguments.map(getVariableUse).toList());
+ node.argumentRefs.map(getVariableUse).toList());
}
Expression visitTypeTest(cps_ir.TypeTest node) {
- Expression value = getVariableUse(node.value);
- List<Expression> typeArgs = translateArguments(node.typeArguments);
+ Expression value = getVariableUse(node.valueRef);
+ List<Expression> typeArgs = translateArguments(node.typeArgumentRefs);
return new TypeOperator(value, node.dartType, typeArgs, isTypeTest: true);
}
Expression visitTypeTestViaFlag(cps_ir.TypeTestViaFlag node) {
- Expression value = getVariableUse(node.interceptor);
+ Expression value = getVariableUse(node.interceptorRef);
// TODO(sra): Move !! to cps_ir level.
return new Not(new Not(new GetTypeTestProperty(value, node.dartType)));
}
@@ -581,42 +581,42 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitSetStatic(cps_ir.SetStatic node) {
return new SetStatic(
node.element,
- getVariableUse(node.value),
+ getVariableUse(node.valueRef),
node.sourceInformation);
}
Expression visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) {
if (node.operator == BuiltinOperator.IsFalsy) {
- return new Not(getVariableUse(node.arguments.single));
+ return new Not(getVariableUse(node.argumentRefs.single));
}
return new ApplyBuiltinOperator(node.operator,
- translateArguments(node.arguments));
+ translateArguments(node.argumentRefs));
}
Expression visitApplyBuiltinMethod(cps_ir.ApplyBuiltinMethod node) {
return new ApplyBuiltinMethod(node.method,
- getVariableUse(node.receiver),
- translateArguments(node.arguments),
- receiverIsNotNull: !node.receiver.definition.type.isNullable);
+ getVariableUse(node.receiverRef),
+ translateArguments(node.argumentRefs),
+ receiverIsNotNull: !node.receiver.type.isNullable);
}
Expression visitGetLength(cps_ir.GetLength node) {
- return new GetLength(getVariableUse(node.object));
+ return new GetLength(getVariableUse(node.objectRef));
}
Expression visitGetIndex(cps_ir.GetIndex node) {
- return new GetIndex(getVariableUse(node.object),
- getVariableUse(node.index));
+ return new GetIndex(getVariableUse(node.objectRef),
+ getVariableUse(node.indexRef));
}
Expression visitSetIndex(cps_ir.SetIndex node) {
- return new SetIndex(getVariableUse(node.object),
- getVariableUse(node.index),
- getVariableUse(node.value));
+ return new SetIndex(getVariableUse(node.objectRef),
+ getVariableUse(node.indexRef),
+ getVariableUse(node.valueRef));
}
Expression visitInvokeStatic(cps_ir.InvokeStatic node) {
- List<Expression> arguments = translateArguments(node.arguments);
+ List<Expression> arguments = translateArguments(node.argumentRefs);
return new InvokeStatic(node.target, node.selector, arguments,
node.sourceInformation);
}
@@ -624,17 +624,17 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitInvokeMethod(cps_ir.InvokeMethod node) {
if (node.callingConvention == cps_ir.CallingConvention.OneShotIntercepted) {
List<Expression> arguments = new List.generate(
- 1 + node.arguments.length,
- (n) => getVariableUse(n == 0 ? node.receiver : node.arguments[n - 1]),
+ 1 + node.argumentRefs.length,
+ (n) => getVariableUse(n == 0 ? node.receiverRef : node.argumentRefs[n - 1]),
growable: false);
return new OneShotInterceptor(node.selector, node.mask, arguments,
node.sourceInformation);
}
InvokeMethod invoke = new InvokeMethod(
- getVariableUse(node.receiver),
+ getVariableUse(node.receiverRef),
node.selector,
node.mask,
- translateArguments(node.arguments),
+ translateArguments(node.argumentRefs),
node.sourceInformation);
// Sometimes we know the Dart receiver is non-null because it has been
// refined, which implies that the JS receiver also can not be null at the
@@ -644,25 +644,25 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
// interceptor is non-null because it intercepts JSNull.
invoke.receiverIsNotNull =
!node.dartReceiver.type.isNullable ||
- !node.receiver.definition.type.isNullable;
+ !node.receiver.type.isNullable;
return invoke;
}
Expression visitInvokeMethodDirectly(cps_ir.InvokeMethodDirectly node) {
- Expression receiver = getVariableUse(node.receiver);
- List<Expression> arguments = translateArguments(node.arguments);
+ Expression receiver = getVariableUse(node.receiverRef);
+ List<Expression> arguments = translateArguments(node.argumentRefs);
return new InvokeMethodDirectly(receiver, node.target,
node.selector, arguments, node.sourceInformation);
}
Expression visitTypeCast(cps_ir.TypeCast node) {
- Expression value = getVariableUse(node.value);
- List<Expression> typeArgs = translateArguments(node.typeArguments);
+ Expression value = getVariableUse(node.valueRef);
+ List<Expression> typeArgs = translateArguments(node.typeArgumentRefs);
return new TypeOperator(value, node.dartType, typeArgs, isTypeTest: false);
}
Expression visitInvokeConstructor(cps_ir.InvokeConstructor node) {
- List<Expression> arguments = translateArguments(node.arguments);
+ List<Expression> arguments = translateArguments(node.argumentRefs);
return new InvokeConstructor(
node.dartType,
node.target,
@@ -673,8 +673,8 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
visitForeignCode(cps_ir.ForeignCode node) {
List<Expression> arguments =
- node.arguments.map(getVariableUse).toList(growable: false);
- List<bool> nullableArguments = node.arguments
+ node.argumentRefs.map(getVariableUse).toList(growable: false);
+ List<bool> nullableArguments = node.argumentRefs
.map((argument) => argument.definition.type.isNullable)
.toList(growable: false);
if (node.codeTemplate.isExpression) {
@@ -704,8 +704,8 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
// In the Tree IR, syntax is more important, so the receiver check uses
// "useInvoke" to denote if an invocation should be emitted.
return new ReceiverCheck(
- condition: getVariableUseOrNull(node.condition),
- value: getVariableUse(node.value),
+ condition: getVariableUseOrNull(node.conditionRef),
+ value: getVariableUse(node.valueRef),
selector: node.selector,
useSelector: node.useSelector,
useInvoke: !node.isNullCheck,
@@ -720,13 +720,13 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
@override
NodeCallback visitYield(cps_ir.Yield node) {
return (Statement next) {
- return new Yield(getVariableUse(node.input), node.hasStar, next);
+ return new Yield(getVariableUse(node.inputRef), node.hasStar, next);
};
}
@override
Expression visitAwait(cps_ir.Await node) {
- return new Await(getVariableUse(node.input));
+ return new Await(getVariableUse(node.inputRef));
}
@override

Powered by Google App Engine
This is Rietveld 408576698