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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/unsugar.dart

Issue 1283773002: dart2js cps: Do not add identical calls for foreign code conditions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 years, 4 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 | « pkg/compiler/lib/src/js_backend/codegen/glue.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/unsugar.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/unsugar.dart b/pkg/compiler/lib/src/js_backend/codegen/unsugar.dart
index d5970c5360ada8b5c3a521d00cb72d7aec3148bd..0bcc9df4e7306a36a7030bf8a3cf8678404b6d31 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/unsugar.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/unsugar.dart
@@ -293,6 +293,21 @@ class UnsugarVisitor extends RecursiveVisitor {
// TODO(karlklose): implement the checked mode part of boolean conversion.
InteriorNode parent = node.parent;
IsTrue condition = node.condition;
+
+ // Do not rewrite conditions that are foreign code.
+ // It is redundant, and causes infinite recursion (if not optimized)
+ // in the implementation of identical, which itself contains a condition.
+ Primitive value = condition.value.definition;
+ if (value is Parameter && value.parent is Continuation) {
+ Continuation cont = value.parent;
+ if (cont.hasExactlyOneUse && cont.firstRef.parent is ForeignCode) {
+ ForeignCode foreign = cont.firstRef.parent;
+ if (foreign.type.containsOnlyBool(_glue.classWorld)) {
+ return;
+ }
+ }
+ }
+
Primitive t = trueConstant;
Primitive i = new ApplyBuiltinOperator(
BuiltinOperator.Identical,
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/glue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698