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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library dart2js.cps_ir.finalize; 1 library dart2js.cps_ir.finalize;
2 2
3 import 'cps_ir_nodes.dart'; 3 import 'cps_ir_nodes.dart';
4 import 'cps_fragment.dart'; 4 import 'cps_fragment.dart';
5 import 'optimizers.dart' show Pass; 5 import 'optimizers.dart' show Pass;
6 import '../js_backend/js_backend.dart' show JavaScriptBackend; 6 import '../js_backend/js_backend.dart' show JavaScriptBackend;
7 import '../js_backend/backend_helpers.dart'; 7 import '../js_backend/backend_helpers.dart';
8 import '../js/js.dart' as js;
8 9
9 /// A transformation pass that must run immediately before the tree IR builder. 10 /// A transformation pass that must run immediately before the tree IR builder.
10 /// 11 ///
11 /// This expands [BoundsCheck] nodes into more low-level operations. 12 /// This expands [BoundsCheck] nodes into more low-level operations.
12 class Finalize extends TrampolineRecursiveVisitor implements Pass { 13 class Finalize extends TrampolineRecursiveVisitor implements Pass {
13 String get passName => 'Finalize'; 14 String get passName => 'Finalize';
14 15
15 JavaScriptBackend backend; 16 JavaScriptBackend backend;
16 BackendHelpers get helpers => backend.helpers; 17 BackendHelpers get helpers => backend.helpers;
17 18
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 [node.object.definition, node.index.definition]); 72 [node.object.definition, node.index.definition]);
72 node..replaceUsesWith(node.object.definition)..destroy(); 73 node..replaceUsesWith(node.object.definition)..destroy();
73 return cps; 74 return cps;
74 } 75 }
75 76
76 void visitGetStatic(GetStatic node) { 77 void visitGetStatic(GetStatic node) {
77 if (node.witness != null) { 78 if (node.witness != null) {
78 node..witness.unlink()..witness = null; 79 node..witness.unlink()..witness = null;
79 } 80 }
80 } 81 }
82
83 void visitForeignCode(ForeignCode node) {
84 if (js.isIdentityTemplate(node.codeTemplate)) {
85 // The CPS builder replaces identity templates with refinements, except
86 // when the refined type is an array type. Some optimizations assume the
87 // type of an object is immutable, but the type of an array can change
88 // after allocation. After the finalize pass, this assumption is no
89 // longer needed, so we can replace the remaining idenitity templates.
90 Refinement refinement = new Refinement(
91 node.arguments.single.definition,
92 node.type)..type = node.type;
93 node.replaceWith(refinement);
94 }
95 }
81 } 96 }
OLDNEW
« 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