| 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 library compiler.src.inferrer.closure_tracer; | 5 library compiler.src.inferrer.closure_tracer; |
| 6 | 6 |
| 7 import '../common/names.dart' show Names; | 7 import '../common/names.dart' show Names; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../js_backend/backend.dart' show JavaScriptBackend; | 9 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 _registerCallForLaterAnalysis(info); | 70 _registerCallForLaterAnalysis(info); |
| 71 } else { | 71 } else { |
| 72 bailout('Passed to a closure'); | 72 bailout('Passed to a closure'); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 @override | 76 @override |
| 77 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { | 77 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { |
| 78 super.visitStaticCallSiteTypeInformation(info); | 78 super.visitStaticCallSiteTypeInformation(info); |
| 79 Element called = info.calledElement; | 79 Element called = info.calledElement; |
| 80 if (compiler.backend.isForeign(compiler.commonElements, called)) { | 80 if (compiler.backend |
| 81 .isForeign(inferrer.closedWorld.commonElements, called)) { |
| 81 String name = called.name; | 82 String name = called.name; |
| 82 if (name == JavaScriptBackend.JS || name == 'DART_CLOSURE_TO_JS') { | 83 if (name == JavaScriptBackend.JS || name == 'DART_CLOSURE_TO_JS') { |
| 83 bailout('Used in JS ${info.call}'); | 84 bailout('Used in JS ${info.call}'); |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 if (called.isGetter && | 87 if (called.isGetter && |
| 87 info.selector != null && | 88 info.selector != null && |
| 88 info.selector.isCall && | 89 info.selector.isCall && |
| 89 inferrer.types.getInferredTypeOf(called) == currentUser) { | 90 inferrer.types.getInferredTypeOf(called) == currentUser) { |
| 90 // This node can be a closure call as well. For example, `foo()` | 91 // This node can be a closure call as well. For example, `foo()` |
| 91 // where `foo` is a getter. | 92 // where `foo` is a getter. |
| 92 _registerCallForLaterAnalysis(info); | 93 _registerCallForLaterAnalysis(info); |
| 93 } | 94 } |
| 94 if (called is MemberElement && | 95 if (called is MemberElement && |
| 95 _checkIfFunctionApply(called) && | 96 _checkIfFunctionApply(called) && |
| 96 info.arguments != null && | 97 info.arguments != null && |
| 97 info.arguments.contains(currentUser)) { | 98 info.arguments.contains(currentUser)) { |
| 98 _tagAsFunctionApplyTarget("static call"); | 99 _tagAsFunctionApplyTarget("static call"); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool _checkIfCurrentUser(element) => | 103 bool _checkIfCurrentUser(element) => |
| 103 inferrer.types.getInferredTypeOf(element) == currentUser; | 104 inferrer.types.getInferredTypeOf(element) == currentUser; |
| 104 | 105 |
| 105 bool _checkIfFunctionApply(MemberElement element) { | 106 bool _checkIfFunctionApply(MemberElement element) { |
| 106 return compiler.commonElements.isFunctionApplyMethod(element); | 107 return inferrer.closedWorld.commonElements.isFunctionApplyMethod(element); |
| 107 } | 108 } |
| 108 | 109 |
| 109 @override | 110 @override |
| 110 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { | 111 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { |
| 111 super.visitDynamicCallSiteTypeInformation(info); | 112 super.visitDynamicCallSiteTypeInformation(info); |
| 112 if (info.selector.isCall) { | 113 if (info.selector.isCall) { |
| 113 if (info.arguments.contains(currentUser)) { | 114 if (info.arguments.contains(currentUser)) { |
| 114 if (!info.targets.every((element) => element.isFunction)) { | 115 if (!info.targets.every((element) => element.isFunction)) { |
| 115 bailout('Passed to a closure'); | 116 bailout('Passed to a closure'); |
| 116 } | 117 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 135 @override | 136 @override |
| 136 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { | 137 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { |
| 137 super.visitStaticCallSiteTypeInformation(info); | 138 super.visitStaticCallSiteTypeInformation(info); |
| 138 if (info.calledElement == tracedElements.first && | 139 if (info.calledElement == tracedElements.first && |
| 139 info.selector != null && | 140 info.selector != null && |
| 140 info.selector.isGetter) { | 141 info.selector.isGetter) { |
| 141 addNewEscapeInformation(info); | 142 addNewEscapeInformation(info); |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 } | 145 } |
| OLD | NEW |