| 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 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 static final Uri DART_FOREIGN_HELPER = | 501 static final Uri DART_FOREIGN_HELPER = |
| 502 new Uri(scheme: 'dart', path: '_foreign_helper'); | 502 new Uri(scheme: 'dart', path: '_foreign_helper'); |
| 503 static final Uri DART_ISOLATE_HELPER = | 503 static final Uri DART_ISOLATE_HELPER = |
| 504 new Uri(scheme: 'dart', path: '_isolate_helper'); | 504 new Uri(scheme: 'dart', path: '_isolate_helper'); |
| 505 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); | 505 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); |
| 506 static final Uri DART_NATIVE_TYPED_DATA = | 506 static final Uri DART_NATIVE_TYPED_DATA = |
| 507 new Uri(scheme: 'dart', path: '_native_typed_data'); | 507 new Uri(scheme: 'dart', path: '_native_typed_data'); |
| 508 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); | 508 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); |
| 509 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); | 509 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); |
| 510 | 510 |
| 511 // TODO(johnniwinther): Move this to [LibraryLoaderTask] and hange to map from |
| 512 // [Uri] to [LibraryElement]. |
| 513 final Map<String, LibraryElement> libraries = |
| 514 new Map<String, LibraryElement>(); |
| 511 final Stopwatch totalCompileTime = new Stopwatch(); | 515 final Stopwatch totalCompileTime = new Stopwatch(); |
| 512 int nextFreeClassId = 0; | 516 int nextFreeClassId = 0; |
| 513 World world; | 517 World world; |
| 514 String assembledCode; | 518 String assembledCode; |
| 515 Types types; | 519 Types types; |
| 516 | 520 |
| 517 final CacheStrategy cacheStrategy; | 521 final CacheStrategy cacheStrategy; |
| 518 | 522 |
| 519 /** | 523 /** |
| 520 * Map from token to the first preceeding comment token. | 524 * Map from token to the first preceeding comment token. |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 | 1309 |
| 1306 // In order to see if a library is deferred, we must compute the | 1310 // In order to see if a library is deferred, we must compute the |
| 1307 // compile-time constants that are metadata. This means adding | 1311 // compile-time constants that are metadata. This means adding |
| 1308 // something to the resolution queue. So we cannot wait with | 1312 // something to the resolution queue. So we cannot wait with |
| 1309 // this until after the resolution queue is processed. | 1313 // this until after the resolution queue is processed. |
| 1310 deferredLoadTask.ensureMetadataResolved(this); | 1314 deferredLoadTask.ensureMetadataResolved(this); |
| 1311 } | 1315 } |
| 1312 | 1316 |
| 1313 phase = PHASE_RESOLVING; | 1317 phase = PHASE_RESOLVING; |
| 1314 if (analyzeAll) { | 1318 if (analyzeAll) { |
| 1315 libraryLoader.libraries.forEach((LibraryElement library) { | 1319 libraries.forEach((uri, lib) { |
| 1316 log('Enqueuing ${library.canonicalUri}'); | 1320 log('Enqueuing $uri'); |
| 1317 fullyEnqueueLibrary(library, enqueuer.resolution); | 1321 fullyEnqueueLibrary(lib, enqueuer.resolution); |
| 1318 }); | 1322 }); |
| 1319 } else if (analyzeMain && mainApp != null) { | 1323 } else if (analyzeMain && mainApp != null) { |
| 1320 fullyEnqueueLibrary(mainApp, enqueuer.resolution); | 1324 fullyEnqueueLibrary(mainApp, enqueuer.resolution); |
| 1321 } | 1325 } |
| 1322 // Elements required by enqueueHelpers are global dependencies | 1326 // Elements required by enqueueHelpers are global dependencies |
| 1323 // that are not pulled in by a particular element. | 1327 // that are not pulled in by a particular element. |
| 1324 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); | 1328 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); |
| 1325 resolveLibraryMetadata(); | 1329 resolveLibraryMetadata(); |
| 1326 log('Resolving...'); | 1330 log('Resolving...'); |
| 1327 processQueue(enqueuer.resolution, main); | 1331 processQueue(enqueuer.resolution, main); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 1381 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
| 1378 if (hasIsolateSupport()) { | 1382 if (hasIsolateSupport()) { |
| 1379 enqueuer.codegen.addToWorkList( | 1383 enqueuer.codegen.addToWorkList( |
| 1380 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); | 1384 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); |
| 1381 enqueuer.codegen.registerGetOfStaticFunction(main); | 1385 enqueuer.codegen.registerGetOfStaticFunction(main); |
| 1382 } | 1386 } |
| 1383 if (enabledNoSuchMethod) { | 1387 if (enabledNoSuchMethod) { |
| 1384 backend.enableNoSuchMethod(enqueuer.codegen); | 1388 backend.enableNoSuchMethod(enqueuer.codegen); |
| 1385 } | 1389 } |
| 1386 if (compileAll) { | 1390 if (compileAll) { |
| 1387 libraryLoader.libraries.forEach((LibraryElement library) { | 1391 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib, |
| 1388 fullyEnqueueLibrary(library, enqueuer.codegen); | 1392 enqueuer.codegen)); |
| 1389 }); | |
| 1390 } | 1393 } |
| 1391 processQueue(enqueuer.codegen, main); | 1394 processQueue(enqueuer.codegen, main); |
| 1392 enqueuer.codegen.logSummary(log); | 1395 enqueuer.codegen.logSummary(log); |
| 1393 | 1396 |
| 1394 if (compilationFailed) return; | 1397 if (compilationFailed) return; |
| 1395 | 1398 |
| 1396 backend.assembleProgram(); | 1399 backend.assembleProgram(); |
| 1397 | 1400 |
| 1398 if (dumpInfo) { | 1401 if (dumpInfo) { |
| 1399 dumpInfoTask.dumpInfo(); | 1402 dumpInfoTask.dumpInfo(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1421 world.registerInstantiatedClass(element, globalDependencies); | 1424 world.registerInstantiatedClass(element, globalDependencies); |
| 1422 } else { | 1425 } else { |
| 1423 world.addToWorkList(element); | 1426 world.addToWorkList(element); |
| 1424 } | 1427 } |
| 1425 } | 1428 } |
| 1426 | 1429 |
| 1427 // Resolves metadata on library elements. This is necessary in order to | 1430 // Resolves metadata on library elements. This is necessary in order to |
| 1428 // resolve metadata classes referenced only from metadata on library tags. | 1431 // resolve metadata classes referenced only from metadata on library tags. |
| 1429 // TODO(ahe): Figure out how to do this lazily. | 1432 // TODO(ahe): Figure out how to do this lazily. |
| 1430 void resolveLibraryMetadata() { | 1433 void resolveLibraryMetadata() { |
| 1431 for (LibraryElement library in libraryLoader.libraries) { | 1434 for (LibraryElement library in libraries.values) { |
| 1432 if (library.metadata != null) { | 1435 if (library.metadata != null) { |
| 1433 for (MetadataAnnotation metadata in library.metadata) { | 1436 for (MetadataAnnotation metadata in library.metadata) { |
| 1434 metadata.ensureResolved(this); | 1437 metadata.ensureResolved(this); |
| 1435 } | 1438 } |
| 1436 } | 1439 } |
| 1437 } | 1440 } |
| 1438 } | 1441 } |
| 1439 | 1442 |
| 1440 void processQueue(Enqueuer world, Element main) { | 1443 void processQueue(Enqueuer world, Element main) { |
| 1441 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); | 1444 world.nativeEnqueuer.processNativeClasses(libraries.values); |
| 1442 if (main != null) { | 1445 if (main != null) { |
| 1443 FunctionElement mainMethod = main; | 1446 FunctionElement mainMethod = main; |
| 1444 if (mainMethod.computeSignature(this).parameterCount != 0) { | 1447 if (mainMethod.computeSignature(this).parameterCount != 0) { |
| 1445 // TODO(ngeoffray, floitsch): we should also ensure that the | 1448 // TODO(ngeoffray, floitsch): we should also ensure that the |
| 1446 // class IsolateMessage is instantiated. Currently, just enabling | 1449 // class IsolateMessage is instantiated. Currently, just enabling |
| 1447 // isolate support works. | 1450 // isolate support works. |
| 1448 world.enableIsolateSupport(main.library); | 1451 world.enableIsolateSupport(main.library); |
| 1449 world.registerInstantiatedClass(listClass, globalDependencies); | 1452 world.registerInstantiatedClass(listClass, globalDependencies); |
| 1450 world.registerInstantiatedClass(stringClass, globalDependencies); | 1453 world.registerInstantiatedClass(stringClass, globalDependencies); |
| 1451 } | 1454 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 } else { | 1792 } else { |
| 1790 member.forEachLocalMember(checkLive); | 1793 member.forEachLocalMember(checkLive); |
| 1791 } | 1794 } |
| 1792 } else if (member.isTypedef) { | 1795 } else if (member.isTypedef) { |
| 1793 if (!member.isResolved) { | 1796 if (!member.isResolved) { |
| 1794 reportHint(member, MessageKind.UNUSED_TYPEDEF, | 1797 reportHint(member, MessageKind.UNUSED_TYPEDEF, |
| 1795 {'name': member.name}); | 1798 {'name': member.name}); |
| 1796 } | 1799 } |
| 1797 } | 1800 } |
| 1798 } | 1801 } |
| 1799 libraryLoader.libraries.forEach((LibraryElement library) { | 1802 libraries.forEach((_, library) { |
| 1800 // TODO(ahe): Implement better heuristics to discover entry points of | 1803 // TODO(ahe): Implement better heuristics to discover entry points of |
| 1801 // packages and use that to discover unused implementation details in | 1804 // packages and use that to discover unused implementation details in |
| 1802 // packages. | 1805 // packages. |
| 1803 if (library.isPlatformLibrary || library.isPackageLibrary) return; | 1806 if (library.isPlatformLibrary || library.isPackageLibrary) return; |
| 1804 library.compilationUnits.forEach((unit) { | 1807 library.compilationUnits.forEach((unit) { |
| 1805 unit.forEachLocalMember(checkLive); | 1808 unit.forEachLocalMember(checkLive); |
| 1806 }); | 1809 }); |
| 1807 }); | 1810 }); |
| 1808 } | 1811 } |
| 1809 | 1812 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 static NullSink outputProvider(String name, String extension) { | 2019 static NullSink outputProvider(String name, String extension) { |
| 2017 return new NullSink('$name.$extension'); | 2020 return new NullSink('$name.$extension'); |
| 2018 } | 2021 } |
| 2019 } | 2022 } |
| 2020 | 2023 |
| 2021 /// Information about suppressed warnings and hints for a given library. | 2024 /// Information about suppressed warnings and hints for a given library. |
| 2022 class SuppressionInfo { | 2025 class SuppressionInfo { |
| 2023 int warnings = 0; | 2026 int warnings = 0; |
| 2024 int hints = 0; | 2027 int hints = 0; |
| 2025 } | 2028 } |
| OLD | NEW |