Reviewers: cromwellian,
Description:
Make splitpoint.xml CodeSplitter2 aware.
Please review this at http://gwt-code-reviews.appspot.com/1639803/
Affected files:
M dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
M dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
M dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java
Index:
dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
===================================================================
--- dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
(revision 10862)
+++ dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
(working copy)
@@ -18,6 +18,7 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JRunAsync;
+import
com.google.gwt.dev.jjs.impl.CodeSplitter2.FragmentPartitioningResult;
import com.google.gwt.dev.util.HtmlTextOutput;
import com.google.gwt.util.tools.Utility;
@@ -54,6 +55,7 @@
htmlOut.indentIn();
List<JRunAsync> runAsyncs = jprogram.getRunAsyncs();
+ FragmentPartitioningResult partitionResult =
jprogram.getFragmentPartitioningResult();
if (runAsyncs.size() > 0) {
curLine = "<splitpoints>";
htmlOut.printRaw(curLine);
@@ -62,6 +64,9 @@
htmlOut.indentIn();
for (JRunAsync runAsync : runAsyncs) {
int sp = runAsync.getSplitPoint();
+ if (partitionResult != null) {
+ sp = partitionResult.getFragmentFromSplitPoint(sp);
+ }
String name = runAsync.getName();
curLine = "<splitpoint id=\"" + sp + "\" location=\"" + name
+ "\"/>";
htmlOut.printRaw(curLine);
@@ -84,6 +89,9 @@
htmlOut.indentIn();
for (int sp : jprogram.getSplitPointInitialSequence()) {
+ if (partitionResult != null) {
+ sp = partitionResult.getFragmentFromSplitPoint(sp);
+ }
curLine = "<splitpointref id=\"" + sp + "\"/>";
htmlOut.printRaw(curLine);
htmlOut.newline();
Index: dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java (revision 10862)
+++ dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java (working copy)
@@ -309,8 +309,8 @@
// If there were some fragment merging.
if (result != null) {
- sp1 = result.getSplitPointFromFragmnet(sp1);
- sp2 = result.getSplitPointFromFragmnet(sp2);
+ sp1 = result.getSplitPointFromFragment(sp1);
+ sp2 = result.getSplitPointFromFragment(sp2);
}
int initPos1 = initialSeq.indexOf(sp1);
@@ -681,6 +681,10 @@
// Initial fragment is the +1.
return runAsyncs.size() + 1;
}
+
+ public FragmentPartitioningResult getFragmentPartitioningResult() {
+ return fragmentPartitioninResult;
+ }
public JDeclaredType getFromTypeMap(String qualifiedBinaryOrSourceName) {
String srcTypeName = qualifiedBinaryOrSourceName.replace('$', '.');
Index: dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java (revision
10862)
+++ dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java (working
copy)
@@ -102,8 +102,10 @@
*/
public static final class FragmentPartitioningResult {
private final int[] fragmentToSplitPoint;
+ private final int[] splitPointToFragmentMap;
private FragmentPartitioningResult(int[] splitPointToFragmentMap, int
numFragments) {
+ this.splitPointToFragmentMap = splitPointToFragmentMap;
fragmentToSplitPoint = new int[numFragments];
for (int i = 0, len = splitPointToFragmentMap.length - 1; i < len;
i++) {
System.out.println("splitPointToFragmentMap[" + i + "] = " +
splitPointToFragmentMap[i]);
@@ -135,8 +137,15 @@
* @return One of the split point number in a given fragment. If there
* are more than one splitpoints in the a fragment, -1 is returned.
*/
- public int getSplitPointFromFragmnet(int fragment) {
+ public int getSplitPointFromFragment(int fragment) {
return fragmentToSplitPoint[fragment];
+ }
+
+ /**
+ * @return Fragment index from a splitpoint number.
+ */
+ public int getFragmentFromSplitPoint(int splitpoint) {
+ return splitPointToFragmentMap[splitpoint];
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors