OK, so I've posted a bunch more patches, using different optimizations:
 - DeadCodeElimination: to optimize out the monomorphic String.toString
calls (String.toString is back to a JSNI String(this) to make sure it
behaves correctly, as I'm afraid the ""+this in Java from the second
code patch could be optimized to 'this' in some cases, or later on with
additional compiler optimizations). Also added tests for the
DeadCodeElimination.tryOptimizeStringCalls method.
 - GenerateJavaScriptAST: special-case the String.toString to alias it
to the native toString (i.e. generate _.tS=_.toString; instead of
_.tS=function(){return this;}; or similar. Technically speaking, the
DeadCodeElimination optimization from the third patch-set is no longer
needed, but it doesn't harm so I didn't remove it.

Pick your poison!


http://gwt-code-reviews.appspot.com/1623803/diff/3002/user/test/com/google/gwt/emultest/java/lang/StringTest.java
File user/test/com/google/gwt/emultest/java/lang/StringTest.java
(right):

http://gwt-code-reviews.appspot.com/1623803/diff/3002/user/test/com/google/gwt/emultest/java/lang/StringTest.java#newcode606
user/test/com/google/gwt/emultest/java/lang/StringTest.java:606: Object
s = Math.random() < 1 ? "abc" : JavaScriptObject.createObject();
On 2012/01/04 19:43:14, scottb wrote:
The way we do this now is:

static volatile boolean TRUE = true;
...
(TRUE ? foo : bar)

Done, including in the hideFromCompiler method (and removed the
associated TODO)

http://gwt-code-reviews.appspot.com/1623803/

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to