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

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

Issue 1204373002: Initial version of limiting invalidation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 5 years, 6 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 | « no previous file | pkg/analyzer/lib/src/context/context.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 0b93d03743b899c6b99864b1119d9b8443f2ab73..662e350532e63cc365deef3ba738922113b38fff 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -412,7 +412,7 @@ class CacheEntry {
* Set the state of the result represented by the given [descriptor] to the
* given [state].
*/
- void setState(ResultDescriptor descriptor, CacheState state) {
+ void setState(ResultDescriptor descriptor, CacheState state, {Delta delta}) {
if (state == CacheState.ERROR) {
throw new ArgumentError('use setErrorState() to set the state to ERROR');
}
@@ -423,7 +423,7 @@ class CacheEntry {
if (state == CacheState.INVALID) {
ResultData data = _resultMap[descriptor];
if (data != null) {
- _invalidate(descriptor);
+ _invalidate(descriptor, delta);
}
} else {
ResultData data = getResultData(descriptor);
@@ -471,7 +471,7 @@ class CacheEntry {
void setValueIncremental(ResultDescriptor descriptor, dynamic value) {
ResultData data = getResultData(descriptor);
List<TargetedResult> dependedOn = data.dependedOnResults;
- _invalidate(descriptor);
+ _invalidate(descriptor, null);
setValue(descriptor, value, dependedOn);
}
@@ -491,7 +491,12 @@ class CacheEntry {
* Invalidate the result represented by the given [descriptor] and propagate
* invalidation to other results that depend on it.
*/
- void _invalidate(ResultDescriptor descriptor) {
+ void _invalidate(ResultDescriptor descriptor, Delta delta) {
+ if (delta != null &&
+ !delta.affects(_partition.context, target, descriptor)) {
+// print('not-invalidate $descriptor for $target');
+ return;
+ }
// print('invalidate $descriptor for $target');
ResultData thisData = _resultMap.remove(descriptor);
if (thisData == null) {
@@ -511,7 +516,7 @@ class CacheEntry {
dependentResults.forEach((TargetedResult dependentResult) {
CacheEntry entry = _partition.get(dependentResult.target);
if (entry != null) {
- entry._invalidate(dependentResult.result);
+ entry._invalidate(dependentResult.result, delta);
}
});
// If empty, remove the entry altogether.
@@ -530,7 +535,7 @@ class CacheEntry {
void _invalidateAll() {
List<ResultDescriptor> results = _resultMap.keys.toList();
for (ResultDescriptor result in results) {
- _invalidate(result);
+ _invalidate(result, null);
}
}
@@ -960,6 +965,24 @@ abstract class CachePartition {
}
/**
+ * The description for a change.
+ */
+class Delta {
+ final Source source;
+
+ Delta(this.source);
+
+ /**
+ * Check whether this delta affects the result described by the given
+ * [descriptor] and [target].
+ */
+ bool affects(InternalAnalysisContext context, AnalysisTarget target,
+ ResultDescriptor descriptor) {
+ return true;
+ }
+}
+
+/**
* [InvalidatedResult] describes an invalidated result.
*/
class InvalidatedResult {
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698