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 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
8 String get name; | 8 String get name; |
9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
10 } | 10 } |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 return compiler.world.locateSingleField( | 620 return compiler.world.locateSingleField( |
621 receiverType.refine(selector, compiler)); | 621 receiverType.refine(selector, compiler)); |
622 } | 622 } |
623 | 623 |
624 HInstruction visitFieldGet(HFieldGet node) { | 624 HInstruction visitFieldGet(HFieldGet node) { |
625 if (node.element == backend.jsIndexableLength) { | 625 if (node.element == backend.jsIndexableLength) { |
626 if (node.receiver is HInvokeStatic) { | 626 if (node.receiver is HInvokeStatic) { |
627 // Try to recognize the length getter with input | 627 // Try to recognize the length getter with input |
628 // [:new List(int):]. | 628 // [:new List(int):]. |
629 HInvokeStatic call = node.receiver; | 629 HInvokeStatic call = node.receiver; |
630 Element element = call.target.element; | 630 Element element = call.element; |
631 // TODO(ngeoffray): checking if the second input is an integer | 631 // TODO(ngeoffray): checking if the second input is an integer |
632 // should not be necessary but it currently makes it easier for | 632 // should not be necessary but it currently makes it easier for |
633 // other optimizations to reason about a fixed length constructor | 633 // other optimizations to reason about a fixed length constructor |
634 // that we know takes an int. | 634 // that we know takes an int. |
635 if (element == compiler.unnamedListConstructor | 635 if (element == compiler.unnamedListConstructor |
636 && call.inputs.length == 2 | 636 && call.inputs.length == 1 |
637 && call.inputs[1].isInteger()) { | 637 && call.inputs[0].isInteger()) { |
638 return call.inputs[1]; | 638 return call.inputs[0]; |
639 } | 639 } |
640 } else if (node.receiver.isConstantList() || | 640 } else if (node.receiver.isConstantList() || |
641 node.receiver.isConstantString()) { | 641 node.receiver.isConstantString()) { |
642 var instruction = node.receiver; | 642 var instruction = node.receiver; |
643 return graph.addConstantInt( | 643 return graph.addConstantInt( |
644 instruction.constant.length, backend.constantSystem); | 644 instruction.constant.length, backend.constantSystem); |
645 } | 645 } |
646 } | 646 } |
647 return node; | 647 return node; |
648 } | 648 } |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 HBasicBlock block = user.block; | 1706 HBasicBlock block = user.block; |
1707 block.addAfter(user, interceptor); | 1707 block.addAfter(user, interceptor); |
1708 block.rewrite(user, interceptor); | 1708 block.rewrite(user, interceptor); |
1709 block.remove(user); | 1709 block.remove(user); |
1710 | 1710 |
1711 // The interceptor will be removed in the dead code elimination | 1711 // The interceptor will be removed in the dead code elimination |
1712 // phase. Note that removing it here would not work because of how | 1712 // phase. Note that removing it here would not work because of how |
1713 // the [visitBasicBlock] is implemented. | 1713 // the [visitBasicBlock] is implemented. |
1714 } | 1714 } |
1715 } | 1715 } |
OLD | NEW |