Make splitpoint.xml CodeSplitter2 aware.
Review at http://gwt-code-reviews.appspot.com/1639803
Review by: cromwellian@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10877 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java b/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
index bb507f8..5ffc1cc 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorder.java
@@ -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();
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
index 18835af..9cb3da6 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
@@ -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('$', '.');
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java b/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java
index 9d9e82b..347088d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/CodeSplitter2.java
@@ -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]);
@@ -116,7 +118,14 @@
}
}
}
-
+
+ /**
+ * @return Fragment index from a splitpoint number.
+ */
+ public int getFragmentFromSplitPoint(int splitpoint) {
+ return splitPointToFragmentMap[splitpoint];
+ }
+
/**
* @return Fragment number of the left over fragment.
*/
@@ -135,11 +144,11 @@
* @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];
}
}
-
+
/**
* Marks the type of partition heuristics
*/