| 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 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 List<DartType> instantiatedTypes = node.instantiatedTypes; | 1690 List<DartType> instantiatedTypes = node.instantiatedTypes; |
| 1691 | 1691 |
| 1692 if (instantiatedTypes != null && !instantiatedTypes.isEmpty) { | 1692 if (instantiatedTypes != null && !instantiatedTypes.isEmpty) { |
| 1693 instantiatedTypes.forEach((type) { | 1693 instantiatedTypes.forEach((type) { |
| 1694 registry.registerInstantiatedType(type); | 1694 registry.registerInstantiatedType(type); |
| 1695 }); | 1695 }); |
| 1696 } | 1696 } |
| 1697 | 1697 |
| 1698 List<js.Expression> arguments = visitArguments(node.inputs, start: 0); | 1698 List<js.Expression> arguments = visitArguments(node.inputs, start: 0); |
| 1699 | 1699 |
| 1700 if (element == backend.getCheckConcurrentModificationError()) { | 1700 if (element == backend.helpers.checkConcurrentModificationError) { |
| 1701 // Manually inline the [checkConcurrentModificationError] function. This | 1701 // Manually inline the [checkConcurrentModificationError] function. This |
| 1702 // function is only called from a for-loop update. Ideally we would just | 1702 // function is only called from a for-loop update. Ideally we would just |
| 1703 // generate the conditionalcontrol flow in the builder but it adds basic | 1703 // generate the conditionalcontrol flow in the builder but it adds basic |
| 1704 // blocks in the loop update that interfere with other optimizations and | 1704 // blocks in the loop update that interfere with other optimizations and |
| 1705 // confuses loop recognition. | 1705 // confuses loop recognition. |
| 1706 | 1706 |
| 1707 assert(arguments.length == 2); | 1707 assert(arguments.length == 2); |
| 1708 Element throwFunction = backend.getThrowConcurrentModificationError(); | 1708 Element throwFunction = backend.helpers.throwConcurrentModificationError; |
| 1709 registry.registerStaticInvocation(throwFunction); | 1709 registry.registerStaticInvocation(throwFunction); |
| 1710 | 1710 |
| 1711 // Calling using `(0, #)(#)` instead of `#(#)` separates the property load | 1711 // Calling using `(0, #)(#)` instead of `#(#)` separates the property load |
| 1712 // of the static function access from the call. For some reason this | 1712 // of the static function access from the call. For some reason this |
| 1713 // helps V8 see that the call never happens so V8 makes the call a | 1713 // helps V8 see that the call never happens so V8 makes the call a |
| 1714 // deoptimization. This removes the call from the optimized loop, making | 1714 // deoptimization. This removes the call from the optimized loop, making |
| 1715 // more optimizations available to the loop. This form is 50% faster on | 1715 // more optimizations available to the loop. This form is 50% faster on |
| 1716 // some small loop, almost as fast as loops with no concurrent | 1716 // some small loop, almost as fast as loops with no concurrent |
| 1717 // modification check. | 1717 // modification check. |
| 1718 push(js.js('# || (0, #)(#)',[ | 1718 push(js.js('# || (0, #)(#)',[ |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 if (node.usedBy.length == 1 | 2255 if (node.usedBy.length == 1 |
| 2256 && node.usedBy[0] is HStringConcat | 2256 && node.usedBy[0] is HStringConcat |
| 2257 && node.usedBy[0].inputs[1] == node) { | 2257 && node.usedBy[0].inputs[1] == node) { |
| 2258 // The context is already <string> + value. | 2258 // The context is already <string> + value. |
| 2259 } else { | 2259 } else { |
| 2260 // Force an empty string for the first operand. | 2260 // Force an empty string for the first operand. |
| 2261 push(new js.Binary('+', js.string(""), pop()) | 2261 push(new js.Binary('+', js.string(""), pop()) |
| 2262 .withSourceInformation(node.sourceInformation)); | 2262 .withSourceInformation(node.sourceInformation)); |
| 2263 } | 2263 } |
| 2264 } else { | 2264 } else { |
| 2265 Element convertToString = backend.getStringInterpolationHelper(); | 2265 Element convertToString = backend.helpers.stringInterpolationHelper; |
| 2266 registry.registerStaticUse(convertToString); | 2266 registry.registerStaticUse(convertToString); |
| 2267 js.Expression jsHelper = | 2267 js.Expression jsHelper = |
| 2268 backend.emitter.staticFunctionAccess(convertToString); | 2268 backend.emitter.staticFunctionAccess(convertToString); |
| 2269 use(input); | 2269 use(input); |
| 2270 push(new js.Call(jsHelper, <js.Expression>[pop()], | 2270 push(new js.Call(jsHelper, <js.Expression>[pop()], |
| 2271 sourceInformation: node.sourceInformation)); | 2271 sourceInformation: node.sourceInformation)); |
| 2272 } | 2272 } |
| 2273 } | 2273 } |
| 2274 | 2274 |
| 2275 void visitLiteralList(HLiteralList node) { | 2275 void visitLiteralList(HLiteralList node) { |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2877 } | 2877 } |
| 2878 registry.registerStaticUse(helper); | 2878 registry.registerStaticUse(helper); |
| 2879 return backend.emitter.staticFunctionAccess(helper); | 2879 return backend.emitter.staticFunctionAccess(helper); |
| 2880 } | 2880 } |
| 2881 | 2881 |
| 2882 @override | 2882 @override |
| 2883 void visitRef(HRef node) { | 2883 void visitRef(HRef node) { |
| 2884 visit(node.value); | 2884 visit(node.value); |
| 2885 } | 2885 } |
| 2886 } | 2886 } |
| OLD | NEW |