| 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 cps_ir.optimization.inline; | 5 library cps_ir.optimization.inline; |
| 6 | 6 |
| 7 import 'cps_fragment.dart'; | 7 import 'cps_fragment.dart'; |
| 8 import 'cps_ir_builder.dart' show ThisParameterLocal; | 8 import 'cps_ir_builder.dart' show ThisParameterLocal; |
| 9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
| 10 import 'optimizers.dart'; | 10 import 'optimizers.dart'; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 visitor.countArgument(invoke.receiver, function.thisParameter); | 239 visitor.countArgument(invoke.receiver, function.thisParameter); |
| 240 for (int i = 0; i < invoke.arguments.length; ++i) { | 240 for (int i = 0; i < invoke.arguments.length; ++i) { |
| 241 visitor.countArgument(invoke.arguments[i], function.parameters[i]); | 241 visitor.countArgument(invoke.arguments[i], function.parameters[i]); |
| 242 } | 242 } |
| 243 return visitor.size; | 243 return visitor.size; |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Inlining a function incurs a cost equal to the number of primitives and | 246 // Inlining a function incurs a cost equal to the number of primitives and |
| 247 // non-jump tail expressions. | 247 // non-jump tail expressions. |
| 248 // TODO(kmillikin): Tune the size computation and size bound. | 248 // TODO(kmillikin): Tune the size computation and size bound. |
| 249 processLetPrim(LetPrim node) { | 249 processLetPrim(LetPrim node) => ++size; |
| 250 if (node.primitive is! Refinement) { | |
| 251 ++size; | |
| 252 } | |
| 253 } | |
| 254 processLetMutable(LetMutable node) => ++size; | 250 processLetMutable(LetMutable node) => ++size; |
| 255 processBranch(Branch node) => ++size; | 251 processBranch(Branch node) => ++size; |
| 256 processThrow(Throw nose) => ++size; | 252 processThrow(Throw nose) => ++size; |
| 257 processRethrow(Rethrow node) => ++size; | 253 processRethrow(Rethrow node) => ++size; |
| 254 |
| 255 // Discount primitives that do not generate code. |
| 256 processRefinement(Refinement node) => --size; |
| 257 processBoundsCheck(BoundsCheck node) { |
| 258 if (node.hasNoChecks) { |
| 259 --size; |
| 260 } |
| 261 } |
| 258 } | 262 } |
| 259 | 263 |
| 260 class InliningVisitor extends TrampolineRecursiveVisitor { | 264 class InliningVisitor extends TrampolineRecursiveVisitor { |
| 261 final Inliner _inliner; | 265 final Inliner _inliner; |
| 262 | 266 |
| 263 // A successful inlining attempt returns the [Primitive] that represents the | 267 // A successful inlining attempt returns the [Primitive] that represents the |
| 264 // result of the inlined call or null. If the result is non-null, the body | 268 // result of the inlined call or null. If the result is non-null, the body |
| 265 // of the inlined function is available in this field. | 269 // of the inlined function is available in this field. |
| 266 CpsFragment _fragment; | 270 CpsFragment _fragment; |
| 267 | 271 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 if (target.isOperator && | 592 if (target.isOperator && |
| 589 (enclosingClass == backend.helpers.jsNumberClass || | 593 (enclosingClass == backend.helpers.jsNumberClass || |
| 590 enclosingClass == backend.helpers.jsDoubleClass || | 594 enclosingClass == backend.helpers.jsDoubleClass || |
| 591 enclosingClass == backend.helpers.jsIntClass)) { | 595 enclosingClass == backend.helpers.jsIntClass)) { |
| 592 // These should be handled by operator specialization. | 596 // These should be handled by operator specialization. |
| 593 return true; | 597 return true; |
| 594 } | 598 } |
| 595 return false; | 599 return false; |
| 596 } | 600 } |
| 597 } | 601 } |
| OLD | NEW |