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

Side by Side Diff: pkg/compiler/lib/src/js_backend/mirrors_analysis.dart

Issue 2915343002: Revert "Only call MirrorsData.retainMetadata* from codegen" (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/mirrors_data.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.mirrors_handler; 5 library dart2js.mirrors_handler;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart'; 8 import '../common/resolution.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // necessary, but the backend relies on them being resolved. 119 // necessary, but the backend relies on them being resolved.
120 enqueuer.applyImpact( 120 enqueuer.applyImpact(
121 _computeImpactForReflectiveStaticFields(_findStaticFieldTargets())); 121 _computeImpactForReflectiveStaticFields(_findStaticFieldTargets()));
122 } 122 }
123 123
124 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); 124 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.');
125 125
126 if (_mirrorsData.mustRetainMetadata) { 126 if (_mirrorsData.mustRetainMetadata) {
127 _reporter.log('Retaining metadata.'); 127 _reporter.log('Retaining metadata.');
128 128
129 /// Register the constant value of [metadata] as live in resolution. 129 for (LibraryEntity library in _compiler.libraryLoader.libraries) {
130 void registerMetadataConstant(MetadataAnnotation metadata) { 130 _mirrorsData.retainMetadataOfLibrary(library,
131 metadata.ensureResolved(_compiler.resolution); 131 addForEmission: !enqueuer.isResolutionQueue);
132 ConstantValue constant =
133 _constants.getConstantValueForMetadata(metadata);
134 Dependency dependency =
135 new Dependency(constant, metadata.annotatedElement);
136 _metadataConstants.add(dependency);
137 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant));
138 } 132 }
139 133
140 // TODO(johnniwinther): We should have access to all recently processed 134 if (!enqueuer.queueIsClosed) {
141 // elements and process these instead. 135 /// Register the constant value of [metadata] as live in resolution.
142 processMetadata(enqueuer.processedEntities, registerMetadataConstant); 136 void registerMetadataConstant(MetadataAnnotation metadata) {
137 ConstantValue constant =
138 _constants.getConstantValueForMetadata(metadata);
139 Dependency dependency =
140 new Dependency(constant, metadata.annotatedElement);
141 _metadataConstants.add(dependency);
142 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant));
143 }
144
145 // TODO(johnniwinther): We should have access to all recently processed
146 // elements and process these instead.
147 processMetadata(enqueuer.processedEntities, registerMetadataConstant);
148 } else {
149 for (Dependency dependency in _metadataConstants) {
150 _impactBuilder.registerConstantUse(
151 new ConstantUse.mirrors(dependency.constant));
152 }
153 _metadataConstants.clear();
154 }
155 enqueuer.applyImpact(_impactBuilder.flush());
143 } 156 }
144 } 157 }
145 158
146 /// Call [registerMetadataConstant] on all metadata from [entities]. 159 /// Call [registerMetadataConstant] on all metadata from [entities].
147 void processMetadata( 160 void processMetadata(
148 Iterable<Entity> entities, void onMetadata(MetadataAnnotation metadata)) { 161 Iterable<Entity> entities, void onMetadata(MetadataAnnotation metadata)) {
149 void processLibraryMetadata(LibraryElement library) { 162 void processLibraryMetadata(LibraryElement library) {
150 if (_registeredMetadata.add(library)) { 163 if (_registeredMetadata.add(library)) {
151 library.metadata.forEach(onMetadata); 164 library.metadata.forEach(onMetadata);
152 library.entryCompilationUnit.metadata.forEach(onMetadata); 165 library.entryCompilationUnit.metadata.forEach(onMetadata);
(...skipping 13 matching lines...) Expand all
166 } 179 }
167 } 180 }
168 if (element.enclosingClass != null) { 181 if (element.enclosingClass != null) {
169 // Only process library of top level fields/methods 182 // Only process library of top level fields/methods
170 // (and not for classes). 183 // (and not for classes).
171 // TODO(johnniwinther): Fix this: We are missing some metadata on 184 // TODO(johnniwinther): Fix this: We are missing some metadata on
172 // libraries (example: in co19/Language/Metadata/before_export_t01). 185 // libraries (example: in co19/Language/Metadata/before_export_t01).
173 if (element.enclosingElement is ClassElement) { 186 if (element.enclosingElement is ClassElement) {
174 // Use [enclosingElement] instead of [enclosingClass] to ensure that 187 // Use [enclosingElement] instead of [enclosingClass] to ensure that
175 // we process patch class metadata for patch and injected members. 188 // we process patch class metadata for patch and injected members.
189 processElementMetadata(element.enclosingElement);
176 } 190 }
177 processElementMetadata(element.enclosingClass); 191 } else {
192 processLibraryMetadata(element.library);
178 } 193 }
179 processLibraryMetadata(element.library);
180 } 194 }
181 } 195 }
182 196
183 entities.forEach((MemberElement member) => processElementMetadata(member)); 197 entities.forEach((MemberElement member) => processElementMetadata(member));
184 } 198 }
185 199
186 void onResolutionComplete() { 200 void onResolutionComplete() {
187 _registeredMetadata.clear(); 201 _registeredMetadata.clear();
188 } 202 }
189 203
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 479
466 /// Records that [constant] is used by the element behind [registry]. 480 /// Records that [constant] is used by the element behind [registry].
467 class Dependency { 481 class Dependency {
468 final ConstantValue constant; 482 final ConstantValue constant;
469 final Element annotatedElement; 483 final Element annotatedElement;
470 484
471 const Dependency(this.constant, this.annotatedElement); 485 const Dependency(this.constant, this.annotatedElement);
472 486
473 String toString() => '$annotatedElement:${constant.toStructuredText()}'; 487 String toString() => '$annotatedElement:${constant.toStructuredText()}';
474 } 488 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/mirrors_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698