| 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 | 10 |
| (...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 // property should not be mangled. | 1703 // property should not be mangled. |
| 1704 if (backend.isTypedArray( | 1704 if (backend.isTypedArray( |
| 1705 node.receiver.instructionType.computeMask(compiler))) { | 1705 node.receiver.instructionType.computeMask(compiler))) { |
| 1706 // TODO(12929): Remove this custom code for typed arrays once V8 | 1706 // TODO(12929): Remove this custom code for typed arrays once V8 |
| 1707 // optimizes their length access. | 1707 // optimizes their length access. |
| 1708 // Do a call to `fetchLength` instead of accessing `length` | 1708 // Do a call to `fetchLength` instead of accessing `length` |
| 1709 // directly. Because `fetchLength` is a constant we use its | 1709 // directly. Because `fetchLength` is a constant we use its |
| 1710 // constant value instead. | 1710 // constant value instead. |
| 1711 Element element = compiler.findRequiredElement( | 1711 Element element = compiler.findRequiredElement( |
| 1712 compiler.typedDataLibrary, const SourceString('fetchLength')); | 1712 compiler.typedDataLibrary, const SourceString('fetchLength')); |
| 1713 Constant constant = compiler.constantHandler.compileConstant(element); | 1713 Constant constant = |
| 1714 compiler.constantHandler.getConstantForVariable(element); |
| 1715 assert(invariant(element, constant != null, |
| 1716 message: 'No constant computed for $element')); |
| 1714 var jsConstant = backend.emitter.constantReference(constant); | 1717 var jsConstant = backend.emitter.constantReference(constant); |
| 1715 push(new js.Call(jsConstant, [pop()]), node); | 1718 push(new js.Call(jsConstant, [pop()]), node); |
| 1716 } else { | 1719 } else { |
| 1717 push(new js.PropertyAccess.field(pop(), 'length'), node); | 1720 push(new js.PropertyAccess.field(pop(), 'length'), node); |
| 1718 } | 1721 } |
| 1719 } else { | 1722 } else { |
| 1720 String name = _fieldPropertyName(element); | 1723 String name = _fieldPropertyName(element); |
| 1721 push(new js.PropertyAccess.field(pop(), name), node); | 1724 push(new js.PropertyAccess.field(pop(), name), node); |
| 1722 world.registerFieldGetter(element); | 1725 world.registerFieldGetter(element); |
| 1723 } | 1726 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 if (constant.isFunction()) { | 1814 if (constant.isFunction()) { |
| 1812 FunctionConstant function = constant; | 1815 FunctionConstant function = constant; |
| 1813 world.registerStaticUse(function.element); | 1816 world.registerStaticUse(function.element); |
| 1814 } | 1817 } |
| 1815 push(backend.emitter.constantReference(constant)); | 1818 push(backend.emitter.constantReference(constant)); |
| 1816 } | 1819 } |
| 1817 | 1820 |
| 1818 visitConstant(HConstant node) { | 1821 visitConstant(HConstant node) { |
| 1819 assert(isGenerateAtUseSite(node)); | 1822 assert(isGenerateAtUseSite(node)); |
| 1820 generateConstant(node.constant); | 1823 generateConstant(node.constant); |
| 1821 DartType type = node.constant.computeType(compiler); | 1824 |
| 1822 if (node.constant is ConstructedConstant || | 1825 backend.registerCompileTimeConstant(node.constant, work.resolutionTree); |
| 1823 node.constant is InterceptorConstant) { | 1826 compiler.constantHandler.addCompileTimeConstantForEmission(node.constant); |
| 1824 ConstantHandler handler = compiler.constantHandler; | |
| 1825 handler.registerCompileTimeConstant(node.constant, work.resolutionTree); | |
| 1826 } | |
| 1827 if (node.constant is! InterceptorConstant) { | |
| 1828 world.registerInstantiatedClass(type.element, work.resolutionTree); | |
| 1829 } | |
| 1830 } | 1827 } |
| 1831 | 1828 |
| 1832 visitNot(HNot node) { | 1829 visitNot(HNot node) { |
| 1833 assert(node.inputs.length == 1); | 1830 assert(node.inputs.length == 1); |
| 1834 generateNot(node.inputs[0]); | 1831 generateNot(node.inputs[0]); |
| 1835 attachLocationToLast(node); | 1832 attachLocationToLast(node); |
| 1836 } | 1833 } |
| 1837 | 1834 |
| 1838 static String mapRelationalOperator(String op, bool inverse) { | 1835 static String mapRelationalOperator(String op, bool inverse) { |
| 1839 Map<String, String> inverseOperator = const <String, String>{ | 1836 Map<String, String> inverseOperator = const <String, String>{ |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 if (leftType.canBeNull() && rightType.canBeNull()) { | 3036 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 3040 if (left.isConstantNull() || right.isConstantNull() || | 3037 if (left.isConstantNull() || right.isConstantNull() || |
| 3041 (leftType.isPrimitive(compiler) && leftType == rightType)) { | 3038 (leftType.isPrimitive(compiler) && leftType == rightType)) { |
| 3042 return '=='; | 3039 return '=='; |
| 3043 } | 3040 } |
| 3044 return null; | 3041 return null; |
| 3045 } else { | 3042 } else { |
| 3046 return '==='; | 3043 return '==='; |
| 3047 } | 3044 } |
| 3048 } | 3045 } |
| OLD | NEW |