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

Side by Side Diff: pkg/analyzer/lib/task/model.dart

Issue 1383043002: Stop defensively copying AST structures before resolution (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/model.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.task.model; 5 library analyzer.task.model;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:developer';
8 9
9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
10 import 'package:analyzer/src/generated/error.dart' show AnalysisError; 11 import 'package:analyzer/src/generated/error.dart' show AnalysisError;
11 import 'package:analyzer/src/generated/java_engine.dart'; 12 import 'package:analyzer/src/generated/java_engine.dart';
12 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
13 import 'package:analyzer/src/generated/utilities_general.dart'; 14 import 'package:analyzer/src/generated/utilities_general.dart';
14 import 'package:analyzer/src/task/driver.dart'; 15 import 'package:analyzer/src/task/driver.dart';
15 import 'package:analyzer/src/task/model.dart'; 16 import 'package:analyzer/src/task/model.dart';
16 17
17 /** 18 /**
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 * Clients are expected to extend this class when creating new tasks. 78 * Clients are expected to extend this class when creating new tasks.
78 */ 79 */
79 abstract class AnalysisTask { 80 abstract class AnalysisTask {
80 /** 81 /**
81 * A table mapping the types of analysis tasks to the number of times each 82 * A table mapping the types of analysis tasks to the number of times each
82 * kind of task has been performed. 83 * kind of task has been performed.
83 */ 84 */
84 static final Map<Type, int> countMap = new HashMap<Type, int>(); 85 static final Map<Type, int> countMap = new HashMap<Type, int>();
85 86
86 /** 87 /**
88 * A table mapping the types of analysis tasks to user tags used to collect
89 * timing data for the Observatory.
90 */
91 static Map<Type, UserTag> tagMap = new HashMap<Type, UserTag>();
92
93 /**
87 * A table mapping the types of analysis tasks to stopwatches used to compute 94 * A table mapping the types of analysis tasks to stopwatches used to compute
88 * how much time was spent executing each kind of task. 95 * how much time was spent executing each kind of task.
89 */ 96 */
90 static final Map<Type, Stopwatch> stopwatchMap = 97 static final Map<Type, Stopwatch> stopwatchMap =
91 new HashMap<Type, Stopwatch>(); 98 new HashMap<Type, Stopwatch>();
92 99
93 /** 100 /**
94 * The context in which the task is to be performed. 101 * The context in which the task is to be performed.
95 */ 102 */
96 final AnalysisContext context; 103 final AnalysisContext context;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (contextName == null) { 228 if (contextName == null) {
222 contextName = 'unnamed'; 229 contextName = 'unnamed';
223 } 230 }
224 AnalysisEngine.instance.instrumentationService 231 AnalysisEngine.instance.instrumentationService
225 .logAnalysisTask(contextName, this); 232 .logAnalysisTask(contextName, this);
226 // 233 //
227 // Gather statistics on the performance of the task. 234 // Gather statistics on the performance of the task.
228 // 235 //
229 int count = countMap[runtimeType]; 236 int count = countMap[runtimeType];
230 countMap[runtimeType] = count == null ? 1 : count + 1; 237 countMap[runtimeType] = count == null ? 1 : count + 1;
238 // UserTag tag = tagMap.putIfAbsent(
239 // runtimeType, () => new UserTag(runtimeType.toString()));
231 Stopwatch stopwatch = stopwatchMap[runtimeType]; 240 Stopwatch stopwatch = stopwatchMap[runtimeType];
232 if (stopwatch == null) { 241 if (stopwatch == null) {
233 stopwatch = new Stopwatch(); 242 stopwatch = new Stopwatch();
234 stopwatchMap[runtimeType] = stopwatch; 243 stopwatchMap[runtimeType] = stopwatch;
235 } 244 }
245 // UserTag previousTag = tag.makeCurrent();
246 // try {
236 stopwatch.start(); 247 stopwatch.start();
237 // 248 //
238 // Actually perform the task. 249 // Actually perform the task.
239 // 250 //
240 try { 251 try {
241 if (dependencyCycle != null && !handlesDependencyCycles) { 252 if (dependencyCycle != null && !handlesDependencyCycles) {
242 throw new InfiniteTaskLoopException(this, dependencyCycle); 253 throw new InfiniteTaskLoopException(this, dependencyCycle);
243 } 254 }
244 internalPerform(); 255 internalPerform();
245 } finally { 256 } finally {
246 stopwatch.stop(); 257 stopwatch.stop();
247 } 258 }
259 // } finally {
260 // previousTag.makeCurrent();
261 // }
248 } on AnalysisException { 262 } on AnalysisException {
249 rethrow; 263 rethrow;
250 } catch (exception, stackTrace) { 264 } catch (exception, stackTrace) {
251 throw new AnalysisException( 265 throw new AnalysisException(
252 'Unexpected exception while performing $description', 266 'Unexpected exception while performing $description',
253 new CaughtException(exception, stackTrace)); 267 new CaughtException(exception, stackTrace));
254 } 268 }
255 } 269 }
256 } 270 }
257 271
258 /** 272 /**
259 * A description of a [List]-based analysis result that can be computed by an 273 * A description of a [List]-based analysis result that can be computed by an
260 * [AnalysisTask]. 274 * [AnalysisTask].
261 * 275 *
262 * Clients are not expected to subtype this class. 276 * Clients are not expected to subtype this class.
263 */ 277 */
264 abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> { 278 abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> {
265 /** 279 /**
266 * Initialize a newly created analysis result to have the given [name] and 280 * Initialize a newly created analysis result to have the given [name] and
267 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long 281 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long
268 * values associated with this result will remain in the cache. 282 * values associated with this result will remain in the cache.
269 */ 283 */
270 factory ListResultDescriptor(String name, List<E> defaultValue, 284 factory ListResultDescriptor(String name, List<E> defaultValue,
271 {ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl< 285 {ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl<
272 E>; 286 E>;
273 287
274 @override 288 @override
275 ListTaskInput<E> of(AnalysisTarget target); 289 ListTaskInput<E> of(AnalysisTarget target, {bool flushOnAccess: false});
276 } 290 }
277 291
278 /** 292 /**
279 * A description of an input to an [AnalysisTask] that can be used to compute 293 * A description of an input to an [AnalysisTask] that can be used to compute
280 * that input. 294 * that input.
281 * 295 *
282 * Clients are not expected to subtype this class. 296 * Clients are not expected to subtype this class.
283 */ 297 */
284 abstract class ListTaskInput<E> extends TaskInput<List<E>> { 298 abstract class ListTaskInput<E> extends TaskInput<List<E>> {
285 /** 299 /**
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 */ 394 */
381 V get defaultValue; 395 V get defaultValue;
382 396
383 /** 397 /**
384 * Return the name of this descriptor. 398 * Return the name of this descriptor.
385 */ 399 */
386 String get name; 400 String get name;
387 401
388 /** 402 /**
389 * Return a task input that can be used to compute this result for the given 403 * Return a task input that can be used to compute this result for the given
390 * [target]. 404 * [target]. If [flushOnAccess] is `true` then the value of this result that
405 * is associated with the [target] will be flushed when it is accessed.
391 */ 406 */
392 TaskInput<V> of(AnalysisTarget target); 407 TaskInput<V> of(AnalysisTarget target, {bool flushOnAccess: false});
393 } 408 }
394 409
395 /** 410 /**
396 * A specification of the given [result] for the given [target]. 411 * A specification of the given [result] for the given [target].
397 * 412 *
398 * Clients are not expected to subtype this class. 413 * Clients are not expected to subtype this class.
399 */ 414 */
400 class TargetedResult { 415 class TargetedResult {
401 /** 416 /**
402 * An empty list of results. 417 * An empty list of results.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 538
524 /** 539 /**
525 * Set the [value] that was computed for the current result. 540 * Set the [value] that was computed for the current result.
526 * 541 *
527 * Throws a [StateError] if [moveNext] has not been invoked or if the last 542 * Throws a [StateError] if [moveNext] has not been invoked or if the last
528 * invocation of [moveNext] returned `false`. 543 * invocation of [moveNext] returned `false`.
529 */ 544 */
530 void set currentValue(Object value); 545 void set currentValue(Object value);
531 546
532 /** 547 /**
548 * Return `true` if the value accessed by this input builder should be flushed
549 * from the cache at the time it is retrieved.
550 */
551 bool get flushOnAccess;
552
553 /**
533 * Return the [value] that was computed by this builder. 554 * Return the [value] that was computed by this builder.
534 * 555 *
535 * Throws a [StateError] if [moveNext] has not been invoked or if the last 556 * Throws a [StateError] if [moveNext] has not been invoked or if the last
536 * invocation of [moveNext] returned `true`. 557 * invocation of [moveNext] returned `true`.
537 * 558 *
538 * Returns `null` if no value could be computed due to a circular dependency. 559 * Returns `null` if no value could be computed due to a circular dependency.
539 */ 560 */
540 V get inputValue; 561 V get inputValue;
541 562
542 /** 563 /**
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 /** 667 /**
647 * A work should be done, but without any special urgency. 668 * A work should be done, but without any special urgency.
648 */ 669 */
649 NORMAL, 670 NORMAL,
650 671
651 /** 672 /**
652 * Nothing to do. 673 * Nothing to do.
653 */ 674 */
654 NONE 675 NONE
655 } 676 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/model.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698