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

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

Issue 1225083004: dart2js: Emit static const fields if accessible by reflections. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/program_builder/collector.dart
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart b/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart
index eb8326de31aba227af0bf448c7ba72c31b05e72d..01299ab390a14eaab2eb475eadf2661f544f7813 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart
@@ -274,15 +274,25 @@ class Collector {
void computeNeededStaticNonFinalFields() {
JavaScriptConstantCompiler handler = backend.constants;
- Iterable<VariableElement> staticNonFinalFields = handler
- .getStaticNonFinalFieldsForEmission()
- .where(compiler.codegenWorld.allReferencedStaticFields.contains);
- for (Element element in Elements.sortedByPosition(staticNonFinalFields)) {
+ addToOutputUnit(Element element) {
List<VariableElement> list = outputStaticNonFinalFieldLists.putIfAbsent(
compiler.deferredLoadTask.outputUnitForElement(element),
- () => new List<VariableElement>());
+ () => new List<VariableElement>());
list.add(element);
}
+
+ Iterable<VariableElement> staticNonFinalFields = handler
+ .getStaticNonFinalFieldsForEmission()
+ .where(compiler.codegenWorld.allReferencedStaticFields.contains);
+
+ Elements.sortedByPosition(staticNonFinalFields).forEach(addToOutputUnit);
+
+ // We also need to emit static const fields if they are available for
+ // reflection.
+ compiler.codegenWorld.allReferencedStaticFields
+ .where((FieldElement field) => field.isConst)
+ .where(backend.isAccessibleByReflection)
+ .forEach(addToOutputUnit);
}
void computeNeededLibraries() {
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698