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 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
8 String get name; | 8 String get name; |
9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
10 } | 10 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 if (input.isExtendableArray(compiler)) { | 256 if (input.isExtendableArray(compiler)) { |
257 if (selector.applies(backend.jsArrayRemoveLast, compiler)) { | 257 if (selector.applies(backend.jsArrayRemoveLast, compiler)) { |
258 target = backend.jsArrayRemoveLast; | 258 target = backend.jsArrayRemoveLast; |
259 } else if (selector.applies(backend.jsArrayAdd, compiler)) { | 259 } else if (selector.applies(backend.jsArrayAdd, compiler)) { |
260 // The codegen special cases array calls, but does not | 260 // The codegen special cases array calls, but does not |
261 // inline argument type checks. | 261 // inline argument type checks. |
262 if (!compiler.enableTypeAssertions) { | 262 if (!compiler.enableTypeAssertions) { |
263 target = backend.jsArrayAdd; | 263 target = backend.jsArrayAdd; |
264 } | 264 } |
265 } | 265 } |
266 } else if (input.isString(compiler)) { | 266 } else if (input.isStringOrNull(compiler)) { |
267 if (selector.applies(backend.jsStringSplit, compiler)) { | 267 if (selector.applies(backend.jsStringSplit, compiler)) { |
268 HInstruction argument = node.inputs[2]; | 268 HInstruction argument = node.inputs[2]; |
269 if (argument.isString(compiler) && !argument.canBeNull()) { | 269 if (argument.isString(compiler)) { |
270 target = backend.jsStringSplit; | 270 target = backend.jsStringSplit; |
271 } | 271 } |
272 } else if (selector.applies(backend.jsStringOperatorAdd, compiler)) { | 272 } else if (selector.applies(backend.jsStringOperatorAdd, compiler)) { |
273 // `operator+` is turned into a JavaScript '+' so we need to | 273 // `operator+` is turned into a JavaScript '+' so we need to |
274 // make sure the receiver and the argument are not null. | 274 // make sure the receiver and the argument are not null. |
275 HInstruction argument = node.inputs[2]; | 275 HInstruction argument = node.inputs[2]; |
276 if (argument.isString(compiler) | 276 if (argument.isString(compiler) |
277 && !argument.canBeNull() | |
278 && !input.canBeNull()) { | 277 && !input.canBeNull()) { |
279 target = backend.jsStringOperatorAdd; | 278 target = backend.jsStringOperatorAdd; |
280 } | 279 } |
281 } else if (selector.applies(backend.jsStringToString, compiler) | 280 } else if (selector.applies(backend.jsStringToString, compiler) |
282 && !input.canBeNull()) { | 281 && !input.canBeNull()) { |
283 return input; | 282 return input; |
284 } | 283 } |
285 } | 284 } |
286 if (target != null) { | 285 if (target != null) { |
287 // TODO(ngeoffray): There is a strong dependency between codegen | 286 // TODO(ngeoffray): There is a strong dependency between codegen |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 HInstruction folded = graph.addConstant( | 784 HInstruction folded = graph.addConstant( |
786 constantSystem.createString( | 785 constantSystem.createString( |
787 new DartString.concat(leftString.value, rightString.value)), | 786 new DartString.concat(leftString.value, rightString.value)), |
788 compiler); | 787 compiler); |
789 if (prefix == null) return folded; | 788 if (prefix == null) return folded; |
790 return new HStringConcat(prefix, folded, node.node, backend.stringType); | 789 return new HStringConcat(prefix, folded, node.node, backend.stringType); |
791 } | 790 } |
792 | 791 |
793 HInstruction visitStringify(HStringify node) { | 792 HInstruction visitStringify(HStringify node) { |
794 HInstruction input = node.inputs[0]; | 793 HInstruction input = node.inputs[0]; |
795 if (input.isString(compiler) && !input.canBeNull()) return input; | 794 if (input.isString(compiler)) return input; |
796 if (input.isConstant()) { | 795 if (input.isConstant()) { |
797 HConstant constant = input; | 796 HConstant constant = input; |
798 if (!constant.constant.isPrimitive()) return node; | 797 if (!constant.constant.isPrimitive()) return node; |
799 PrimitiveConstant primitive = constant.constant; | 798 PrimitiveConstant primitive = constant.constant; |
800 return graph.addConstant(constantSystem.createString( | 799 return graph.addConstant(constantSystem.createString( |
801 primitive.toDartString()), compiler); | 800 primitive.toDartString()), compiler); |
802 } | 801 } |
803 return node; | 802 return node; |
804 } | 803 } |
805 | 804 |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 | 1965 |
1967 keyedValues.forEach((receiver, values) { | 1966 keyedValues.forEach((receiver, values) { |
1968 result.keyedValues[receiver] = | 1967 result.keyedValues[receiver] = |
1969 new Map<HInstruction, HInstruction>.from(values); | 1968 new Map<HInstruction, HInstruction>.from(values); |
1970 }); | 1969 }); |
1971 | 1970 |
1972 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 1971 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
1973 return result; | 1972 return result; |
1974 } | 1973 } |
1975 } | 1974 } |
OLD | NEW |