| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine; | 8 library engine; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 bool hintsEnabled = _options.hint; | 1630 bool hintsEnabled = _options.hint; |
| 1631 // | 1631 // |
| 1632 // Look for priority sources that need to be analyzed. | 1632 // Look for priority sources that need to be analyzed. |
| 1633 // | 1633 // |
| 1634 for (Source source in _priorityOrder) { | 1634 for (Source source in _priorityOrder) { |
| 1635 _getSourcesNeedingProcessing(source, _cache.get(source), true, hintsEnable
d, sources); | 1635 _getSourcesNeedingProcessing(source, _cache.get(source), true, hintsEnable
d, sources); |
| 1636 } | 1636 } |
| 1637 // | 1637 // |
| 1638 // Look for non-priority sources that need to be analyzed. | 1638 // Look for non-priority sources that need to be analyzed. |
| 1639 // | 1639 // |
| 1640 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1640 WorkManager_WorkIterator iterator = _workManager.iterator(); |
| 1641 while (iterator.moveNext()) { | 1641 while (iterator.hasNext) { |
| 1642 _getSourcesNeedingProcessing(iterator.key, iterator.value, false, hintsEna
bled, sources); | 1642 Source source = iterator.next(); |
| 1643 _getSourcesNeedingProcessing(source, _cache.get(source), false, hintsEnabl
ed, sources); |
| 1643 } | 1644 } |
| 1644 return new List<Source>.from(sources); | 1645 return new List<Source>.from(sources); |
| 1645 } | 1646 } |
| 1646 | 1647 |
| 1647 @override | 1648 @override |
| 1648 AnalysisContextStatistics get statistics { | 1649 AnalysisContextStatistics get statistics { |
| 1649 bool hintsEnabled = _options.hint; | 1650 bool hintsEnabled = _options.hint; |
| 1650 AnalysisContextStatisticsImpl statistics = new AnalysisContextStatisticsImpl
(); | 1651 AnalysisContextStatisticsImpl statistics = new AnalysisContextStatisticsImpl
(); |
| 1651 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1652 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
| 1652 while (iterator.moveNext()) { | 1653 while (iterator.moveNext()) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 int getStart = JavaSystem.currentTimeMillis(); | 1765 int getStart = JavaSystem.currentTimeMillis(); |
| 1765 AnalysisTask task = nextAnalysisTask; | 1766 AnalysisTask task = nextAnalysisTask; |
| 1766 int getEnd = JavaSystem.currentTimeMillis(); | 1767 int getEnd = JavaSystem.currentTimeMillis(); |
| 1767 if (task == null && _validateCacheConsistency()) { | 1768 if (task == null && _validateCacheConsistency()) { |
| 1768 task = nextAnalysisTask; | 1769 task = nextAnalysisTask; |
| 1769 } | 1770 } |
| 1770 if (task == null) { | 1771 if (task == null) { |
| 1771 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); | 1772 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); |
| 1772 } | 1773 } |
| 1773 String taskDescription = task.toString(); | 1774 String taskDescription = task.toString(); |
| 1774 if (!_reportedLoop && !_recentTasks.add(taskDescription)) { | 1775 // if (!reportedLoop && !recentTasks.add(taskDescription)) { |
| 1775 PrintStringWriter writer = new PrintStringWriter(); | 1776 // reportedLoop = true; |
| 1776 writer.print("Performing repeated task: "); | 1777 // @SuppressWarnings("resource") |
| 1777 writer.println(taskDescription); | 1778 // PrintStringWriter writer = new PrintStringWriter(); |
| 1778 for (String description in _recentTasks) { | 1779 // writer.print("Performing repeated task: "); |
| 1779 writer.print(" "); | 1780 // writer.println(taskDescription); |
| 1780 writer.println(description); | 1781 // for (String description : recentTasks) { |
| 1781 } | 1782 // writer.print(" "); |
| 1782 _logInformation(writer.toString()); | 1783 // writer.println(description); |
| 1783 } | 1784 // } |
| 1785 // logInformation(writer.toString()); |
| 1786 // } |
| 1784 _notifyAboutToPerformTask(taskDescription); | 1787 _notifyAboutToPerformTask(taskDescription); |
| 1785 if (_TRACE_PERFORM_TASK) { | 1788 if (_TRACE_PERFORM_TASK) { |
| 1786 print(taskDescription); | 1789 print(taskDescription); |
| 1787 } | 1790 } |
| 1788 int performStart = JavaSystem.currentTimeMillis(); | 1791 int performStart = JavaSystem.currentTimeMillis(); |
| 1789 try { | 1792 try { |
| 1790 task.perform(_resultRecorder); | 1793 task.perform(_resultRecorder); |
| 1791 } on ObsoleteSourceAnalysisException catch (exception) { | 1794 } on ObsoleteSourceAnalysisException catch (exception) { |
| 1792 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescription}", exception); | 1795 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescription}", exception); |
| 1793 } on AnalysisException catch (exception) { | 1796 } on AnalysisException catch (exception) { |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 } else { | 3354 } else { |
| 3352 sourcesToRemove.add(source); | 3355 sourcesToRemove.add(source); |
| 3353 } | 3356 } |
| 3354 } | 3357 } |
| 3355 } finally { | 3358 } finally { |
| 3356 int count = sourcesToRemove.length; | 3359 int count = sourcesToRemove.length; |
| 3357 for (int i = 0; i < count; i++) { | 3360 for (int i = 0; i < count; i++) { |
| 3358 _workManager.remove(sourcesToRemove[i]); | 3361 _workManager.remove(sourcesToRemove[i]); |
| 3359 } | 3362 } |
| 3360 } | 3363 } |
| 3361 // // | |
| 3362 // // Look for a non-priority source that needs to be analyzed and was
missed by the loop above. | |
| 3363 // // | |
| 3364 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) { | |
| 3365 // source = entry.getKey(); | |
| 3366 // TaskData taskData = getNextAnalysisTaskForSource(source, entry.get
Value(), false, hintsEnabled); | |
| 3367 // AnalysisTask task = taskData.getTask(); | |
| 3368 // if (task != null) { | |
| 3369 // System.out.println("Failed to analyze " + source.getFullName()); | |
| 3370 // return task; | |
| 3371 // } | |
| 3372 // } | |
| 3373 if (hasBlockedTask) { | 3364 if (hasBlockedTask) { |
| 3374 // All of the analysis work is blocked waiting for an asynchronous task to
complete. | 3365 // All of the analysis work is blocked waiting for an asynchronous task to
complete. |
| 3375 return WaitForAsyncTask.instance; | 3366 return WaitForAsyncTask.instance; |
| 3376 } | 3367 } |
| 3377 return null; | 3368 return null; |
| 3378 } | 3369 } |
| 3379 | 3370 |
| 3380 /** | 3371 /** |
| 3381 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the | 3372 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the |
| 3382 * task that should be performed, or `null` if there is no more work to be don
e for the | 3373 * task that should be performed, or `null` if there is no more work to be don
e for the |
| (...skipping 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6267 * The logger that should receive information about errors within the analysis
engine. | 6258 * The logger that should receive information about errors within the analysis
engine. |
| 6268 */ | 6259 */ |
| 6269 Logger _logger = Logger.NULL; | 6260 Logger _logger = Logger.NULL; |
| 6270 | 6261 |
| 6271 /** | 6262 /** |
| 6272 * The partition manager being used to manage the shared partitions. | 6263 * The partition manager being used to manage the shared partitions. |
| 6273 */ | 6264 */ |
| 6274 final PartitionManager partitionManager = new PartitionManager(); | 6265 final PartitionManager partitionManager = new PartitionManager(); |
| 6275 | 6266 |
| 6276 /** | 6267 /** |
| 6268 * A flag indicating whether union types should be used. |
| 6269 */ |
| 6270 bool enableUnionTypes = false; |
| 6271 |
| 6272 /** |
| 6273 * A flag indicating whether union types should have strict semantics. This op
tion has no effect |
| 6274 * when `enabledUnionTypes` is `false`. |
| 6275 */ |
| 6276 bool strictUnionTypes = false; |
| 6277 |
| 6278 /** |
| 6279 * Clear any caches holding on to analysis results so that a full re-analysis
will be performed |
| 6280 * the next time an analysis context is created. |
| 6281 */ |
| 6282 void clearCaches() { |
| 6283 partitionManager.clearCache(); |
| 6284 } |
| 6285 |
| 6286 /** |
| 6277 * Create a new context in which analysis can be performed. | 6287 * Create a new context in which analysis can be performed. |
| 6278 * | 6288 * |
| 6279 * @return the analysis context that was created | 6289 * @return the analysis context that was created |
| 6280 */ | 6290 */ |
| 6281 AnalysisContext createAnalysisContext() { | 6291 AnalysisContext createAnalysisContext() { |
| 6282 // | 6292 // |
| 6283 // If instrumentation is ignoring data, return an uninstrumented analysis co
ntext. | 6293 // If instrumentation is ignoring data, return an uninstrumented analysis co
ntext. |
| 6284 // | 6294 // |
| 6285 if (Instrumentation.isNullLogger) { | 6295 if (Instrumentation.isNullLogger) { |
| 6286 return new AnalysisContextImpl(); | 6296 return new AnalysisContextImpl(); |
| (...skipping 5963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12250 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); | 12260 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); |
| 12251 _checkThread(instrumentation); | 12261 _checkThread(instrumentation); |
| 12252 try { | 12262 try { |
| 12253 instrumentation.metric3("contextId", _contextId); | 12263 instrumentation.metric3("contextId", _contextId); |
| 12254 AnalysisResult result = _basis.performAnalysisTask(); | 12264 AnalysisResult result = _basis.performAnalysisTask(); |
| 12255 if (result.changeNotices != null) { | 12265 if (result.changeNotices != null) { |
| 12256 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt
h); | 12266 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt
h); |
| 12257 } | 12267 } |
| 12258 return result; | 12268 return result; |
| 12259 } finally { | 12269 } finally { |
| 12260 instrumentation.log2(2); | 12270 instrumentation.log2(15); |
| 12261 } | 12271 } |
| 12262 } | 12272 } |
| 12263 | 12273 |
| 12264 @override | 12274 @override |
| 12265 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 12275 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 12266 _basis.recordLibraryElements(elementMap); | 12276 _basis.recordLibraryElements(elementMap); |
| 12267 } | 12277 } |
| 12268 | 12278 |
| 12269 @override | 12279 @override |
| 12270 void removeListener(AnalysisListener listener) { | 12280 void removeListener(AnalysisListener listener) { |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13212 * A table mapping SDK's to the partitions used for those SDK's. | 13222 * A table mapping SDK's to the partitions used for those SDK's. |
| 13213 */ | 13223 */ |
| 13214 HashMap<DartSdk, SdkCachePartition> _sdkPartitions = new HashMap<DartSdk, SdkC
achePartition>(); | 13224 HashMap<DartSdk, SdkCachePartition> _sdkPartitions = new HashMap<DartSdk, SdkC
achePartition>(); |
| 13215 | 13225 |
| 13216 /** | 13226 /** |
| 13217 * The default cache size for a Dart SDK partition. | 13227 * The default cache size for a Dart SDK partition. |
| 13218 */ | 13228 */ |
| 13219 static int _DEFAULT_SDK_CACHE_SIZE = 256; | 13229 static int _DEFAULT_SDK_CACHE_SIZE = 256; |
| 13220 | 13230 |
| 13221 /** | 13231 /** |
| 13232 * Clear any cached data being maintained by this manager. |
| 13233 */ |
| 13234 void clearCache() { |
| 13235 _sdkPartitions.clear(); |
| 13236 } |
| 13237 |
| 13238 /** |
| 13222 * Return the partition being used for the given SDK, creating the partition i
f necessary. | 13239 * Return the partition being used for the given SDK, creating the partition i
f necessary. |
| 13223 * | 13240 * |
| 13224 * @param sdk the SDK for which a partition is being requested | 13241 * @param sdk the SDK for which a partition is being requested |
| 13225 * @return the partition being used for the given SDK | 13242 * @return the partition being used for the given SDK |
| 13226 */ | 13243 */ |
| 13227 SdkCachePartition forSdk(DartSdk sdk) { | 13244 SdkCachePartition forSdk(DartSdk sdk) { |
| 13228 SdkCachePartition partition = _sdkPartitions[sdk]; | 13245 SdkCachePartition partition = _sdkPartitions[sdk]; |
| 13229 if (partition == null) { | 13246 if (partition == null) { |
| 13230 partition = new SdkCachePartition(sdk.context as InternalAnalysisContext,
_DEFAULT_SDK_CACHE_SIZE); | 13247 partition = new SdkCachePartition(sdk.context as InternalAnalysisContext,
_DEFAULT_SDK_CACHE_SIZE); |
| 13231 _sdkPartitions[sdk] = partition; | 13248 _sdkPartitions[sdk] = partition; |
| (...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15585 _index++; | 15602 _index++; |
| 15586 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { | 15603 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { |
| 15587 _index = 0; | 15604 _index = 0; |
| 15588 _queueIndex++; | 15605 _queueIndex++; |
| 15589 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { | 15606 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { |
| 15590 _queueIndex++; | 15607 _queueIndex++; |
| 15591 } | 15608 } |
| 15592 } | 15609 } |
| 15593 } | 15610 } |
| 15594 } | 15611 } |
| OLD | NEW |