| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 type_graph_inferrer; | 5 part of type_graph_inferrer; |
| 6 | 6 |
| 7 class ClosureTracerVisitor extends TracerVisitor { | 7 class ClosureTracerVisitor extends TracerVisitor { |
| 8 ClosureTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer); | 8 ClosureTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer); |
| 9 | 9 |
| 10 void run() { | 10 void run() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bailout('Passed to a closure'); | 47 bailout('Passed to a closure'); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { | 51 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { |
| 52 super.visitStaticCallSiteTypeInformation(info); | 52 super.visitStaticCallSiteTypeInformation(info); |
| 53 Element called = info.calledElement; | 53 Element called = info.calledElement; |
| 54 if (called.isForeign(compiler) && called.name == 'JS') { | 54 if (called.isForeign(compiler) && called.name == 'JS') { |
| 55 bailout('Used in JS ${info.call}'); | 55 bailout('Used in JS ${info.call}'); |
| 56 } | 56 } |
| 57 if (inferrer.types.getInferredTypeOf(called) == currentUser) { |
| 58 // This node can be a closure call as well. For example, `foo()` |
| 59 // where `foo` is a getter. |
| 60 analyzeCall(info); |
| 61 } |
| 57 } | 62 } |
| 58 | 63 |
| 59 bool checkIfCurrentUser(element) { | 64 bool checkIfCurrentUser(element) { |
| 60 return inferrer.types.getInferredTypeOf(element) == currentUser; | 65 return inferrer.types.getInferredTypeOf(element) == currentUser; |
| 61 } | 66 } |
| 62 | 67 |
| 63 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { | 68 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { |
| 64 super.visitDynamicCallSiteTypeInformation(info); | 69 super.visitDynamicCallSiteTypeInformation(info); |
| 65 if (info.selector.isCall()) { | 70 if (info.selector.isCall()) { |
| 66 if (info.arguments.contains(currentUser) | 71 if (info.arguments.contains(currentUser) |
| 67 && !info.targets.every((element) => element.isFunction())) { | 72 && !info.targets.every((element) => element.isFunction())) { |
| 68 bailout('Passed to a closure'); | 73 bailout('Passed to a closure'); |
| 69 } else if (info.targets.any((element) => checkIfCurrentUser(element))) { | 74 } else if (info.targets.any((element) => checkIfCurrentUser(element))) { |
| 70 analyzeCall(info); | 75 analyzeCall(info); |
| 71 } | 76 } |
| 72 } | 77 } |
| 73 } | 78 } |
| 74 } | 79 } |
| OLD | NEW |