| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 3634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3645 return type.isIndexable(compiler); | 3645 return type.isIndexable(compiler); |
| 3646 } else if (selector.isIndexSet()) { | 3646 } else if (selector.isIndexSet()) { |
| 3647 DartType classType = element.getEnclosingClass().computeType(compiler); | 3647 DartType classType = element.getEnclosingClass().computeType(compiler); |
| 3648 HType type = new HType.nonNullExact(classType, compiler); | 3648 HType type = new HType.nonNullExact(classType, compiler); |
| 3649 return type.isMutableIndexable(compiler); | 3649 return type.isMutableIndexable(compiler); |
| 3650 } else { | 3650 } else { |
| 3651 return false; | 3651 return false; |
| 3652 } | 3652 } |
| 3653 } | 3653 } |
| 3654 | 3654 |
| 3655 bool isThisSend(Send send) { | 3655 bool isOptimizableOperation(Send node, Selector selector, Element element) { |
| 3656 if (send.isPrefix || send.isPostfix) return false; | 3656 ClassElement cls = element.getEnclosingClass(); |
| 3657 Node receiver = send.receiver; | 3657 if (isOptimizableOperationOnIndexable(selector, element)) return true; |
| 3658 if (receiver == null) return true; | 3658 if (!backend.interceptedClasses.contains(cls)) return false; |
| 3659 Identifier identifier = receiver.asIdentifier(); | 3659 if (selector.isOperator()) return true; |
| 3660 return identifier != null && identifier.isThis(); | 3660 if (selector.isSetter()) return true; |
| 3661 if (selector.isIndex()) return true; |
| 3662 if (selector.isIndexSet()) return true; |
| 3663 if (element == backend.jsArrayAdd |
| 3664 || element == backend.jsArrayRemoveLast |
| 3665 || element == backend.jsStringSplit) { |
| 3666 return true; |
| 3667 } |
| 3668 return false; |
| 3661 } | 3669 } |
| 3662 | 3670 |
| 3663 Element element = compiler.world.locateSingleElement(selector); | 3671 Element element = compiler.world.locateSingleElement(selector); |
| 3664 if (element != null | 3672 if (element != null |
| 3665 // TODO(ngeoffray): Handle non-send nodes. | 3673 // TODO(ngeoffray): Handle non-send nodes. |
| 3666 && (node.asSend() != null) | 3674 && (node.asSend() != null) |
| 3667 && !(element.isGetter() && selector.isCall()) | 3675 && !(element.isGetter() && selector.isCall()) |
| 3668 && !(element.isFunction() && selector.isGetter()) | 3676 && !(element.isFunction() && selector.isGetter()) |
| 3669 // This check is to ensure we don't regress compared to our | 3677 && !isOptimizableOperation(node, selector, element)) { |
| 3670 // previous limited inlining. We currently don't want to | |
| 3671 // inline methods on intercepted classes because the | |
| 3672 // optimizers apply their own optimizations on these methods. | |
| 3673 && (!backend.interceptedClasses.contains(element.getEnclosingClass()) | |
| 3674 || isThisSend(node)) | |
| 3675 // Avoid inlining optimizable operations on indexables. | |
| 3676 && !isOptimizableOperationOnIndexable(selector, element)) { | |
| 3677 Send send = node.asSend(); | 3678 Send send = node.asSend(); |
| 3678 Link<Node> nodes = send.isPropertyAccess ? null : send.arguments; | 3679 Link<Node> nodes = send.isPropertyAccess ? null : send.arguments; |
| 3679 if (tryInlineMethod(element, selector, nodes, arguments, node)) { | 3680 if (tryInlineMethod(element, selector, nodes, arguments, node)) { |
| 3680 return; | 3681 return; |
| 3681 } | 3682 } |
| 3682 } | 3683 } |
| 3683 | 3684 |
| 3684 HInstruction receiver = arguments[0]; | 3685 HInstruction receiver = arguments[0]; |
| 3685 Set<ClassElement> interceptedClasses = | 3686 Set<ClassElement> interceptedClasses = |
| 3686 backend.getInterceptedClassesOn(selector.name); | 3687 backend.getInterceptedClassesOn(selector.name); |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5268 new HSubGraphBlockInformation(elseBranch.graph)); | 5269 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5269 | 5270 |
| 5270 HBasicBlock conditionStartBlock = conditionBranch.block; | 5271 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5271 conditionStartBlock.setBlockFlow(info, joinBlock); | 5272 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5272 SubGraph conditionGraph = conditionBranch.graph; | 5273 SubGraph conditionGraph = conditionBranch.graph; |
| 5273 HIf branch = conditionGraph.end.last; | 5274 HIf branch = conditionGraph.end.last; |
| 5274 assert(branch is HIf); | 5275 assert(branch is HIf); |
| 5275 branch.blockInformation = conditionStartBlock.blockFlow; | 5276 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5276 } | 5277 } |
| 5277 } | 5278 } |
| OLD | NEW |