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

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

Issue 409473002: A bit of element model cleanup. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 5 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 js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 * be visible by reflection unless some other interfaces makes them 1828 * be visible by reflection unless some other interfaces makes them
1829 * accessible. 1829 * accessible.
1830 */ 1830 */
1831 computeMembersNeededForReflection() { 1831 computeMembersNeededForReflection() {
1832 if (_membersNeededForReflection != null) return; 1832 if (_membersNeededForReflection != null) return;
1833 if (compiler.mirrorsLibrary == null) { 1833 if (compiler.mirrorsLibrary == null) {
1834 _membersNeededForReflection = const []; 1834 _membersNeededForReflection = const [];
1835 } 1835 }
1836 // Compute a mapping from class to the closures it contains, so we 1836 // Compute a mapping from class to the closures it contains, so we
1837 // can include the correct ones when including the class. 1837 // can include the correct ones when including the class.
1838 Map<ClassElement, List<Element>> closureMap = 1838 Map<ClassElement, List<LocalFunctionElement>> closureMap =
1839 new Map<ClassElement, List<Element>>(); 1839 new Map<ClassElement, List<LocalFunctionElement>>();
1840 for (FunctionElement closure in compiler.resolverWorld.allClosures) { 1840 for (LocalFunctionElement closure in compiler.resolverWorld.allClosures) {
1841 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure); 1841 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure);
1842 } 1842 }
1843 bool foundClosure = false; 1843 bool foundClosure = false;
1844 Set<Element> reflectableMembers = new Set<Element>(); 1844 Set<Element> reflectableMembers = new Set<Element>();
1845 ResolutionEnqueuer resolution = compiler.enqueuer.resolution; 1845 ResolutionEnqueuer resolution = compiler.enqueuer.resolution;
1846 for (ClassElement cls in resolution.universe.instantiatedClasses) { 1846 for (ClassElement cls in resolution.universe.instantiatedClasses) {
1847 // Do not process internal classes. 1847 // Do not process internal classes.
1848 if (cls.library.isInternalLibrary || cls.isInjected) continue; 1848 if (cls.library.isInternalLibrary || cls.isInjected) continue;
1849 if (referencedFromMirrorSystem(cls)) { 1849 if (referencedFromMirrorSystem(cls)) {
1850 Set<Name> memberNames = new Set<Name>(); 1850 Set<Name> memberNames = new Set<Name>();
(...skipping 19 matching lines...) Expand all
1870 subcls.forEachClassMember((Member member) { 1870 subcls.forEachClassMember((Member member) {
1871 if (memberNames.contains(member.name)) { 1871 if (memberNames.contains(member.name)) {
1872 assert(invariant(member.element, 1872 assert(invariant(member.element,
1873 resolution.isLive(member.element))); 1873 resolution.isLive(member.element)));
1874 reflectableMembers.add(member.element); 1874 reflectableMembers.add(member.element);
1875 } 1875 }
1876 }); 1876 });
1877 } 1877 }
1878 } 1878 }
1879 // 5) all its closures 1879 // 5) all its closures
1880 List<Element> closures = closureMap[cls]; 1880 List<LocalFunctionElement> closures = closureMap[cls];
1881 if (closures != null) { 1881 if (closures != null) {
1882 reflectableMembers.addAll(closures); 1882 reflectableMembers.addAll(closures);
1883 foundClosure = true; 1883 foundClosure = true;
1884 } 1884 }
1885 } else { 1885 } else {
1886 // check members themselves 1886 // check members themselves
1887 cls.constructors.forEach((ConstructorElement element) { 1887 cls.constructors.forEach((ConstructorElement element) {
1888 if (!compiler.enqueuer.resolution.isLive(element)) return; 1888 if (!compiler.enqueuer.resolution.isLive(element)) return;
1889 if (referencedFromMirrorSystem(element, false)) { 1889 if (referencedFromMirrorSystem(element, false)) {
1890 reflectableMembers.add(element); 1890 reflectableMembers.add(element);
1891 } 1891 }
1892 }); 1892 });
1893 cls.forEachClassMember((Member member) { 1893 cls.forEachClassMember((Member member) {
1894 if (!compiler.enqueuer.resolution.isLive(member.element)) return; 1894 if (!compiler.enqueuer.resolution.isLive(member.element)) return;
1895 if (referencedFromMirrorSystem(member.element, false)) { 1895 if (referencedFromMirrorSystem(member.element, false)) {
1896 reflectableMembers.add(member.element); 1896 reflectableMembers.add(member.element);
1897 } 1897 }
1898 }); 1898 });
1899 // Also add in closures. Those might be reflectable is their enclosing 1899 // Also add in closures. Those might be reflectable is their enclosing
1900 // member is. 1900 // member is.
1901 List<Element> closures = closureMap[cls]; 1901 List<LocalFunctionElement> closures = closureMap[cls];
1902 if (closures != null) { 1902 if (closures != null) {
1903 for (Element closure in closures) { 1903 for (LocalFunctionElement closure in closures) {
1904 if (referencedFromMirrorSystem(closure.enclosingMember, false)) { 1904 if (referencedFromMirrorSystem(closure.memberContext, false)) {
1905 reflectableMembers.add(closure); 1905 reflectableMembers.add(closure);
1906 foundClosure = true; 1906 foundClosure = true;
1907 } 1907 }
1908 } 1908 }
1909 } 1909 }
1910 } 1910 }
1911 } 1911 }
1912 // We also need top-level non-class elements like static functions and 1912 // We also need top-level non-class elements like static functions and
1913 // global fields. We use the resolution queue to decide which elements are 1913 // global fields. We use the resolution queue to decide which elements are
1914 // part of the live world. 1914 // part of the live world.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 } 2311 }
2312 2312
2313 /// Records that [constant] is used by the element behind [registry]. 2313 /// Records that [constant] is used by the element behind [registry].
2314 class Dependency { 2314 class Dependency {
2315 final Constant constant; 2315 final Constant constant;
2316 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. 2316 // TODO(johnniwinther): Change to [Element] when dependency nodes are added.
2317 final Registry registry; 2317 final Registry registry;
2318 2318
2319 const Dependency(this.constant, this.registry); 2319 const Dependency(this.constant, this.registry);
2320 } 2320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698