Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 2015513003: Optimize more megamorphic dispatch sites (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/instrumentation/instrumentation.dart ('k') | pkg/analyzer/lib/src/context/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/cache.dart
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart
index 130beb41ee5029250f3d73b91e1c5d3feece13a2..cbf27057fc09fcf7311ea20f953fa51732cc2d1f 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -603,8 +603,14 @@ class CacheEntry {
// Stop depending on other results.
if (deltaResult != DeltaResult.KEEP_CONTINUE) {
TargetedResult thisResult = new TargetedResult(target, descriptor);
- for (TargetedResult dependedOnResult in thisData.dependedOnResults) {
- for (AnalysisCache cache in _partition.containingCaches) {
+ List<AnalysisCache> caches = _partition.containingCaches;
+ int cacheLength = caches.length;
+ List<TargetedResult> results = thisData.dependedOnResults;
+ int resultLength = results.length;
+ for (int i = 0; i < resultLength; i++) {
+ TargetedResult dependedOnResult = results[i];
+ for (int j = 0; j < cacheLength; j++) {
+ AnalysisCache cache = caches[j];
CacheEntry entry = cache.get(dependedOnResult.target);
if (entry != null) {
ResultData data =
@@ -636,7 +642,9 @@ class CacheEntry {
*/
void _invalidateAll() {
List<ResultDescriptor> results = _resultMap.keys.toList();
- for (ResultDescriptor result in results) {
+ int length = results.length;
+ for (int i = 0; i < length; i++) {
+ ResultDescriptor result = results[i];
_invalidate(nextInvalidateId++, result, null, 0);
}
}
@@ -648,9 +656,14 @@ class CacheEntry {
int id, ResultData thisData, Delta delta, int level) {
// It is necessary to copy the results to a list to avoid a concurrent
// modification of the set of dependent results.
+ List<AnalysisCache> caches = _partition.containingCaches;
+ int cacheLength = caches.length;
List<TargetedResult> dependentResults = thisData.dependentResults.toList();
- for (TargetedResult dependentResult in dependentResults) {
- for (AnalysisCache cache in _partition.containingCaches) {
+ int resultLength = dependentResults.length;
+ for (int i = 0; i < resultLength; i++) {
+ TargetedResult dependentResult = dependentResults[i];
+ for (int j = 0; j < cacheLength; j++) {
+ AnalysisCache cache = caches[j];
CacheEntry entry = cache.get(dependentResult.target);
if (entry != null) {
entry._invalidate(id, dependentResult.result, delta, level);
@@ -673,8 +686,15 @@ class CacheEntry {
*/
void _setDependedOnResults(ResultData thisData, TargetedResult thisResult,
List<TargetedResult> dependedOn) {
- thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
- for (AnalysisCache cache in _partition.containingCaches) {
+ List<AnalysisCache> caches = _partition.containingCaches;
+ int cacheLength = caches.length;
+
+ List<TargetedResult> oldResults = thisData.dependedOnResults;
+ int oldLength = oldResults.length;
+ for (int i = 0; i < oldLength; i++) {
+ TargetedResult dependedOnResult = oldResults[i];
+ for (int j = 0; j < cacheLength; j++) {
+ AnalysisCache cache = caches[j];
CacheEntry entry = cache.get(dependedOnResult.target);
if (entry != null) {
ResultData data = entry.getResultDataOrNull(dependedOnResult.result);
@@ -683,10 +703,13 @@ class CacheEntry {
}
}
}
- });
+ }
thisData.dependedOnResults = dependedOn;
- thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
- for (AnalysisCache cache in _partition.containingCaches) {
+ int newLength = dependedOn.length;
+ for (int i = 0; i < newLength; i++) {
+ TargetedResult dependedOnResult = dependedOn[i];
+ for (int j = 0; j < cacheLength; j++) {
+ AnalysisCache cache = caches[j];
CacheEntry entry = cache.get(dependedOnResult.target);
if (entry != null) {
ResultData data = entry.getResultDataOrNull(dependedOnResult.result);
@@ -695,7 +718,7 @@ class CacheEntry {
}
}
}
- });
+ }
}
/**
@@ -709,8 +732,11 @@ class CacheEntry {
thisData.state = CacheState.ERROR;
thisData.value = descriptor.defaultValue;
// Propagate the error state.
+ List<AnalysisCache> caches = _partition.containingCaches;
+ int cacheLength = caches.length;
thisData.dependentResults.forEach((TargetedResult dependentResult) {
- for (AnalysisCache cache in _partition.containingCaches) {
+ for (int j = 0; j < cacheLength; j++) {
scheglov 2016/05/25 17:44:46 Could be 'i'.
Brian Wilkerson 2016/05/25 17:48:42 Done
+ AnalysisCache cache = caches[j];
CacheEntry entry = cache.get(dependentResult.target);
if (entry != null) {
entry._setErrorState(dependentResult.result, exception);
« no previous file with comments | « pkg/analyzer/lib/instrumentation/instrumentation.dart ('k') | pkg/analyzer/lib/src/context/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698