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