Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart |
| index 57a388ed240bdb16bdf65507be0ef50f0036a98e..a59b8fc2cf98e10e7cf0b1df17c2efaa18da9bf5 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart |
| @@ -25,6 +25,14 @@ class CodeEmitterTask extends CompilerTask { |
| new Map<OutputUnit, List<ClassElement>>(); |
| final Map<OutputUnit, List<ConstantValue>> outputConstantLists = |
| new Map<OutputUnit, List<ConstantValue>>(); |
| + final Map<OutputUnit, List<Element>> outputStaticLists = |
| + new Map<OutputUnit, List<Element>>(); |
| + final Map<OutputUnit, Set<LibraryElement>> outputLibraryLists = |
| + new Map<OutputUnit, Set<LibraryElement>>(); |
| + |
| + /// True, if the output contains a constant list. |
|
Johnni Winther
2014/10/16 08:04:50
Add that this is updated in [computeNeededConstant
floitsch
2014/10/16 11:53:36
Done.
|
| + bool outputContainsConstantList = false; |
| + |
| final List<ClassElement> nativeClasses = <ClassElement>[]; |
| /// Records if a type variable is read dynamically for type tests. |
| @@ -163,6 +171,9 @@ class CodeEmitterTask extends CompilerTask { |
| compiler.hasIncrementalSupport ? null : emitter.compareConstants); |
| for (ConstantValue constant in constants) { |
| if (emitter.isConstantInlinedOrAlreadyEmitted(constant)) continue; |
| + |
| + if (constant.isList) outputContainsConstantList = true; |
| + |
| OutputUnit constantUnit = |
| compiler.deferredLoadTask.outputUnitForConstant(constant); |
| if (constantUnit == null) { |
| @@ -286,6 +297,33 @@ class CodeEmitterTask extends CompilerTask { |
| } |
| } |
| + void computeNeededStatics() { |
| + bool isStaticFunction(Element element) => |
| + !element.isInstanceMember && !element.isField; |
| + |
| + Iterable<Element> elements = |
| + backend.generatedCode.keys.where(isStaticFunction); |
| + |
| + for (Element element in Elements.sortedByPosition(elements)) { |
| + outputStaticLists.putIfAbsent( |
| + compiler.deferredLoadTask.outputUnitForElement(element), |
| + () => new List<Element>()) |
| + .add(element); |
| + } |
| + } |
| + |
| + void computeNeededLibraries() { |
| + void addSurroundingLibraryToSet(Element element) { |
| + OutputUnit unit = compiler.deferredLoadTask.outputUnitForElement(element); |
| + LibraryElement library = element.library; |
| + outputLibraryLists.putIfAbsent(unit, () => new Set<LibraryElement>()) |
| + .add(library); |
| + } |
| + |
| + backend.generatedCode.keys.forEach(addSurroundingLibraryToSet); |
| + neededClasses.forEach(addSurroundingLibraryToSet); |
| +} |
| + |
| void assembleProgram() { |
| measure(() { |
| emitter.invalidateCaches(); |
| @@ -296,6 +334,9 @@ class CodeEmitterTask extends CompilerTask { |
| computeNeededDeclarations(); |
| computeNeededConstants(); |
| + computeNeededStatics(); |
| + computeNeededLibraries(); |
| + |
| Program program; |
| if (USE_NEW_EMITTER) { |