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

Side by Side Diff: lib/compiler/implementation/compiler.dart

Issue 11304021: Add NativeEnqueuer to work with the Enqueuer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : this.constantSystem = constantSystem; 67 : this.constantSystem = constantSystem;
68 68
69 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { 69 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) {
70 lib.forEachExport((Element e) { 70 lib.forEachExport((Element e) {
71 if (e.isFunction()) world.addToWorkList(e); 71 if (e.isFunction()) world.addToWorkList(e);
72 }); 72 });
73 } 73 }
74 74
75 abstract void enqueueHelpers(Enqueuer world); 75 abstract void enqueueHelpers(Enqueuer world);
76 abstract void codegen(WorkItem work); 76 abstract void codegen(WorkItem work);
77 abstract void processNativeClasses(Enqueuer world, 77
78 Collection<LibraryElement> libraries); 78 // The backend determines the native resolution enqueuer so tools like
79 // dart2dart can ignore the native classes.
80 abstract NativeEnqueuer nativeResolutionEnqueuer(world);
81 abstract NativeEnqueuer nativeCodegenEnqueuer(world);
82
79 abstract void assembleProgram(); 83 abstract void assembleProgram();
80 abstract List<CompilerTask> get tasks; 84 abstract List<CompilerTask> get tasks;
81 85
82 // TODO(ahe,karlklose): rename this? 86 // TODO(ahe,karlklose): rename this?
83 void dumpInferredTypes() {} 87 void dumpInferredTypes() {}
84 88
85 ItemCompilationContext createItemCompilationContext() { 89 ItemCompilationContext createItemCompilationContext() {
86 return new ItemCompilationContext(); 90 return new ItemCompilationContext();
87 } 91 }
88 92
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 reportFatalError('Could not find $MAIN', mainApp); 481 reportFatalError('Could not find $MAIN', mainApp);
478 } else { 482 } else {
479 if (!main.isFunction()) reportFatalError('main is not a function', main); 483 if (!main.isFunction()) reportFatalError('main is not a function', main);
480 FunctionElement mainMethod = main; 484 FunctionElement mainMethod = main;
481 FunctionSignature parameters = mainMethod.computeSignature(this); 485 FunctionSignature parameters = mainMethod.computeSignature(this);
482 parameters.forEachParameter((Element parameter) { 486 parameters.forEachParameter((Element parameter) {
483 reportFatalError('main cannot have parameters', parameter); 487 reportFatalError('main cannot have parameters', parameter);
484 }); 488 });
485 } 489 }
486 490
491 enqueuer.resolution.nativeEnqueuer =
492 backend.nativeResolutionEnqueuer(enqueuer.resolution);
493 enqueuer.codegen.nativeEnqueuer =
494 backend.nativeCodegenEnqueuer(enqueuer.codegen);
495
487 log('Resolving...'); 496 log('Resolving...');
488 phase = PHASE_RESOLVING; 497 phase = PHASE_RESOLVING;
489 backend.enqueueHelpers(enqueuer.resolution); 498 backend.enqueueHelpers(enqueuer.resolution);
490 processQueue(enqueuer.resolution, main); 499 processQueue(enqueuer.resolution, main);
491 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); 500 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
492 501
493 if (compilationFailed) return; 502 if (compilationFailed) return;
494 503
495 log('Inferring types...'); 504 log('Inferring types...');
496 typesTask.onResolutionComplete(main); 505 typesTask.onResolutionComplete(main);
497 506
498 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution 507 // TODO(ahe): Remove this line. Eventually, enqueuer.resolution
499 // should know this. 508 // should know this.
500 world.populate(); 509 world.populate();
501 510
502 log('Compiling...'); 511 log('Compiling...');
503 phase = PHASE_COMPILING; 512 phase = PHASE_COMPILING;
504 processQueue(enqueuer.codegen, main); 513 processQueue(enqueuer.codegen, main);
505 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 514 log('Compiled ${codegenWorld.generatedCode.length} methods.');
506 515
507 if (compilationFailed) return; 516 if (compilationFailed) return;
508 517
509 backend.assembleProgram(); 518 backend.assembleProgram();
510 519
511 checkQueues(); 520 checkQueues();
512 } 521 }
513 522
514 void processQueue(Enqueuer world, Element main) { 523 void processQueue(Enqueuer world, Element main) {
515 backend.processNativeClasses(world, libraries.values); 524 world.nativeEnqueuer.processNativeClasses(libraries.values);
516 world.addToWorkList(main); 525 world.addToWorkList(main);
517 progress.reset(); 526 progress.reset();
518 world.forEach((WorkItem work) { 527 world.forEach((WorkItem work) {
519 withCurrentElement(work.element, () => work.run(this, world)); 528 withCurrentElement(work.element, () => work.run(this, world));
520 }); 529 });
521 world.queueIsClosed = true; 530 world.queueIsClosed = true;
522 if (compilationFailed) return; 531 if (compilationFailed) return;
523 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 532 assert(world.checkNoEnqueuedInvokedInstanceMethods());
524 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) { 533 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) {
525 backend.dumpInferredTypes(); 534 backend.dumpInferredTypes();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // TODO(johnniwinther): Use [spannable] and [message] to provide better 871 // TODO(johnniwinther): Use [spannable] and [message] to provide better
863 // information on assertion errors. 872 // information on assertion errors.
864 if (condition is Function){ 873 if (condition is Function){
865 condition = condition(); 874 condition = condition();
866 } 875 }
867 if (!condition && message != null) { 876 if (!condition && message != null) {
868 print('assertion failed: $message'); 877 print('assertion failed: $message');
869 } 878 }
870 return spannable != null && condition; 879 return spannable != null && condition;
871 } 880 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/backend.dart » ('j') | lib/compiler/implementation/native_handler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698