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.node_tracer; | 5 library compiler.src.inferrer.node_tracer; |
6 | 6 |
7 import '../common/names.dart' show Identifiers; | 7 import '../common/names.dart' show Identifiers; |
8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../types/types.dart' show ContainerTypeMask, MapTypeMask; | 10 import '../types/types.dart' show ContainerTypeMask, MapTypeMask; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 void addNewEscapeInformation(TypeInformation info) { | 107 void addNewEscapeInformation(TypeInformation info) { |
108 if (flowsInto.contains(info)) return; | 108 if (flowsInto.contains(info)) return; |
109 flowsInto.add(info); | 109 flowsInto.add(info); |
110 workList.add(info); | 110 workList.add(info); |
111 } | 111 } |
112 | 112 |
113 bool _wouldBeTooManyUsers(Set users) { | 113 bool _wouldBeTooManyUsers(Set users) { |
114 int seenSoFar = analyzedElements.length; | 114 int seenSoFar = analyzedElements.length; |
115 if (seenSoFar + users.length <= MAX_ANALYSIS_COUNT) return false; | 115 if (seenSoFar + users.length <= MAX_ANALYSIS_COUNT) return false; |
116 int actualWork = users | 116 int actualWork = 0; |
117 .where((TypeInformation user) => !analyzedElements.contains(user.owner)) | 117 for (TypeInformation user in users) { |
118 .length; | 118 if (!analyzedElements.contains(user.owner)) { |
119 return seenSoFar + actualWork > MAX_ANALYSIS_COUNT; | 119 actualWork++; |
| 120 if (actualWork > MAX_ANALYSIS_COUNT - seenSoFar) return true; |
| 121 } |
| 122 } |
| 123 return false; |
120 } | 124 } |
121 | 125 |
122 void analyze() { | 126 void analyze() { |
123 // Collect the [TypeInformation] where the list can flow in, | 127 // Collect the [TypeInformation] where the list can flow in, |
124 // as well as the operations done on all these [TypeInformation]s. | 128 // as well as the operations done on all these [TypeInformation]s. |
125 addNewEscapeInformation(tracedType); | 129 addNewEscapeInformation(tracedType); |
126 while (!workList.isEmpty) { | 130 while (!workList.isEmpty) { |
127 currentUser = workList.removeLast(); | 131 currentUser = workList.removeLast(); |
128 if (_wouldBeTooManyUsers(currentUser.users)) { | 132 if (_wouldBeTooManyUsers(currentUser.users)) { |
129 bailout('Too many users'); | 133 bailout('Too many users'); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 402 } |
399 if (isParameterOfListAddingMethod(info.element) || | 403 if (isParameterOfListAddingMethod(info.element) || |
400 isParameterOfMapAddingMethod(info.element)) { | 404 isParameterOfMapAddingMethod(info.element)) { |
401 // These elements are being handled in | 405 // These elements are being handled in |
402 // [visitDynamicCallSiteTypeInformation]. | 406 // [visitDynamicCallSiteTypeInformation]. |
403 return; | 407 return; |
404 } | 408 } |
405 addNewEscapeInformation(info); | 409 addNewEscapeInformation(info); |
406 } | 410 } |
407 } | 411 } |
OLD | NEW |