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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/enqueue.dart

Issue 13133006: Check for cyclic type variable bounds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased + pull in PostProcess code. Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart2js; 5 part of dart2js;
6 6
7 class EnqueueTask extends CompilerTask { 7 class EnqueueTask extends CompilerTask {
8 final ResolutionEnqueuer resolution; 8 final ResolutionEnqueuer resolution;
9 final CodegenEnqueuer codegen; 9 final CodegenEnqueuer codegen;
10 10
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 compiler.backend.registerIsCheck(type, this, elements); 386 compiler.backend.registerIsCheck(type, this, elements);
387 } 387 }
388 388
389 void registerAsCheck(DartType type, TreeElements elements) { 389 void registerAsCheck(DartType type, TreeElements elements) {
390 registerIsCheck(type, elements); 390 registerIsCheck(type, elements);
391 compiler.backend.registerAsCheck(type, elements); 391 compiler.backend.registerAsCheck(type, elements);
392 } 392 }
393 393
394 void forEach(f(WorkItem work)); 394 void forEach(f(WorkItem work));
395 395
396 void forEachPostProcessTask(f(PostProcessTask work)) {}
397
396 void logSummary(log(message)) { 398 void logSummary(log(message)) {
397 _logSpecificSummary(log); 399 _logSpecificSummary(log);
398 nativeEnqueuer.logSummary(log); 400 nativeEnqueuer.logSummary(log);
399 } 401 }
400 402
401 /// Log summary specific to the concrete enqueuer. 403 /// Log summary specific to the concrete enqueuer.
402 void _logSpecificSummary(log(message)); 404 void _logSpecificSummary(log(message));
403 405
404 String toString() => 'Enqueuer($name)'; 406 String toString() => 'Enqueuer($name)';
405 } 407 }
406 408
407 /// [Enqueuer] which is specific to resolution. 409 /// [Enqueuer] which is specific to resolution.
408 class ResolutionEnqueuer extends Enqueuer { 410 class ResolutionEnqueuer extends Enqueuer {
409 /** 411 /**
410 * Map from declaration elements to the [TreeElements] object holding the 412 * Map from declaration elements to the [TreeElements] object holding the
411 * resolution mapping for the element implementation. 413 * resolution mapping for the element implementation.
412 * 414 *
413 * Invariant: Key elements are declaration elements. 415 * Invariant: Key elements are declaration elements.
414 */ 416 */
415 final Map<Element, TreeElements> resolvedElements; 417 final Map<Element, TreeElements> resolvedElements;
416 418
417 final Queue<ResolutionWorkItem> queue; 419 final Queue<ResolutionWorkItem> queue;
418 420
421 /**
422 * A post-processing queue for the resolution phase which is processed
423 * immediately after the resolution queue has been closed.
424 */
425 final Queue<PostProcessTask> postQueue;
426
419 ResolutionEnqueuer(Compiler compiler, 427 ResolutionEnqueuer(Compiler compiler,
420 ItemCompilationContext itemCompilationContextCreator()) 428 ItemCompilationContext itemCompilationContextCreator())
421 : super('resolution enqueuer', compiler, itemCompilationContextCreator), 429 : super('resolution enqueuer', compiler, itemCompilationContextCreator),
422 resolvedElements = new Map<Element, TreeElements>(), 430 resolvedElements = new Map<Element, TreeElements>(),
423 queue = new Queue<ResolutionWorkItem>(); 431 queue = new Queue<ResolutionWorkItem>(),
432 postQueue = new Queue<PostProcessTask>();
424 433
425 bool get isResolutionQueue => true; 434 bool get isResolutionQueue => true;
426 435
427 bool isProcessed(Element member) => resolvedElements.containsKey(member); 436 bool isProcessed(Element member) => resolvedElements.containsKey(member);
428 437
429 TreeElements getCachedElements(Element element) { 438 TreeElements getCachedElements(Element element) {
430 // TODO(ngeoffray): Get rid of this check. 439 // TODO(ngeoffray): Get rid of this check.
431 if (element.enclosingElement.isClosure()) { 440 if (element.enclosingElement.isClosure()) {
432 closureMapping.ClosureClassElement cls = element.enclosingElement; 441 closureMapping.ClosureClassElement cls = element.enclosingElement;
433 element = cls.methodElement; 442 element = cls.methodElement;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 addToWorkList(compiler.createInvocationMirrorElement); 523 addToWorkList(compiler.createInvocationMirrorElement);
515 } 524 }
516 525
517 void forEach(f(WorkItem work)) { 526 void forEach(f(WorkItem work)) {
518 while (!queue.isEmpty) { 527 while (!queue.isEmpty) {
519 // TODO(johnniwinther): Find an optimal process order for resolution. 528 // TODO(johnniwinther): Find an optimal process order for resolution.
520 f(queue.removeLast()); 529 f(queue.removeLast());
521 } 530 }
522 } 531 }
523 532
533 /**
534 * Adds an action to the post-processing queue.
535 *
536 * The action is performed as part of the post-processing immediately after
537 * the resolution queue has been closed. As a consequence, [action] must not
538 * add elements to the resolution queue.
539 */
540 void addPostProcessAction(Element element, PostProcessAction action) {
541 if (queueIsClosed) {
542 throw new SpannableAssertionFailure(element,
543 "Resolution work list is closed.");
544 }
545 postQueue.add(new PostProcessTask(element, action));
546 }
547
548 void forEachPostProcessTask(f(PostProcessTask work)) {
549 while (!postQueue.isEmpty) {
550 f(postQueue.removeFirst());
551 }
552 }
553
524 void registerJsCall(Send node, ResolverVisitor resolver) { 554 void registerJsCall(Send node, ResolverVisitor resolver) {
525 nativeEnqueuer.registerJsCall(node, resolver); 555 nativeEnqueuer.registerJsCall(node, resolver);
526 } 556 }
527 557
528 void _logSpecificSummary(log(message)) { 558 void _logSpecificSummary(log(message)) {
529 log('Resolved ${resolvedElements.length} elements.'); 559 log('Resolved ${resolvedElements.length} elements.');
530 } 560 }
531 } 561 }
532 562
533 /// [Enqueuer] which is specific to code generation. 563 /// [Enqueuer] which is specific to code generation.
(...skipping 29 matching lines...) Expand all
563 while(!queue.isEmpty) { 593 while(!queue.isEmpty) {
564 // TODO(johnniwinther): Find an optimal process order for codegen. 594 // TODO(johnniwinther): Find an optimal process order for codegen.
565 f(queue.removeLast()); 595 f(queue.removeLast());
566 } 596 }
567 } 597 }
568 598
569 void _logSpecificSummary(log(message)) { 599 void _logSpecificSummary(log(message)) {
570 log('Compiled ${generatedCode.length} methods.'); 600 log('Compiled ${generatedCode.length} methods.');
571 } 601 }
572 } 602 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698