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

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

Issue 1576063003: dart2js cps: Translate identity placeholders to refinement nodes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase again 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 | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/js/js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/finalize.dart
diff --git a/pkg/compiler/lib/src/cps_ir/finalize.dart b/pkg/compiler/lib/src/cps_ir/finalize.dart
index 1406a58829e55089964079d6f78ddaf9c8749228..7e3b6e15b2658daed66b59f6aa07e64ac74521d4 100644
--- a/pkg/compiler/lib/src/cps_ir/finalize.dart
+++ b/pkg/compiler/lib/src/cps_ir/finalize.dart
@@ -5,6 +5,7 @@ import 'cps_fragment.dart';
import 'optimizers.dart' show Pass;
import '../js_backend/js_backend.dart' show JavaScriptBackend;
import '../js_backend/backend_helpers.dart';
+import '../js/js.dart' as js;
/// A transformation pass that must run immediately before the tree IR builder.
///
@@ -78,4 +79,18 @@ class Finalize extends TrampolineRecursiveVisitor implements Pass {
node..witness.unlink()..witness = null;
}
}
+
+ void visitForeignCode(ForeignCode node) {
+ if (js.isIdentityTemplate(node.codeTemplate)) {
+ // The CPS builder replaces identity templates with refinements, except
+ // when the refined type is an array type. Some optimizations assume the
+ // type of an object is immutable, but the type of an array can change
+ // after allocation. After the finalize pass, this assumption is no
+ // longer needed, so we can replace the remaining idenitity templates.
+ Refinement refinement = new Refinement(
+ node.arguments.single.definition,
+ node.type)..type = node.type;
+ node.replaceWith(refinement);
+ }
+ }
}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/js/js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698