Remove synthetic clinit calls that are now empty.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1570 8db76d5a-ed1c-0410-87a9-c151d255dfc7
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 fed1fff..92b38d7 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
@@ -661,6 +661,11 @@
this.jsonTypeTable = jsonObjects;
}
+ public boolean isClinit(JMethod method) {
+ JReferenceType enclosingType = method.getEnclosingType();
+ return (enclosingType != null) && (method == enclosingType.methods.get(0));
+ }
+
public boolean isJavaScriptObject(JType type) {
if (type instanceof JClassType) {
return typeOracle.canTriviallyCast((JClassType) type,
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
index cc3b2fb..210ba0e 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
@@ -329,9 +329,15 @@
*/
@Override
public void endVisit(JMethodCall x, Context ctx) {
- JMethod method = x.getTarget();
- if (method.getEnclosingType() == program.getTypeJavaLangString()) {
- tryOptimizeStringCall(x, ctx, method);
+ JMethod target = x.getTarget();
+ JReferenceType targetType = target.getEnclosingType();
+ if (targetType == program.getTypeJavaLangString()) {
+ tryOptimizeStringCall(x, ctx, target);
+ } else if (program.isClinit(target)) {
+ // Eliminate the call if the target is now empty.
+ if (!program.typeOracle.hasClinit(targetType)) {
+ ctx.replaceMe(program.getLiteralNull());
+ }
}
}