John Stalcup has uploaded a new change for review.
https://gwt-review.googlesource.com/3460
Change subject: adds type tightening (and tests) for casts inside of
RunAsync onSuccessCalls, resulting in smaller leftover fragments
......................................................................
adds type tightening (and tests) for casts inside of RunAsync
onSuccessCalls, resulting in smaller leftover fragments
Change-Id: I7b454db222da054834aa0d78b1a769100bf9da9b
---
M dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
M dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
2 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
b/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
index 5ac6ea7..5fb0f82 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
@@ -45,6 +45,7 @@
import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JReferenceType;
import com.google.gwt.dev.jjs.ast.JReturnStatement;
+import com.google.gwt.dev.jjs.ast.JRunAsync;
import com.google.gwt.dev.jjs.ast.JTryStatement;
import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.JTypeOracle;
@@ -625,6 +626,12 @@
}
@Override
+ public boolean visit(JRunAsync x, Context ctx) {
+ x.traverseOnSuccess(this);
+ return super.visit(x, ctx);
+ }
+
+ @Override
public boolean visit(JClassType x, Context ctx) {
// don't mess with classes used in code gen
if (program.codeGenTypes.contains(x)) {
diff --git
a/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
b/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
index 70eaa5e..bc8b1b6 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
@@ -83,13 +83,14 @@
private JProgram jProgram = null;
private JsProgram jsProgram = null;
-
- public void setUp() throws Exception{
+
+ @Override
+ public void setUp() throws Exception {
super.setUp();
stackMode.addDefinedValue(new ConditionNone(), "STRIP");
jsProgram = new JsProgram();
}
-
+
public void testSimple() throws UnableToCompleteException {
StringBuffer code = new StringBuffer();
code.append("package test;\n");
@@ -127,6 +128,34 @@
// functionC must be in the initial fragment.
assertInFragment("functionC", 0);
+ }
+
+ public void testOnSuccessCallCast() throws UnableToCompleteException {
+ StringBuffer code = new StringBuffer();
+ code.append("package test;\n");
+ code.append("import com.google.gwt.core.client.GWT;\n");
+ code.append("import com.google.gwt.core.client.RunAsyncCallback;\n");
+ code.append("public class EntryPoint {\n");
+ code.append(" " + functionA);
+ code.append(" " + functionB);
+ code.append(" " + functionC);
+ code.append(" public static void onModuleLoad() {\n");
+ code.append(" functionC();");
+ code.append(" " +
createRunAsync("(RunAsyncCallback)", "functionA();"));
+ code.append(" " +
createRunAsync("(RunAsyncCallback)", "functionB();"));
+ code.append(" }\n");
+ code.append("}\n");
+ compileSnippet(code.toString());
+
+ // init + 2 fragments + leftover.
+ assertFragmentCount(4);
+
+ assertInFragment("functionA", 1);
+ assertInFragment("functionB", 2);
+
+ // Verify that functionA and B aren't in the leftover.
+ assertNotInFragment("functionA", 3);
+ assertNotInFragment("functionB", 3);
}
public void testMergeLeftOvers() throws UnableToCompleteException {
@@ -292,6 +321,8 @@
jProgram.addEntryMethod(findMethod(jProgram, "onModuleLoad"));
CastNormalizer.exec(jProgram, false);
ArrayNormalizer.exec(jProgram);
+ TypeTightener.exec(jProgram);
+ MethodCallTightener.exec(jProgram);
Map<StandardSymbolData, JsName> symbolTable =
new TreeMap<StandardSymbolData, JsName>(new
SymbolData.ClassIdentComparator());
JavaToJavaScriptMap map = GenerateJavaScriptAST.exec(
@@ -332,13 +363,21 @@
mergeLimit);
}
-
- private static String createRunAsync(String body) {
- return "GWT.runAsync(new RunAsyncCallback() {" +
- "public void onFailure(Throwable reason) {}" +
- "public void onSuccess() {" + body + "}});";
+ private static String createRunAsync(String cast, String body) {
+ StringBuffer code = new StringBuffer();
+ code.append("GWT.runAsync(" + cast + "new RunAsyncCallback() {\n");
+ code.append(" public void onFailure(Throwable reason) {}\n");
+ code.append(" public void onSuccess() {\n");
+ code.append(" " + body);
+ code.append(" }\n");
+ code.append("});\n");
+ return code.toString();
}
-
+
+ private static String createRunAsync(String body) {
+ return createRunAsync("", body);
+ }
+
/**
* Add some of the compiler intrinsic
*/
--
To view, visit https://gwt-review.googlesource.com/3460
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b454db222da054834aa0d78b1a769100bf9da9b
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: John Stalcup <stal...@google.com>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.