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

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

Issue 12033003: Deferred (aka lazy) loading of static functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 /** 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ClassElement boolClass; 227 ClassElement boolClass;
228 ClassElement numClass; 228 ClassElement numClass;
229 ClassElement intClass; 229 ClassElement intClass;
230 ClassElement doubleClass; 230 ClassElement doubleClass;
231 ClassElement stringClass; 231 ClassElement stringClass;
232 ClassElement functionClass; 232 ClassElement functionClass;
233 ClassElement nullClass; 233 ClassElement nullClass;
234 ClassElement listClass; 234 ClassElement listClass;
235 ClassElement typeClass; 235 ClassElement typeClass;
236 ClassElement mapClass; 236 ClassElement mapClass;
237 ClassElement deferLoadClass;
238 ClassElement onLibraryLoadedClass;
239
237 ClassElement jsInvocationMirrorClass; 240 ClassElement jsInvocationMirrorClass;
238 /// Document class from dart:mirrors. 241 /// Document class from dart:mirrors.
239 ClassElement documentClass; 242 ClassElement documentClass;
240 Element assertMethod; 243 Element assertMethod;
241 Element identicalFunction; 244 Element identicalFunction;
242 Element functionApplyMethod; 245 Element functionApplyMethod;
243 Element invokeOnMethod; 246 Element invokeOnMethod;
244 Element createInvocationMirrorElement; 247 Element createInvocationMirrorElement;
245 248
246 Element get currentElement => _currentElement; 249 Element get currentElement => _currentElement;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 TreeValidatorTask validator; 287 TreeValidatorTask validator;
285 ResolverTask resolver; 288 ResolverTask resolver;
286 closureMapping.ClosureTask closureToClassMapper; 289 closureMapping.ClosureTask closureToClassMapper;
287 TypeCheckerTask checker; 290 TypeCheckerTask checker;
288 ti.TypesTask typesTask; 291 ti.TypesTask typesTask;
289 Backend backend; 292 Backend backend;
290 ConstantHandler constantHandler; 293 ConstantHandler constantHandler;
291 ConstantHandler metadataHandler; 294 ConstantHandler metadataHandler;
292 EnqueueTask enqueuer; 295 EnqueueTask enqueuer;
293 CompilerTask fileReadingTask; 296 CompilerTask fileReadingTask;
297 DeferredLoadTask deferredLoadTask;
294 298
295 static const SourceString MAIN = const SourceString('main'); 299 static const SourceString MAIN = const SourceString('main');
296 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); 300 static const SourceString CALL_OPERATOR_NAME = const SourceString('call');
297 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); 301 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod');
298 static const int NO_SUCH_METHOD_ARG_COUNT = 1; 302 static const int NO_SUCH_METHOD_ARG_COUNT = 1;
299 static const SourceString CREATE_INVOCATION_MIRROR = 303 static const SourceString CREATE_INVOCATION_MIRROR =
300 const SourceString('createInvocationMirror'); 304 const SourceString('createInvocationMirror');
301 static const SourceString INVOKE_ON = const SourceString('invokeOn'); 305 static const SourceString INVOKE_ON = const SourceString('invokeOn');
302 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); 306 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType');
303 static const SourceString START_ROOT_ISOLATE = 307 static const SourceString START_ROOT_ISOLATE =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 libraryLoader = new LibraryLoaderTask(this), 366 libraryLoader = new LibraryLoaderTask(this),
363 scanner = new ScannerTask(this), 367 scanner = new ScannerTask(this),
364 dietParser = new DietParserTask(this), 368 dietParser = new DietParserTask(this),
365 parser = new ParserTask(this), 369 parser = new ParserTask(this),
366 patchParser = new PatchParserTask(this), 370 patchParser = new PatchParserTask(this),
367 resolver = new ResolverTask(this), 371 resolver = new ResolverTask(this),
368 closureToClassMapper = new closureMapping.ClosureTask(this, closureNamer), 372 closureToClassMapper = new closureMapping.ClosureTask(this, closureNamer),
369 checker = new TypeCheckerTask(this), 373 checker = new TypeCheckerTask(this),
370 typesTask = new ti.TypesTask(this), 374 typesTask = new ti.TypesTask(this),
371 constantHandler = new ConstantHandler(this, backend.constantSystem), 375 constantHandler = new ConstantHandler(this, backend.constantSystem),
376 deferredLoadTask = new DeferredLoadTask(this),
372 enqueuer = new EnqueueTask(this)]; 377 enqueuer = new EnqueueTask(this)];
373 378
374 tasks.addAll(backend.tasks); 379 tasks.addAll(backend.tasks);
375 metadataHandler = new ConstantHandler( 380 metadataHandler = new ConstantHandler(
376 this, backend.constantSystem, isMetadata: true); 381 this, backend.constantSystem, isMetadata: true);
377 } 382 }
378 383
379 ResolutionUniverse get resolverWorld => enqueuer.resolution.universe; 384 ResolutionUniverse get resolverWorld => enqueuer.resolution.universe;
380 CodegenUniverse get codegenWorld => enqueuer.codegen.universe; 385 CodegenUniverse get codegenWorld => enqueuer.codegen.universe;
381 386
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 node = currentElement; 448 node = currentElement;
444 } 449 }
445 if (node is Node) { 450 if (node is Node) {
446 return spanFromNode(node, uri); 451 return spanFromNode(node, uri);
447 } else if (node is Token) { 452 } else if (node is Token) {
448 return spanFromTokens(node, node, uri); 453 return spanFromTokens(node, node, uri);
449 } else if (node is HInstruction) { 454 } else if (node is HInstruction) {
450 return spanFromHInstruction(node); 455 return spanFromHInstruction(node);
451 } else if (node is Element) { 456 } else if (node is Element) {
452 return spanFromElement(node); 457 return spanFromElement(node);
458 } else if (node is MetadataAnnotation) {
459 return spanFromTokens(node.beginToken, node.beginToken);
453 } else { 460 } else {
454 throw 'No error location.'; 461 throw 'No error location.';
455 } 462 }
456 } 463 }
457 464
458 void reportFatalError(String reason, Element element, 465 void reportFatalError(String reason, Element element,
459 {Node node, Token token, HInstruction instruction}) { 466 {Node node, Token token, HInstruction instruction}) {
460 withCurrentElement(element, () { 467 withCurrentElement(element, () {
461 cancel(reason, node: node, token: token, instruction: instruction, 468 cancel(reason, node: node, token: token, instruction: instruction,
462 element: element); 469 element: element);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 withCurrentElement(dynamicClass, () { 502 withCurrentElement(dynamicClass, () {
496 library.addToScope(dynamicClass, this); 503 library.addToScope(dynamicClass, this);
497 }); 504 });
498 } 505 }
499 } 506 }
500 507
501 LibraryElement scanBuiltinLibrary(String filename); 508 LibraryElement scanBuiltinLibrary(String filename);
502 509
503 void initializeSpecialClasses() { 510 void initializeSpecialClasses() {
504 final List missingCoreClasses = []; 511 final List missingCoreClasses = [];
505 ClassElement lookupCoreClass(SourceString name) { 512 ClassElement lookupCoreClass(String name) {
506 ClassElement result = coreLibrary.find(name); 513 ClassElement result = coreLibrary.find(new SourceString(name));
507 if (result == null) { 514 if (result == null) {
508 missingCoreClasses.add(name.slowToString()); 515 missingCoreClasses.add(name);
509 } 516 }
510 return result; 517 return result;
511 } 518 }
512 objectClass = lookupCoreClass(const SourceString('Object')); 519 objectClass = lookupCoreClass('Object');
513 boolClass = lookupCoreClass(const SourceString('bool')); 520 boolClass = lookupCoreClass('bool');
514 numClass = lookupCoreClass(const SourceString('num')); 521 numClass = lookupCoreClass('num');
515 intClass = lookupCoreClass(const SourceString('int')); 522 intClass = lookupCoreClass('int');
516 doubleClass = lookupCoreClass(const SourceString('double')); 523 doubleClass = lookupCoreClass('double');
517 stringClass = lookupCoreClass(const SourceString('String')); 524 stringClass = lookupCoreClass('String');
518 functionClass = lookupCoreClass(const SourceString('Function')); 525 functionClass = lookupCoreClass('Function');
519 listClass = lookupCoreClass(const SourceString('List')); 526 listClass = lookupCoreClass('List');
520 typeClass = lookupCoreClass(const SourceString('Type')); 527 typeClass = lookupCoreClass('Type');
521 mapClass = lookupCoreClass(const SourceString('Map')); 528 mapClass = lookupCoreClass('Map');
529 deferLoadClass = lookupCoreClass('DeferLoad');
530 onLibraryLoadedClass = lookupCoreClass('OnLibraryLoaded');
522 if (!missingCoreClasses.isEmpty) { 531 if (!missingCoreClasses.isEmpty) {
523 internalErrorOnElement(coreLibrary, 532 internalErrorOnElement(coreLibrary,
524 'dart:core library does not contain required classes: ' 533 'dart:core library does not contain required classes: '
525 '$missingCoreClasses'); 534 '$missingCoreClasses');
526 } 535 }
527 536
528 final List missingHelperClasses = []; 537 final List missingHelperClasses = [];
529 ClassElement lookupHelperClass(SourceString name) { 538 ClassElement lookupHelperClass(String name) {
530 ClassElement result = jsHelperLibrary.find(name); 539 ClassElement result = jsHelperLibrary.find(new SourceString(name));
531 if (result == null) { 540 if (result == null) {
532 missingHelperClasses.add(name.slowToString()); 541 missingHelperClasses.add(name);
533 } 542 }
534 return result; 543 return result;
535 } 544 }
536 jsInvocationMirrorClass = 545 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror');
537 lookupHelperClass(const SourceString('JSInvocationMirror')); 546 closureClass = lookupHelperClass('Closure');
538 closureClass = lookupHelperClass(const SourceString('Closure')); 547 dynamicClass = lookupHelperClass('Dynamic_');
539 dynamicClass = lookupHelperClass(const SourceString('Dynamic_')); 548 nullClass = lookupHelperClass('Null');
540 nullClass = lookupHelperClass(const SourceString('Null'));
541 if (!missingHelperClasses.isEmpty) { 549 if (!missingHelperClasses.isEmpty) {
542 internalErrorOnElement(jsHelperLibrary, 550 internalErrorOnElement(jsHelperLibrary,
543 'dart:_js_helper library does not contain required classes: ' 551 'dart:_js_helper library does not contain required classes: '
544 '$missingHelperClasses'); 552 '$missingHelperClasses');
545 } 553 }
546 554
547 types = new Types(this, dynamicClass); 555 types = new Types(this, dynamicClass);
548 } 556 }
549 557
550 void scanBuiltinLibraries() { 558 void scanBuiltinLibraries() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 reportFatalError('main is not a function', main); 635 reportFatalError('main is not a function', main);
628 } 636 }
629 FunctionElement mainMethod = main; 637 FunctionElement mainMethod = main;
630 FunctionSignature parameters = mainMethod.computeSignature(this); 638 FunctionSignature parameters = mainMethod.computeSignature(this);
631 parameters.forEachParameter((Element parameter) { 639 parameters.forEachParameter((Element parameter) {
632 reportFatalError('main cannot have parameters', parameter); 640 reportFatalError('main cannot have parameters', parameter);
633 }); 641 });
634 } 642 }
635 } 643 }
636 644
645 deferredLoadTask.registerMainApp(mainApp);
646
637 log('Resolving...'); 647 log('Resolving...');
638 phase = PHASE_RESOLVING; 648 phase = PHASE_RESOLVING;
639 if (analyzeAll) { 649 if (analyzeAll) {
640 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib)); 650 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib));
641 } 651 }
642 backend.enqueueHelpers(enqueuer.resolution); 652 backend.enqueueHelpers(enqueuer.resolution);
643 processQueue(enqueuer.resolution, main); 653 processQueue(enqueuer.resolution, main);
644 enqueuer.resolution.logSummary(log); 654 enqueuer.resolution.logSummary(log);
645 655
646 if (compilationFailed) return; 656 if (compilationFailed) return;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1127
1118 void close() {} 1128 void close() {}
1119 1129
1120 toString() => name; 1130 toString() => name;
1121 1131
1122 /// Convenience method for getting an [api.CompilerOutputProvider]. 1132 /// Convenience method for getting an [api.CompilerOutputProvider].
1123 static NullSink outputProvider(String name, String extension) { 1133 static NullSink outputProvider(String name, String extension) {
1124 return new NullSink('$name.$extension'); 1134 return new NullSink('$name.$extension');
1125 } 1135 }
1126 } 1136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698