Reviewers: cromwellian, scottb, zundel,
Description:
After an enum is ordinalized, any static methods generated as
staticImpl's should no longer be considered as such, since there is no
longer an instantated instance being passed as the first arg to the
method (this instance has been transformed into an ordinal int).
This was causing some clinit's not to be generated, since method calls
to staticImpl's don't force a clinit, since it is assumed that the
passed in instance argument will cause the clinit to be generated.
Please review this at http://gwt-code-reviews.appspot.com/1467815/
Affected files:
M dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
M dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
Index: dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java (revision 10425)
+++ dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java (working copy)
@@ -1017,6 +1017,13 @@
this.typesByQueryId = typesByQueryId;
}
+ public void removeStaticImplMapping(JMethod staticImpl) {
+ JMethod instanceMethod = staticToInstanceMap.remove(staticImpl);
+ if (instanceMethod != null) {
+ instanceToStaticMap.remove(instanceMethod);
+ }
+ }
+
public void setRunAsyncs(List<JRunAsync> runAsyncs) {
this.runAsyncs = Lists.normalizeUnmodifiable(runAsyncs);
}
Index: dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java (revision
10425)
+++ dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java (working
copy)
@@ -663,10 +663,24 @@
return false;
}
- // cleanup clinit method for ordinalizable enums
if (canBeOrdinal(x)) {
- // method 0 is always the clinit
+ /*
+ * Cleanup clinit method for ordinalizable enums. Note, method 0 is
+ * always the clinit.
+ */
updateClinit(x.getMethods().get(0));
+
+ /*
+ * Remove any static impl mappings for any methods in an ordinal
enum
+ * class. An ordinalized enum will no longer have an instance
passed as
+ * the first argument for a static impl (it will just be an int).
This
+ * is needed to preserve proper assumptions about static impls by
other
+ * optimizers (e.g. we might need to insert a clinit, when it
wouldn't
+ * be needed if a method call still had a static impl target).
+ */
+ for (JMethod method : x.getMethods()) {
+ program.removeStaticImplMapping(method);
+ }
}
return true;
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors