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

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

Issue 2921933002: 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 | « pkg/compiler/lib/src/js_backend/mirrors_analysis.dart ('k') | no next file » | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common_elements.dart'; 7 import '../common_elements.dart';
8 import '../compiler.dart'; 8 import '../compiler.dart';
9 import '../constants/values.dart'; 9 import '../constants/values.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 /// This property is used to tag emitted elements with a marker which is 117 /// This property is used to tag emitted elements with a marker which is
118 /// checked by the runtime system to throw an exception if an element is 118 /// checked by the runtime system to throw an exception if an element is
119 /// accessed (invoked, get, set) that is not accessible for the reflective 119 /// accessed (invoked, get, set) that is not accessible for the reflective
120 /// system. 120 /// system.
121 bool isMemberAccessibleByReflection(MemberEntity element); 121 bool isMemberAccessibleByReflection(MemberEntity element);
122 122
123 // TODO(johnniwinther): Remove this. 123 // TODO(johnniwinther): Remove this.
124 @deprecated 124 @deprecated
125 bool isAccessibleByReflection(Element element); 125 bool isAccessibleByReflection(Element element);
126 126
127 bool retainMetadataOfLibrary(LibraryEntity element, 127 bool retainMetadataOfLibrary(LibraryEntity element);
128 {bool addForEmission: true});
129 bool retainMetadataOfTypedef(TypedefElement element); 128 bool retainMetadataOfTypedef(TypedefElement element);
130 bool retainMetadataOfClass(ClassEntity element); 129 bool retainMetadataOfClass(ClassEntity element);
131 bool retainMetadataOfMember(MemberEntity element); 130 bool retainMetadataOfMember(MemberEntity element);
132 bool retainMetadataOfParameter(ParameterElement element); 131 bool retainMetadataOfParameter(ParameterElement element);
133 132
134 bool invokedReflectively(Element element); 133 bool invokedReflectively(Element element);
135 134
136 /// Returns true if this element has to be enqueued due to 135 /// Returns true if this element has to be enqueued due to
137 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if 136 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if
138 /// normal tree shaking is still active ([isTreeShakingDisabled] is false). 137 /// normal tree shaking is still active ([isTreeShakingDisabled] is false).
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 hasRetainedMetadata = true; 283 hasRetainedMetadata = true;
285 if (isTypedefReferencedFromMirrorSystem(element)) { 284 if (isTypedefReferencedFromMirrorSystem(element)) {
286 _retainMetadataOf(element); 285 _retainMetadataOf(element);
287 return true; 286 return true;
288 } 287 }
289 } 288 }
290 return false; 289 return false;
291 } 290 }
292 291
293 @override 292 @override
294 bool retainMetadataOfLibrary(LibraryElement element, 293 bool retainMetadataOfLibrary(LibraryElement element) {
295 {bool addForEmission: true}) {
296 if (mustRetainMetadata) { 294 if (mustRetainMetadata) {
297 hasRetainedMetadata = true; 295 hasRetainedMetadata = true;
298 if (isLibraryReferencedFromMirrorSystem(element)) { 296 if (isLibraryReferencedFromMirrorSystem(element)) {
299 _retainMetadataOf(element, addForEmission: addForEmission); 297 _retainMetadataOf(element);
300 return true; 298 return true;
301 } 299 }
302 } 300 }
303 return false; 301 return false;
304 } 302 }
305 303
306 void _retainMetadataOf(Element element, {bool addForEmission: true}) { 304 void _retainMetadataOf(Element element) {
305 assert(_compiler.phase == Compiler.PHASE_COMPILING);
307 for (MetadataAnnotation metadata in element.metadata) { 306 for (MetadataAnnotation metadata in element.metadata) {
308 metadata.ensureResolved(_compiler.resolution);
309 ConstantValue constant = _constants.getConstantValueForMetadata(metadata); 307 ConstantValue constant = _constants.getConstantValueForMetadata(metadata);
310 if (addForEmission) { 308 CodegenWorldBuilder worldBuilder = _compiler.codegenWorldBuilder;
311 CodegenWorldBuilder worldBuilder = _compiler.codegenWorldBuilder; 309 worldBuilder.addCompileTimeConstantForEmission(constant);
312 worldBuilder.addCompileTimeConstantForEmission(constant);
313 }
314 } 310 }
315 } 311 }
316 312
317 bool invokedReflectively(Element element) { 313 bool invokedReflectively(Element element) {
318 if (element.isParameter) { 314 if (element.isParameter) {
319 ParameterElement parameter = element; 315 ParameterElement parameter = element;
320 if (invokedReflectively(parameter.functionDeclaration)) return true; 316 if (invokedReflectively(parameter.functionDeclaration)) return true;
321 } 317 }
322 318
323 if (element.isField) { 319 if (element.isField) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 697 }
702 698
703 /// Called when `const Symbol(name)` is seen. 699 /// Called when `const Symbol(name)` is seen.
704 void registerConstSymbol(String name) { 700 void registerConstSymbol(String name) {
705 symbolsUsed.add(name); 701 symbolsUsed.add(name);
706 if (name.endsWith('=')) { 702 if (name.endsWith('=')) {
707 symbolsUsed.add(name.substring(0, name.length - 1)); 703 symbolsUsed.add(name.substring(0, name.length - 1));
708 } 704 }
709 } 705 }
710 } 706 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/mirrors_analysis.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698