| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.cps_ir.share_interceptors; | 5 library dart2js.cps_ir.share_interceptors; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart'; | 8 import 'optimizers.dart'; |
| 9 import 'type_mask_system.dart'; |
| 10 import '../elements/elements.dart'; |
| 9 import '../constants/values.dart'; | 11 import '../constants/values.dart'; |
| 10 | 12 |
| 11 /// Merges calls to `getInterceptor` when one call dominates the other. | 13 /// Merges calls to `getInterceptor` when one call is in scope of the other. |
| 14 /// |
| 15 /// Also replaces `getInterceptor` calls with an interceptor constant when |
| 16 /// the result is known statically, and there is no interceptor already in |
| 17 /// scope. |
| 12 /// | 18 /// |
| 13 /// Should run after [LoopInvariantCodeMotion] so interceptors lifted out from | 19 /// Should run after [LoopInvariantCodeMotion] so interceptors lifted out from |
| 14 /// loops can be merged. | 20 /// loops can be merged. |
| 15 class ShareInterceptors extends RecursiveVisitor implements Pass { | 21 class ShareInterceptors extends RecursiveVisitor implements Pass { |
| 16 String get passName => 'Share interceptors'; | 22 String get passName => 'Share interceptors'; |
| 17 | 23 |
| 18 final Map<Primitive, Primitive> interceptorFor = | 24 final Map<Primitive, Primitive> interceptorFor = |
| 19 <Primitive, Primitive>{}; | 25 <Primitive, Primitive>{}; |
| 20 | 26 |
| 21 final Map<ConstantValue, Primitive> sharedConstantFor = | 27 final Map<ConstantValue, Primitive> sharedConstantFor = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return node.body; | 89 return node.body; |
| 84 } | 90 } |
| 85 | 91 |
| 86 Expression getEnclosingExpression(Node node) { | 92 Expression getEnclosingExpression(Node node) { |
| 87 while (node is! Expression) { | 93 while (node is! Expression) { |
| 88 node = node.parent; | 94 node = node.parent; |
| 89 } | 95 } |
| 90 return node; | 96 return node; |
| 91 } | 97 } |
| 92 } | 98 } |
| OLD | NEW |