| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:analyzer/context/context_root.dart'; | 9 import 'package:analyzer/context/context_root.dart'; |
| 10 import 'package:analyzer/context/declared_variables.dart'; | 10 import 'package:analyzer/context/declared_variables.dart'; |
| 11 import 'package:analyzer/dart/analysis/results.dart' as results; | 11 import 'package:analyzer/dart/analysis/results.dart' as results; |
| 12 import 'package:analyzer/dart/ast/ast.dart'; | 12 import 'package:analyzer/dart/ast/ast.dart'; |
| 13 import 'package:analyzer/dart/element/element.dart' | 13 import 'package:analyzer/dart/element/element.dart' |
| 14 show CompilationUnitElement, LibraryElement; | 14 show CompilationUnitElement, LibraryElement; |
| 15 import 'package:analyzer/error/error.dart'; | 15 import 'package:analyzer/error/error.dart'; |
| 16 import 'package:analyzer/error/listener.dart'; | 16 import 'package:analyzer/error/listener.dart'; |
| 17 import 'package:analyzer/exception/exception.dart'; | 17 import 'package:analyzer/exception/exception.dart'; |
| 18 import 'package:analyzer/file_system/file_system.dart'; | 18 import 'package:analyzer/file_system/file_system.dart'; |
| 19 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 19 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
| 20 import 'package:analyzer/src/dart/analysis/file_tracker.dart'; | 20 import 'package:analyzer/src/dart/analysis/file_tracker.dart'; |
| 21 import 'package:analyzer/src/dart/analysis/index.dart'; | 21 import 'package:analyzer/src/dart/analysis/index.dart'; |
| 22 import 'package:analyzer/src/dart/analysis/library_analyzer.dart'; | 22 import 'package:analyzer/src/dart/analysis/library_analyzer.dart'; |
| 23 import 'package:analyzer/src/dart/analysis/library_context.dart'; | 23 import 'package:analyzer/src/dart/analysis/library_context.dart'; |
| 24 import 'package:analyzer/src/dart/analysis/search.dart'; | 24 import 'package:analyzer/src/dart/analysis/search.dart'; |
| 25 import 'package:analyzer/src/dart/analysis/status.dart'; | 25 import 'package:analyzer/src/dart/analysis/status.dart'; |
| 26 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; | 26 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; |
| 27 import 'package:analyzer/src/generated/engine.dart' | 27 import 'package:analyzer/src/generated/engine.dart' |
| 28 show AnalysisContext, AnalysisEngine, AnalysisOptions; | 28 show |
| 29 AnalysisContext, |
| 30 AnalysisEngine, |
| 31 AnalysisOptions, |
| 32 PerformanceStatistics; |
| 29 import 'package:analyzer/src/generated/source.dart'; | 33 import 'package:analyzer/src/generated/source.dart'; |
| 34 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 30 import 'package:analyzer/src/lint/registry.dart' as linter; | 35 import 'package:analyzer/src/lint/registry.dart' as linter; |
| 31 import 'package:analyzer/src/summary/format.dart'; | 36 import 'package:analyzer/src/summary/format.dart'; |
| 32 import 'package:analyzer/src/summary/idl.dart'; | 37 import 'package:analyzer/src/summary/idl.dart'; |
| 33 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 38 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 34 import 'package:front_end/src/base/api_signature.dart'; | 39 import 'package:front_end/src/base/api_signature.dart'; |
| 35 import 'package:front_end/src/base/performace_logger.dart'; | 40 import 'package:front_end/src/base/performace_logger.dart'; |
| 36 import 'package:front_end/src/incremental/byte_store.dart'; | 41 import 'package:front_end/src/incremental/byte_store.dart'; |
| 37 import 'package:meta/meta.dart'; | 42 import 'package:meta/meta.dart'; |
| 38 | 43 |
| 44 class DriverPerformance { |
| 45 static final PerformanceTag driver = |
| 46 PerformanceStatistics.analyzer.createChild('driver'); |
| 47 |
| 48 static final PerformanceTag cache = driver.createChild('cache'); |
| 49 } |
| 50 |
| 39 /** | 51 /** |
| 40 * This class computes [AnalysisResult]s for Dart files. | 52 * This class computes [AnalysisResult]s for Dart files. |
| 41 * | 53 * |
| 42 * Let the set of "explicitly analyzed files" denote the set of paths that have | 54 * Let the set of "explicitly analyzed files" denote the set of paths that have |
| 43 * been passed to [addFile] but not subsequently passed to [removeFile]. Let | 55 * been passed to [addFile] but not subsequently passed to [removeFile]. Let |
| 44 * the "current analysis results" denote the map from the set of explicitly | 56 * the "current analysis results" denote the map from the set of explicitly |
| 45 * analyzed files to the most recent [AnalysisResult] delivered to [results] | 57 * analyzed files to the most recent [AnalysisResult] delivered to [results] |
| 46 * for each file. Let the "current file state" represent a map from file path | 58 * for each file. Let the "current file state" represent a map from file path |
| 47 * to the file contents most recently read from that file, or fetched from the | 59 * to the file contents most recently read from that file, or fetched from the |
| 48 * content cache (considering all possible possible file paths, regardless of | 60 * content cache (considering all possible possible file paths, regardless of |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // Skip reading if the signature, so errors, are the same as the last time. | 983 // Skip reading if the signature, so errors, are the same as the last time. |
| 972 if (skipIfSameSignature) { | 984 if (skipIfSameSignature) { |
| 973 assert(!withUnit); | 985 assert(!withUnit); |
| 974 if (_lastProducedSignatures[path] == signature) { | 986 if (_lastProducedSignatures[path] == signature) { |
| 975 return AnalysisResult._UNCHANGED; | 987 return AnalysisResult._UNCHANGED; |
| 976 } | 988 } |
| 977 } | 989 } |
| 978 | 990 |
| 979 // If we don't need the fully resolved unit, check for the cached result. | 991 // If we don't need the fully resolved unit, check for the cached result. |
| 980 if (!withUnit) { | 992 if (!withUnit) { |
| 981 List<int> bytes = _byteStore.get(key); | 993 List<int> bytes = DriverPerformance.cache.makeCurrentWhile(() { |
| 994 return _byteStore.get(key); |
| 995 }); |
| 982 if (bytes != null) { | 996 if (bytes != null) { |
| 983 return _getAnalysisResultFromBytes(file, signature, bytes); | 997 return _getAnalysisResultFromBytes(file, signature, bytes); |
| 984 } | 998 } |
| 985 } | 999 } |
| 986 | 1000 |
| 987 // We need the fully resolved unit, or the result is not cached. | 1001 // We need the fully resolved unit, or the result is not cached. |
| 988 return _logger.run('Compute analysis result for $path', () { | 1002 return _logger.run('Compute analysis result for $path', () { |
| 989 try { | 1003 try { |
| 990 LibraryContext libraryContext = _createLibraryContext(library); | 1004 LibraryContext libraryContext = _createLibraryContext(library); |
| 991 try { | 1005 try { |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 libraryDeclarations.add(new TopLevelDeclarationInSource( | 1997 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 1984 file.source, declaration, isExported)); | 1998 file.source, declaration, isExported)); |
| 1985 } | 1999 } |
| 1986 } | 2000 } |
| 1987 } | 2001 } |
| 1988 | 2002 |
| 1989 // We're not done yet. | 2003 // We're not done yet. |
| 1990 return false; | 2004 return false; |
| 1991 } | 2005 } |
| 1992 } | 2006 } |
| OLD | NEW |