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

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

Issue 1507313006: dart2js cps: Add instruction for null checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix true/false misdocumentation about condition and do not emit call Created 5 years 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 84c5200515ff58d2f8c9d1082a5874ac7c05177c..11c10225418418f3d0057e467765597fa79b10a6 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -107,10 +107,16 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
/// This increments the reference count for the given variable, so the
/// returned expression must be used in the tree.
Expression getVariableUse(cps_ir.Reference<cps_ir.Primitive> reference) {
- if (thisParameter != null && reference.definition == thisParameter) {
+ cps_ir.Primitive prim = reference.definition.effectiveDefinition;
+ if (thisParameter != null && prim == thisParameter) {
return new This();
}
- return new VariableUse(getVariable(reference.definition));
+ return new VariableUse(getVariable(prim));
+ }
+
+ Expression getVariableUseOrNull(
+ cps_ir.Reference<cps_ir.Primitive> reference) {
+ return reference == null ? null : getVariableUse(reference);
}
Label getLabel(cps_ir.Continuation cont) {
@@ -496,10 +502,6 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
);
}
- FunctionDefinition makeSubFunction(cps_ir.FunctionDefinition function) {
- return createInnerBuilder().buildFunction(function);
- }
-
Expression visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) {
return new ReifyRuntimeType(
getVariableUse(node.value), node.sourceInformation);
@@ -643,6 +645,15 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
}
}
+ visitNullCheck(cps_ir.NullCheck node) => (Statement next) {
+ return new NullCheck(
+ condition: getVariableUseOrNull(node.condition),
+ value: getVariableUse(node.value),
+ selector: node.selector,
+ next: next,
+ sourceInformation: node.sourceInformation);
+ };
+
Expression visitGetLazyStatic(cps_ir.GetLazyStatic node) {
// In the tree IR, GetStatic handles lazy fields because we do not need
// as fine-grained control over side effects.
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698