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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder/collector.dart

Issue 2994333002: Various redemptions (Closed)
Patch Set: Fix + status updates Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.js_emitter.program_builder; 5 part of dart2js.js_emitter.program_builder;
6 6
7 /** 7 /**
8 * Generates the code for all used classes in the program. Static fields (even 8 * Generates the code for all used classes in the program. Static fields (even
9 * in classes) are ignored, since they can be treated as non-class elements. 9 * in classes) are ignored, since they can be treated as non-class elements.
10 * 10 *
(...skipping 30 matching lines...) Expand all
41 final Map<OutputUnit, List<FieldEntity>> outputStaticNonFinalFieldLists = 41 final Map<OutputUnit, List<FieldEntity>> outputStaticNonFinalFieldLists =
42 new Map<OutputUnit, List<FieldEntity>>(); 42 new Map<OutputUnit, List<FieldEntity>>();
43 final Map<OutputUnit, Set<LibraryEntity>> outputLibraryLists = 43 final Map<OutputUnit, Set<LibraryEntity>> outputLibraryLists =
44 new Map<OutputUnit, Set<LibraryEntity>>(); 44 new Map<OutputUnit, Set<LibraryEntity>>();
45 45
46 /// True, if the output contains a constant list. 46 /// True, if the output contains a constant list.
47 /// 47 ///
48 /// This flag is updated in [computeNeededConstants]. 48 /// This flag is updated in [computeNeededConstants].
49 bool outputContainsConstantList = false; 49 bool outputContainsConstantList = false;
50 50
51 final List<ClassElement> nativeClassesAndSubclasses = <ClassElement>[]; 51 final List<ClassEntity> nativeClassesAndSubclasses = <ClassEntity>[];
52 52
53 List<TypedefEntity> typedefsNeededForReflection; 53 List<TypedefEntity> typedefsNeededForReflection;
54 54
55 Collector( 55 Collector(
56 this._options, 56 this._options,
57 this._commonElements, 57 this._commonElements,
58 this._elementEnvironment, 58 this._elementEnvironment,
59 this._deferredLoadTask, 59 this._deferredLoadTask,
60 this._worldBuilder, 60 this._worldBuilder,
61 this._namer, 61 this._namer,
(...skipping 19 matching lines...) Expand all
81 } 81 }
82 return classes; 82 return classes;
83 } 83 }
84 84
85 /** 85 /**
86 * Return a function that returns true if its argument is a class 86 * Return a function that returns true if its argument is a class
87 * that needs to be emitted. 87 * that needs to be emitted.
88 */ 88 */
89 Function computeClassFilter() { 89 Function computeClassFilter() {
90 if (_mirrorsData.isTreeShakingDisabled) { 90 if (_mirrorsData.isTreeShakingDisabled) {
91 return (ClassElement cls) => true; 91 return (ClassEntity cls) => true;
92 } 92 }
93 93
94 Set<ClassEntity> unneededClasses = new Set<ClassEntity>(); 94 Set<ClassEntity> unneededClasses = new Set<ClassEntity>();
95 // The [Bool] class is not marked as abstract, but has a factory 95 // The [Bool] class is not marked as abstract, but has a factory
96 // constructor that always throws. We never need to emit it. 96 // constructor that always throws. We never need to emit it.
97 unneededClasses.add(_commonElements.boolClass); 97 unneededClasses.add(_commonElements.boolClass);
98 98
99 // Go over specialized interceptors and then constants to know which 99 // Go over specialized interceptors and then constants to know which
100 // interceptors are needed. 100 // interceptors are needed.
101 Set<ClassEntity> needed = new Set<ClassEntity>(); 101 Set<ClassEntity> needed = new Set<ClassEntity>();
(...skipping 27 matching lines...) Expand all
129 129
130 /** 130 /**
131 * Compute all the constants that must be emitted. 131 * Compute all the constants that must be emitted.
132 */ 132 */
133 void computeNeededConstants() { 133 void computeNeededConstants() {
134 // Make sure we retain all metadata of all elements. This could add new 134 // Make sure we retain all metadata of all elements. This could add new
135 // constants to the handler. 135 // constants to the handler.
136 if (_mirrorsData.mustRetainMetadata) { 136 if (_mirrorsData.mustRetainMetadata) {
137 // TODO(floitsch): verify that we don't run through the same elements 137 // TODO(floitsch): verify that we don't run through the same elements
138 // multiple times. 138 // multiple times.
139 for (MemberElement element in _generatedCode.keys) { 139 for (MemberEntity element in _generatedCode.keys) {
140 if (_mirrorsData.isMemberAccessibleByReflection(element)) { 140 if (_mirrorsData.isMemberAccessibleByReflection(element)) {
141 _mirrorsData.retainMetadataOfMember(element); 141 _mirrorsData.retainMetadataOfMember(element);
142 } 142 }
143 } 143 }
144 for (ClassElement cls in neededClasses) { 144 for (ClassEntity cls in neededClasses) {
145 final onlyForRti = classesOnlyNeededForRti.contains(cls); 145 final onlyForRti = classesOnlyNeededForRti.contains(cls);
146 if (!onlyForRti) { 146 if (!onlyForRti) {
147 _mirrorsData.retainMetadataOfClass(cls); 147 _mirrorsData.retainMetadataOfClass(cls);
148 new FieldVisitor(_options, _elementEnvironment, _worldBuilder, 148 new FieldVisitor(
149 _nativeData, _mirrorsData, _namer, _closedWorld) 149 _options,
150 _elementEnvironment,
151 _commonElements,
152 _worldBuilder,
153 _nativeData,
154 _mirrorsData,
155 _namer,
156 _closedWorld)
150 .visitFields((FieldEntity member, 157 .visitFields((FieldEntity member,
151 js.Name name, 158 js.Name name,
152 js.Name accessorName, 159 js.Name accessorName,
153 bool needsGetter, 160 bool needsGetter,
154 bool needsSetter, 161 bool needsSetter,
155 bool needsCheckedSetter) { 162 bool needsCheckedSetter) {
156 bool needsAccessor = needsGetter || needsSetter; 163 bool needsAccessor = needsGetter || needsSetter;
157 if (needsAccessor && 164 if (needsAccessor &&
158 _mirrorsData.isMemberAccessibleByReflection(member)) { 165 _mirrorsData.isMemberAccessibleByReflection(member)) {
159 _mirrorsData.retainMetadataOfMember(member); 166 _mirrorsData.retainMetadataOfMember(member);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 350 }
344 351
345 void collect() { 352 void collect() {
346 computeNeededDeclarations(); 353 computeNeededDeclarations();
347 computeNeededConstants(); 354 computeNeededConstants();
348 computeNeededStatics(); 355 computeNeededStatics();
349 computeNeededStaticNonFinalFields(); 356 computeNeededStaticNonFinalFields();
350 computeNeededLibraries(); 357 computeNeededLibraries();
351 } 358 }
352 } 359 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common_elements.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698