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

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

Issue 1609993002: Mark ForeignCode as isSafeForElimination when it has no effects or exceptions. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index b36440e9228c887e26776414047c4743c48bd975..1da858fc2335174ca61df1af924a97be16a1c185 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -3020,7 +3020,21 @@ class TypePropagationVisitor implements Visitor {
@override
void visitForeignCode(ForeignCode node) {
+ bool firstArgumentIsNullable = false;
+ if (node.arguments.length > 0) {
+ AbstractConstantValue first = getValue(node.arguments.first.definition);
+ if (first.isNothing) {
+ setValue(node, nothing);
+ return;
+ }
+ firstArgumentIsNullable = first.isNullable;
+ }
setValue(node, nonConstant(node.storedType));
+ node.isSafeForElimination =
+ !node.nativeBehavior.sideEffects.hasSideEffects() &&
+ (!node.nativeBehavior.throwBehavior.canThrow ||
+ (!firstArgumentIsNullable &&
+ node.nativeBehavior.throwBehavior.isOnlyNullNSMGuard));
}
@override
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698