| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |