| OLD | NEW |
| 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 library dart2js.library_loader; | 5 library dart2js.library_loader; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'common/names.dart' show Uris; | 9 import 'common/names.dart' show Uris; |
| 10 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 if (reusedLibraries != null) { | 338 if (reusedLibraries != null) { |
| 339 reusedLibraries.forEach(mapLibrary); | 339 reusedLibraries.forEach(mapLibrary); |
| 340 } | 340 } |
| 341 }); | 341 }); |
| 342 } | 342 } |
| 343 | 343 |
| 344 Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)) { | 344 Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)) { |
| 345 return measure(() { | 345 return measure(() { |
| 346 assert(currentHandler == null); | 346 assert(currentHandler == null); |
| 347 | 347 |
| 348 wrapper(lib) => reuseLibrary(lib).then((reuse) => reuse ? lib : null); | 348 Future<LibraryElement> wrapper(LibraryElement library) { |
| 349 try { |
| 350 return reuseLibrary(library) |
| 351 .then((bool reuse) => reuse ? library : null); |
| 352 } catch (exception, trace) { |
| 353 reporter.onCrashInUserCode( |
| 354 'Uncaught exception in reuseLibrary', exception, trace); |
| 355 rethrow; |
| 356 } |
| 357 } |
| 358 |
| 349 List<Future<LibraryElement>> reusedLibrariesFuture = | 359 List<Future<LibraryElement>> reusedLibrariesFuture = |
| 350 // TODO(sigmund): make measurements separate from compiler | 360 // TODO(sigmund): make measurements separate from compiler |
| 351 compiler.reuseLibraryTask.measure( | 361 compiler.reuseLibraryTask.measure( |
| 352 () => libraryCanonicalUriMap.values.map(wrapper).toList()); | 362 () => libraryCanonicalUriMap.values.map(wrapper).toList()); |
| 353 | 363 |
| 354 return Future | 364 return Future |
| 355 .wait(reusedLibrariesFuture) | 365 .wait(reusedLibrariesFuture) |
| 356 .then((List<LibraryElement> reusedLibraries) { | 366 .then((List<LibraryElement> reusedLibraries) { |
| 357 resetImplementation(reusedLibraries.where((e) => e != null)); | 367 resetImplementation(reusedLibraries.where((e) => e != null)); |
| 358 }); | 368 }); |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 /// Called after a request to load a library. The [results] will include all | 1474 /// Called after a request to load a library. The [results] will include all |
| 1465 /// transitive libraries loaded as a result of the initial request. | 1475 /// transitive libraries loaded as a result of the initial request. |
| 1466 Future onLibrariesLoaded(LoadedLibraries results); | 1476 Future onLibrariesLoaded(LoadedLibraries results); |
| 1467 | 1477 |
| 1468 /// Called whenever a library element is created. | 1478 /// Called whenever a library element is created. |
| 1469 void onLibraryCreated(LibraryElement library); | 1479 void onLibraryCreated(LibraryElement library); |
| 1470 | 1480 |
| 1471 /// Called whenever a library is scanned from a script file. | 1481 /// Called whenever a library is scanned from a script file. |
| 1472 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); | 1482 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); |
| 1473 } | 1483 } |
| OLD | NEW |