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

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

Issue 21110003: Implement MirrorUsed.targets for libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r25609 and added test. Created 7 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 | 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 class JavaScriptItemCompilationContext extends ItemCompilationContext { 7 class JavaScriptItemCompilationContext extends ItemCompilationContext {
8 final Set<HInstruction> boundsChecked; 8 final Set<HInstruction> boundsChecked;
9 9
10 JavaScriptItemCompilationContext() 10 JavaScriptItemCompilationContext()
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 final List<Dependency> metadataInstantiatedTypes = <Dependency>[]; 313 final List<Dependency> metadataInstantiatedTypes = <Dependency>[];
314 314
315 /// List of elements used from metadata. If metadata must be preserved, 315 /// List of elements used from metadata. If metadata must be preserved,
316 /// these elements must be compiled. 316 /// these elements must be compiled.
317 final List<Element> metadataStaticUse = <Element>[]; 317 final List<Element> metadataStaticUse = <Element>[];
318 318
319 /// List of tear-off functions referenced from metadata. If metadata must be 319 /// List of tear-off functions referenced from metadata. If metadata must be
320 /// preserved, these elements must be compiled. 320 /// preserved, these elements must be compiled.
321 final List<FunctionElement> metadataGetOfStaticFunction = <FunctionElement>[]; 321 final List<FunctionElement> metadataGetOfStaticFunction = <FunctionElement>[];
322 322
323 /// List of symbols that the user has requested for reflection.
324 final Set<String> symbolsUsed = new Set<String>();
325
326 /// List of elements that the user has requested for reflection.
327 final Set<Element> targetsUsed = new Set<Element>();
328
329 /// List of annotations provided by user that indicate that the annotated
330 /// element must be retained.
331 final Set<Element> metaTargetsUsed = new Set<Element>();
Johnni Winther 2013/07/30 11:15:09 Isn't this a list of the annotated elements and no
ahe 2013/07/30 12:05:45 No. This is a list of classes that can be used as
332
323 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval) 333 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval)
324 : namer = determineNamer(compiler), 334 : namer = determineNamer(compiler),
325 oneShotInterceptors = new Map<String, Selector>(), 335 oneShotInterceptors = new Map<String, Selector>(),
326 interceptedElements = new Map<SourceString, Set<Element>>(), 336 interceptedElements = new Map<SourceString, Set<Element>>(),
327 rti = new RuntimeTypes(compiler), 337 rti = new RuntimeTypes(compiler),
328 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), 338 specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
329 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { 339 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) {
330 emitter = disableEval 340 emitter = disableEval
331 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) 341 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap)
332 : new CodeEmitterTask(compiler, namer, generateSourceMap); 342 : new CodeEmitterTask(compiler, namer, generateSourceMap);
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 } 1449 }
1440 } 1450 }
1441 1451
1442 void registerMetadataGetOfStaticFunction(FunctionElement element) { 1452 void registerMetadataGetOfStaticFunction(FunctionElement element) {
1443 if (mustRetainMetadata) { 1453 if (mustRetainMetadata) {
1444 compiler.constantHandler.registerGetOfStaticFunction(element); 1454 compiler.constantHandler.registerGetOfStaticFunction(element);
1445 } else { 1455 } else {
1446 metadataGetOfStaticFunction.add(element); 1456 metadataGetOfStaticFunction.add(element);
1447 } 1457 }
1448 } 1458 }
1459
1460 void registerMirrorUsage(Set<String> symbols,
1461 Set<Element> targets,
1462 Set<Element> metaTargets) {
1463 if (symbols != null) symbolsUsed.addAll(symbols);
1464 if (targets != null) {
1465 for (Element element in targets) {
1466 // TODO(ahe): Implement finer granularity.
1467 targetsUsed.add(element.getLibrary());
1468 }
1469 }
1470 if (metaTargets != null) metaTargetsUsed.addAll(metaTargets);
1471 }
1472
1473 bool isNeededForReflection(Element element) {
1474 // TODO(ahe): Implement this.
1475 if (!metaTargetsUsed.isEmpty) return true;
1476 if (targetsUsed.contains(element.getLibrary())) return true;
1477 return false;
1478 }
1449 } 1479 }
1450 1480
1451 /// Records that [type] is used by [user.element]. 1481 /// Records that [type] is used by [user.element].
1452 class Dependency { 1482 class Dependency {
1453 final DartType type; 1483 final DartType type;
1454 final TreeElements user; 1484 final TreeElements user;
1455 1485
1456 const Dependency(this.type, this.user); 1486 const Dependency(this.type, this.user);
1457 } 1487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698