Author: [EMAIL PROTECTED]
Date: Sat Oct 18 14:52:02 2008
New Revision: 3780
Modified:
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter.java
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/SourceGenerationVisitor.java
Log:
This brings the branch in line with the proposed merge
to trunk on October 17, 2008.
Modified:
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter.java
==============================================================================
---
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter.java
(original)
+++
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter.java
Sat Oct 18 14:52:02 2008
@@ -255,15 +255,7 @@
PerfLogger.end();
}
- /**
- * Map each program atom to a fragment. Atoms are mapped to a non-zero
- * fragment whenever they are known not to be needed whenever that
fragment's
- * split point has not been reached. Any atoms that cannot be so mapped
are
- * left in fragment zero.
- */
- private FragmentMap mapFragments() {
- FragmentMap fragmentMap = new FragmentMap();
-
+ private void mapExclusiveAtoms(FragmentMap fragmentMap) {
List<ControlFlowAnalyzer> allButOnes = computeAllButOneCfas();
ControlFlowAnalyzer everything = computeCompleteCfa();
@@ -290,7 +282,69 @@
updateMap(entry, fragmentMap.types, allButOne.getInstantiatedTypes(),
everything.getInstantiatedTypes());
}
+ }
+
+ /**
+ * Make sure that all field initializers can run in their specified
fragment.
+ * To do this, trace the code needed by each initializer, and make sure
it is
+ * either in 0 or in the same entry point as the field itself.
+ */
+ private void mapFieldInitializerCode(FragmentMap fragmentMap) {
+ ControlFlowAnalyzer initiallyLive = new ControlFlowAnalyzer(jprogram);
+ traverseEntry(initiallyLive, 0);
+ initiallyLive.finishTraversal();
+
+ // Note: do split point 0 last, to account for any fields moved to it
+ for (int splitPoint = numEntries - 1; splitPoint >= 0; splitPoint--) {
+ ControlFlowAnalyzer neededByFields = initiallyLive.clone();
+ for (JField field : fragmentMap.fields.keySet()) {
+ if (fragmentMap.fields.get(field) == splitPoint) {
+ if (field.getInitializer() != null) {
+ neededByFields.traverseFrom(field.getInitializer());
+ }
+ }
+ }
+ neededByFields.finishTraversal();
+ for (JNode node : neededByFields.getLiveFieldsAndMethods()) {
+ if (node instanceof JField) {
+ if (!fragmentMap.fields.containsKey(node)
+ || (fragmentMap.fields.get(node) != splitPoint)) {
+ fragmentMap.fields.put((JField) node, 0);
+ }
+ }
+ if (node instanceof JMethod) {
+ if (!fragmentMap.methods.containsKey(node)
+ || (fragmentMap.methods.get(node) != splitPoint)) {
+ fragmentMap.methods.put((JMethod) node, 0);
+ }
+ }
+ }
+ for (String string : neededByFields.getLiveStrings()) {
+ if (!fragmentMap.strings.containsKey(string)
+ || (fragmentMap.strings.get(string) != splitPoint)) {
+ fragmentMap.strings.put(string, 0);
+ }
+ }
+ for (JReferenceType type : neededByFields.getInstantiatedTypes()) {
+ if (!fragmentMap.types.containsKey(type)
+ || (fragmentMap.types.get(type) != splitPoint)) {
+ fragmentMap.types.put(type, 0);
+ }
+ }
+ }
+ }
+
+ /**
+ * Map each program atom to a fragment. Atoms are mapped to a non-zero
+ * fragment whenever they are known not to be needed whenever that
fragment's
+ * split point has not been reached. Any atoms that cannot be so mapped
are
+ * left in fragment zero.
+ */
+ private FragmentMap mapFragments() {
+ FragmentMap fragmentMap = new FragmentMap();
+ mapExclusiveAtoms(fragmentMap);
+ mapFieldInitializerCode(fragmentMap);
return fragmentMap;
}
Modified:
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
==============================================================================
---
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
(original)
+++
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
Sat Oct 18 14:52:02 2008
@@ -62,9 +62,9 @@
/**
* This class finds out what code in a program is live based on starting
- * execution at a specified location. Note that the client must call
- * [EMAIL PROTECTED] #finishTraversal()} after the other traversal methods have
- * been called, or the results will be incomplete.
+ * execution at a specified location. Note that the client must call
+ * [EMAIL PROTECTED] #finishTraversal()} after the other traversal methods
have been
+ * called, or the results will be incomplete.
*/
public class ControlFlowAnalyzer {
@@ -158,12 +158,12 @@
@Override
public boolean visit(JClassLiteral x, Context ctx) {
/*
- * Rescue just slightly less than what would normally be rescued for
- * a field reference to the literal's field. Rescue the field
itself,
- * and its initializer, but do NOT rescue the whole enclosing class.
- * That would pull in the clinit of that class, which has
initializers
- * for all the class literals, which in turn have all of the strings
- * of all of the class names.
+ * Rescue just slightly less than what would normally be rescued for
a
+ * field reference to the literal's field. Rescue the field itself,
and
+ * its initializer, but do NOT rescue the whole enclosing class. That
+ * would pull in the clinit of that class, which has initializers
for all
+ * the class literals, which in turn have all of the strings of all
of the
+ * class names.
*/
JField field = x.getField();
rescue(field);
@@ -276,7 +276,7 @@
// JLS 12.4.1: references to static methods rescue the enclosing
class
rescue(enclosingType, true, false);
}
-
+
if (x.isNative()) {
// Manually rescue native parameter references
final JsniMethodBody body = (JsniMethodBody) x.getBody();
@@ -633,6 +633,13 @@
*/
public Set<? extends JReferenceType> getReferencedTypes() {
return referencedTypes;
+ }
+
+ /**
+ * Traverse all code executed by <code>expr</code>.
+ */
+ public void traverseFrom(JExpression expr) {
+ rescuer.accept(expr);
}
/**
Modified:
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/SourceGenerationVisitor.java
==============================================================================
---
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/SourceGenerationVisitor.java
(original)
+++
changes/spoon/runAsync/dev/core/src/com/google/gwt/dev/jjs/impl/SourceGenerationVisitor.java
Sat Oct 18 14:52:02 2008
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not
* use this file except in compliance with the License. You may obtain a
copy of
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---