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 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
8 | 8 |
9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
10 final SourceInformationStrategy sourceInformationFactory; | 10 final SourceInformationStrategy sourceInformationFactory; |
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 | 1591 |
1592 TypeMask getOptimizedSelectorFor(HInvokeDynamic node, | 1592 TypeMask getOptimizedSelectorFor(HInvokeDynamic node, |
1593 Selector selector, | 1593 Selector selector, |
1594 TypeMask mask) { | 1594 TypeMask mask) { |
1595 if (node.element != null) { | 1595 if (node.element != null) { |
1596 // Create an artificial type mask to make sure only | 1596 // Create an artificial type mask to make sure only |
1597 // [node.element] will be enqueued. We're not using the receiver | 1597 // [node.element] will be enqueued. We're not using the receiver |
1598 // type because our optimizations might end up in a state where the | 1598 // type because our optimizations might end up in a state where the |
1599 // invoke dynamic knows more than the receiver. | 1599 // invoke dynamic knows more than the receiver. |
1600 ClassElement enclosing = node.element.enclosingClass; | 1600 ClassElement enclosing = node.element.enclosingClass; |
1601 return | 1601 if (compiler.world.isInstantiated(enclosing)) { |
1602 new TypeMask.nonNullExact(enclosing.declaration, compiler.world); | 1602 return new TypeMask.nonNullExact( |
| 1603 enclosing.declaration, compiler.world); |
| 1604 } else { |
| 1605 // The element is mixed in so a non-null subtype mask is the most |
| 1606 // precise we have. |
| 1607 assert(invariant(node, compiler.world.isUsedAsMixin(enclosing), |
| 1608 message: "Element ${node.element} from $enclosing expected " |
| 1609 "to be mixed in.")); |
| 1610 return new TypeMask.nonNullSubtype( |
| 1611 enclosing.declaration, compiler.world); |
| 1612 } |
1603 } | 1613 } |
1604 // If [JSInvocationMirror._invokeOn] is enabled, and this call | 1614 // If [JSInvocationMirror._invokeOn] is enabled, and this call |
1605 // might hit a `noSuchMethod`, we register an untyped selector. | 1615 // might hit a `noSuchMethod`, we register an untyped selector. |
1606 return compiler.world.extendMaskIfReachesAll(selector, mask); | 1616 return compiler.world.extendMaskIfReachesAll(selector, mask); |
1607 } | 1617 } |
1608 | 1618 |
1609 void registerMethodInvoke(HInvokeDynamic node) { | 1619 void registerMethodInvoke(HInvokeDynamic node) { |
1610 Selector selector = node.selector; | 1620 Selector selector = node.selector; |
1611 TypeMask mask = getOptimizedSelectorFor(node, selector, node.mask); | 1621 TypeMask mask = getOptimizedSelectorFor(node, selector, node.mask); |
1612 | 1622 |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 } | 2873 } |
2864 registry.registerStaticUse(helper); | 2874 registry.registerStaticUse(helper); |
2865 return backend.emitter.staticFunctionAccess(helper); | 2875 return backend.emitter.staticFunctionAccess(helper); |
2866 } | 2876 } |
2867 | 2877 |
2868 @override | 2878 @override |
2869 void visitRef(HRef node) { | 2879 void visitRef(HRef node) { |
2870 visit(node.value); | 2880 visit(node.value); |
2871 } | 2881 } |
2872 } | 2882 } |
OLD | NEW |