| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 expressionStack = <js.Expression>[], | 147 expressionStack = <js.Expression>[], |
| 148 oldContainerStack = <js.Block>[], | 148 oldContainerStack = <js.Block>[], |
| 149 generateAtUseSite = new Set<HInstruction>(), | 149 generateAtUseSite = new Set<HInstruction>(), |
| 150 controlFlowOperators = new Set<HInstruction>(), | 150 controlFlowOperators = new Set<HInstruction>(), |
| 151 breakAction = new Map<Entity, EntityAction>(), | 151 breakAction = new Map<Entity, EntityAction>(), |
| 152 continueAction = new Map<Entity, EntityAction>(); | 152 continueAction = new Map<Entity, EntityAction>(); |
| 153 | 153 |
| 154 Compiler get compiler => backend.compiler; | 154 Compiler get compiler => backend.compiler; |
| 155 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; | 155 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; |
| 156 CodegenRegistry get registry => work.registry; | 156 CodegenRegistry get registry => work.registry; |
| 157 native.NativeEnqueuer get nativeEnqueuer { |
| 158 return compiler.enqueuer.codegen.nativeEnqueuer; |
| 159 } |
| 157 | 160 |
| 158 bool isGenerateAtUseSite(HInstruction instruction) { | 161 bool isGenerateAtUseSite(HInstruction instruction) { |
| 159 return generateAtUseSite.contains(instruction); | 162 return generateAtUseSite.contains(instruction); |
| 160 } | 163 } |
| 161 | 164 |
| 162 bool hasNonBitOpUser(HInstruction instruction, Set<HPhi> phiSet) { | 165 bool hasNonBitOpUser(HInstruction instruction, Set<HPhi> phiSet) { |
| 163 for (HInstruction user in instruction.usedBy) { | 166 for (HInstruction user in instruction.usedBy) { |
| 164 if (user is HPhi) { | 167 if (user is HPhi) { |
| 165 if (!phiSet.contains(user)) { | 168 if (!phiSet.contains(user)) { |
| 166 phiSet.add(user); | 169 phiSet.add(user); |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 | 1594 |
| 1592 TypeMask getOptimizedSelectorFor(HInvokeDynamic node, | 1595 TypeMask getOptimizedSelectorFor(HInvokeDynamic node, |
| 1593 Selector selector, | 1596 Selector selector, |
| 1594 TypeMask mask) { | 1597 TypeMask mask) { |
| 1595 if (node.element != null) { | 1598 if (node.element != null) { |
| 1596 // Create an artificial type mask to make sure only | 1599 // Create an artificial type mask to make sure only |
| 1597 // [node.element] will be enqueued. We're not using the receiver | 1600 // [node.element] will be enqueued. We're not using the receiver |
| 1598 // type because our optimizations might end up in a state where the | 1601 // type because our optimizations might end up in a state where the |
| 1599 // invoke dynamic knows more than the receiver. | 1602 // invoke dynamic knows more than the receiver. |
| 1600 ClassElement enclosing = node.element.enclosingClass; | 1603 ClassElement enclosing = node.element.enclosingClass; |
| 1601 return | 1604 if (compiler.world.isInstantiated(enclosing)) { |
| 1602 new TypeMask.nonNullExact(enclosing.declaration, compiler.world); | 1605 return new TypeMask.nonNullExact( |
| 1606 enclosing.declaration, compiler.world); |
| 1607 } else { |
| 1608 // The element is mixed in so a non-null subtype mask is the most |
| 1609 // precise we have. |
| 1610 assert(invariant(node, compiler.world.isUsedAsMixin(enclosing), |
| 1611 message: "Element ${node.element} from $enclosing expected " |
| 1612 "to be mixed in.")); |
| 1613 return new TypeMask.nonNullSubtype( |
| 1614 enclosing.declaration, compiler.world); |
| 1615 } |
| 1603 } | 1616 } |
| 1604 // If [JSInvocationMirror._invokeOn] is enabled, and this call | 1617 // If [JSInvocationMirror._invokeOn] is enabled, and this call |
| 1605 // might hit a `noSuchMethod`, we register an untyped selector. | 1618 // might hit a `noSuchMethod`, we register an untyped selector. |
| 1606 return compiler.world.extendMaskIfReachesAll(selector, mask); | 1619 return compiler.world.extendMaskIfReachesAll(selector, mask); |
| 1607 } | 1620 } |
| 1608 | 1621 |
| 1609 void registerMethodInvoke(HInvokeDynamic node) { | 1622 void registerMethodInvoke(HInvokeDynamic node) { |
| 1610 Selector selector = node.selector; | 1623 Selector selector = node.selector; |
| 1611 TypeMask mask = getOptimizedSelectorFor(node, selector, node.mask); | 1624 TypeMask mask = getOptimizedSelectorFor(node, selector, node.mask); |
| 1612 | 1625 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 visitLocalSet(HLocalSet node) { | 1838 visitLocalSet(HLocalSet node) { |
| 1826 use(node.value); | 1839 use(node.value); |
| 1827 assignVariable(variableNames.getName(node.receiver), | 1840 assignVariable(variableNames.getName(node.receiver), |
| 1828 pop(), | 1841 pop(), |
| 1829 node.sourceInformation); | 1842 node.sourceInformation); |
| 1830 } | 1843 } |
| 1831 | 1844 |
| 1832 void registerForeignTypes(HForeign node) { | 1845 void registerForeignTypes(HForeign node) { |
| 1833 native.NativeBehavior nativeBehavior = node.nativeBehavior; | 1846 native.NativeBehavior nativeBehavior = node.nativeBehavior; |
| 1834 if (nativeBehavior == null) return; | 1847 if (nativeBehavior == null) return; |
| 1835 nativeBehavior.typesReturned.forEach((type) { | 1848 nativeEnqueuer.registerNativeBehavior(nativeBehavior, node); |
| 1836 if (type is InterfaceType) { | |
| 1837 registry.registerInstantiatedType(type); | |
| 1838 } | |
| 1839 }); | |
| 1840 } | 1849 } |
| 1841 | 1850 |
| 1842 visitForeignCode(HForeignCode node) { | 1851 visitForeignCode(HForeignCode node) { |
| 1843 List<HInstruction> inputs = node.inputs; | 1852 List<HInstruction> inputs = node.inputs; |
| 1844 if (node.isJsStatement()) { | 1853 if (node.isJsStatement()) { |
| 1845 List<js.Expression> interpolatedExpressions = <js.Expression>[]; | 1854 List<js.Expression> interpolatedExpressions = <js.Expression>[]; |
| 1846 for (int i = 0; i < inputs.length; i++) { | 1855 for (int i = 0; i < inputs.length; i++) { |
| 1847 use(inputs[i]); | 1856 use(inputs[i]); |
| 1848 interpolatedExpressions.add(pop()); | 1857 interpolatedExpressions.add(pop()); |
| 1849 } | 1858 } |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 } | 2872 } |
| 2864 registry.registerStaticUse(helper); | 2873 registry.registerStaticUse(helper); |
| 2865 return backend.emitter.staticFunctionAccess(helper); | 2874 return backend.emitter.staticFunctionAccess(helper); |
| 2866 } | 2875 } |
| 2867 | 2876 |
| 2868 @override | 2877 @override |
| 2869 void visitRef(HRef node) { | 2878 void visitRef(HRef node) { |
| 2870 visit(node.value); | 2879 visit(node.value); |
| 2871 } | 2880 } |
| 2872 } | 2881 } |
| OLD | NEW |