| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // If the type can be null, and the intercepted method can be in | 220 // If the type can be null, and the intercepted method can be in |
| 221 // the object class, keep the interceptor. | 221 // the object class, keep the interceptor. |
| 222 if (type.canBeNull() | 222 if (type.canBeNull() |
| 223 && interceptor.interceptedClasses.contains(compiler.objectClass)) { | 223 && interceptor.interceptedClasses.contains(compiler.objectClass)) { |
| 224 return node; | 224 return node; |
| 225 } | 225 } |
| 226 // Change the call to a regular invoke dynamic call. | 226 // Change the call to a regular invoke dynamic call. |
| 227 return new HInvokeDynamicMethod( | 227 return new HInvokeDynamicMethod( |
| 228 node.selector, node.inputs.getRange(1, node.inputs.length - 1)); | 228 node.selector, node.inputs.getRange(1, node.inputs.length - 1)); |
| 229 } | 229 } |
| 230 HInstruction instruction = |
| 231 node.specializer.tryConvertToBuiltin(node, types); |
| 232 if (instruction != null) return instruction; |
| 230 | 233 |
| 231 Selector selector = node.selector; | 234 Selector selector = node.selector; |
| 232 | |
| 233 // TODO(ngeoffray): Move this logic into a separate class. | |
| 234 if (selector.kind == SelectorKind.INDEX | |
| 235 && input.isIndexablePrimitive(types)) { | |
| 236 if (selector.name == const SourceString('[]')) { | |
| 237 return new HIndex(node.inputs[1], node.inputs[2]); | |
| 238 } else if (input.isMutableArray(types)) { | |
| 239 assert(selector.name == const SourceString('[]=')); | |
| 240 return new HIndexAssign(node.inputs[1], node.inputs[2], node.inputs[3]); | |
| 241 } | |
| 242 } else if (selector.kind == SelectorKind.OPERATOR) { | |
| 243 if (selector.name == const SourceString('unary-')) { | |
| 244 if (input.isNumber(types)) { | |
| 245 return new HNegate(input); | |
| 246 } | |
| 247 } else if (selector.name == const SourceString('~')) { | |
| 248 if (input.isNumber(types)) { | |
| 249 return new HBitNot(input); | |
| 250 } | |
| 251 } | |
| 252 } | |
| 253 | |
| 254 SourceString selectorName = selector.name; | 235 SourceString selectorName = selector.name; |
| 255 Element target; | 236 Element target; |
| 256 if (input.isExtendableArray(types)) { | 237 if (input.isExtendableArray(types)) { |
| 257 if (selectorName == backend.jsArrayRemoveLast.name | 238 if (selectorName == backend.jsArrayRemoveLast.name |
| 258 && selector.argumentCount == 0) { | 239 && selector.argumentCount == 0) { |
| 259 target = backend.jsArrayRemoveLast; | 240 target = backend.jsArrayRemoveLast; |
| 260 } else if (selectorName == backend.jsArrayAdd.name | 241 } else if (selectorName == backend.jsArrayAdd.name |
| 261 && selector.argumentCount == 1 | 242 && selector.argumentCount == 1 |
| 262 && selector.namedArgumentCount == 0 | 243 && selector.namedArgumentCount == 0 |
| 263 && !compiler.enableTypeAssertions) { | 244 && !compiler.enableTypeAssertions) { |
| (...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 HInstruction receiver = interceptor.receiver; | 1475 HInstruction receiver = interceptor.receiver; |
| 1495 for (var user in receiver.usedBy) { | 1476 for (var user in receiver.usedBy) { |
| 1496 if (user is HInterceptor && interceptor.dominates(user)) { | 1477 if (user is HInterceptor && interceptor.dominates(user)) { |
| 1497 user.interceptedClasses = interceptor.interceptedClasses; | 1478 user.interceptedClasses = interceptor.interceptedClasses; |
| 1498 } | 1479 } |
| 1499 } | 1480 } |
| 1500 } | 1481 } |
| 1501 | 1482 |
| 1502 // TODO(ngeoffray): Also implement it for non-intercepted calls. | 1483 // TODO(ngeoffray): Also implement it for non-intercepted calls. |
| 1503 } | 1484 } |
| OLD | NEW |