http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
File dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
(right):
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java#newcode298
dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java:298:
LongCastNormalizer.exec(jprogram);
On 2011/03/16 01:26:31, scottb wrote:
Can you just describe for posterity why this is needed?
It's been a long time, but IIRC, LongCastNormalizer turns implicit casts
into explicit casts. That means int += long becomes int += (int) long,
so when this normalizer runs and calls getType() on the RHS, it will see
int as the type and fail to split up the assignment. However, Lex is
the person who originally suggested this move, so he may have had other
reasons.
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java
File
dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java
(right):
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java#newcode70
dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java:70:
if (isIntegral(lhsType) && !isIntegral(rhsType)) {
Yeah, that's more correct, to fix the short op= int issues. I put in an
exception for float op= double because I don't think it will do anything
for correctness, except increase program size slightly.
On 2011/03/16 01:26:31, scottb wrote:
I almost think this ought to be:
if (widen(lhsType, rhsType) != lhsType)) {
...
}
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java#newcode70
dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java:70:
if (isIntegral(lhsType) && !isIntegral(rhsType)) {
AFAIK, the case of (float += double) already works and doesn't need to
be broken up. I think we only want to break up precisely the cases that
fail in JS otherwise we'll increase code size.
On 2011/03/16 01:26:31, scottb wrote:
I almost think this ought to be:
if (widen(lhsType, rhsType) != lhsType)) {
...
}
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java#newcode95
dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java:95:
widenType(type, JPrimitiveType.LONG) == JPrimitiveType.LONG;
Removed.
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java#newcode98
dev/core/src/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizer.java:98:
private JType widenType(JType lhsType, JType rhsType) {
Copied from Lex's brain, and
http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#26917
On 2011/03/16 01:26:31, scottb wrote:
Did you copy this from somewhere, or is there a JLS section you can
cite for
this?
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java
File
dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java
(right):
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java#newcode74
dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java:74:
"int x=2; short d=3; x += d;");
On 2011/03/16 01:26:31, scottb wrote:
OTOH, short += int should get split up, can you add a test for that?
Done, although I worry that someone might be relying on this broken
behavior, perhaps in a GWT crypto library. In general however, I believe
people tend not to utilize integral overflow behavior in GWT.
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java#newcode77
dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java:77:
"int x=2; long d=3L; x += (int)d;");
Fixed.
http://gwt-code-reviews.appspot.com/1385803/diff/2002/dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java#newcode86
dev/core/test/com/google/gwt/dev/jjs/impl/PostOptimizationCompoundAssignmentNormalizerTest.java:86:
"float x=2; double d=3.0; x += d;");
On 2011/03/16 01:26:31, scottb wrote:
Same here, float = float + double forces you to coerce.
Yeah but we don't have a way to narrow_float/round_float, so it wouldn't
change the result.
http://gwt-code-reviews.appspot.com/1385803/
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors