| 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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 } | 1657 } |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 visitFieldGet(HFieldGet node) { | 1660 visitFieldGet(HFieldGet node) { |
| 1661 use(node.receiver); | 1661 use(node.receiver); |
| 1662 Element element = node.element; | 1662 Element element = node.element; |
| 1663 if (element == backend.jsIndexableLength) { | 1663 if (element == backend.jsIndexableLength) { |
| 1664 // We're accessing a native JavaScript property called 'length' | 1664 // We're accessing a native JavaScript property called 'length' |
| 1665 // on a JS String or a JS array. Therefore, the name of that | 1665 // on a JS String or a JS array. Therefore, the name of that |
| 1666 // property should not be mangled. | 1666 // property should not be mangled. |
| 1667 push(new js.PropertyAccess.field(pop(), 'length'), node); | 1667 if (backend.isTypedArray( |
| 1668 node.receiver.instructionType.computeMask(compiler))) { |
| 1669 // TODO(12929): Remove this custom code for typed arrays once V8 |
| 1670 // optimizes their length access. |
| 1671 // Do a call to `fetchLength` instead of accessing `length` |
| 1672 // directly. Because `fetchLength` is a constant we use its |
| 1673 // constant value instead. |
| 1674 Element element = compiler.findRequiredElement( |
| 1675 compiler.typedDataLibrary, const SourceString('fetchLength')); |
| 1676 Constant constant = compiler.constantHandler.compileConstant(element); |
| 1677 var jsConstant = backend.emitter.constantReference(constant); |
| 1678 push(new js.Call(jsConstant, [pop()]), node); |
| 1679 } else { |
| 1680 push(new js.PropertyAccess.field(pop(), 'length'), node); |
| 1681 } |
| 1668 } else { | 1682 } else { |
| 1669 String name = _fieldPropertyName(element); | 1683 String name = _fieldPropertyName(element); |
| 1670 push(new js.PropertyAccess.field(pop(), name), node); | 1684 push(new js.PropertyAccess.field(pop(), name), node); |
| 1671 world.registerFieldGetter(element); | 1685 world.registerFieldGetter(element); |
| 1672 } | 1686 } |
| 1673 } | 1687 } |
| 1674 | 1688 |
| 1675 visitFieldSet(HFieldSet node) { | 1689 visitFieldSet(HFieldSet node) { |
| 1676 Element element = node.element; | 1690 Element element = node.element; |
| 1677 world.registerFieldSetter(element); | 1691 world.registerFieldSetter(element); |
| (...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 if (leftType.canBeNull() && rightType.canBeNull()) { | 2987 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2974 if (left.isConstantNull() || right.isConstantNull() || | 2988 if (left.isConstantNull() || right.isConstantNull() || |
| 2975 (leftType.isPrimitive(compiler) && leftType == rightType)) { | 2989 (leftType.isPrimitive(compiler) && leftType == rightType)) { |
| 2976 return '=='; | 2990 return '=='; |
| 2977 } | 2991 } |
| 2978 return null; | 2992 return null; |
| 2979 } else { | 2993 } else { |
| 2980 return '==='; | 2994 return '==='; |
| 2981 } | 2995 } |
| 2982 } | 2996 } |
| OLD | NEW |