Fix for bug 5408, error in shift operations on Long. arithmetic
authorMartin Soch <Martin.Soch@oracle.com>
Wed, 09 Oct 2013 14:50:29 +0200
brancharithmetic
changeset 13527bc78045adfd
parent 1351 f73c1a0234fb
child 1361 1b333e5804f5
Fix for bug 5408, error in shift operations on Long.
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js
     1.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java	Mon Oct 07 14:20:58 2013 +0200
     1.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java	Wed Oct 09 14:50:29 2013 +0200
     1.3 @@ -1,3 +1,20 @@
     1.4 +/**
     1.5 + * Back 2 Browser Bytecode Translator
     1.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 + *
     1.8 + * This program is free software: you can redistribute it and/or modify
     1.9 + * it under the terms of the GNU General Public License as published by
    1.10 + * the Free Software Foundation, version 2 of the License.
    1.11 + *
    1.12 + * This program is distributed in the hope that it will be useful,
    1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 + * GNU General Public License for more details.
    1.16 + *
    1.17 + * You should have received a copy of the GNU General Public License
    1.18 + * along with this program. Look for COPYING file in the top folder.
    1.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 + */
    1.21  package org.apidesign.bck2brwsr.tck;
    1.22  
    1.23  import java.util.EnumMap;
    1.24 @@ -15,7 +32,6 @@
    1.25          B, W;
    1.26      }
    1.27  
    1.28 -    /*
    1.29      @Compare public String enumSet() {
    1.30          try { throw new Exception(); } catch (Exception ex) {}
    1.31          EnumSet<Color> c = EnumSet.allOf(Color.class);
    1.32 @@ -26,7 +42,6 @@
    1.33          EnumSet<Color> c = EnumSet.of(Color.B, Color.W);
    1.34          return c.toString();
    1.35      }
    1.36 -    */
    1.37  
    1.38      @Compare public boolean enumFirstContains() {
    1.39          EnumSet<Color> c = EnumSet.of(Color.B);
     2.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Mon Oct 07 14:20:58 2013 +0200
     2.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Wed Oct 09 14:50:29 2013 +0200
     2.3 @@ -304,6 +304,14 @@
     2.4      @Compare public long shiftL3() {
     2.5          return shl(0x00fa37d7763e0ca1l, 45);
     2.6      }
     2.7 +    
     2.8 +    @Compare public long shiftL4() {
     2.9 +        return shl(0x00fa37d7763e0ca1l, 0);
    2.10 +    }
    2.11 +    
    2.12 +    @Compare public long shiftL5() {
    2.13 +        return shl(0x00fa37d7763e0ca1l, 70);
    2.14 +    }
    2.15  
    2.16      @Compare public long shiftR1() {
    2.17          return shr(0x00fa37d7763e0ca1l, 5);
    2.18 @@ -316,6 +324,14 @@
    2.19      @Compare public long shiftR3() {
    2.20          return shr(0x00fa37d7763e0ca1l, 45);
    2.21      }
    2.22 +    
    2.23 +    @Compare public long shiftR4() {
    2.24 +        return shr(0x00fa37d7763e0ca1l, 0);
    2.25 +    }
    2.26 +    
    2.27 +    @Compare public long shiftR5() {
    2.28 +        return shr(0x00fa37d7763e0ca1l, 70);
    2.29 +    }
    2.30  
    2.31      @Compare public long uShiftR1() {
    2.32          return ushr(0x00fa37d7763e0ca1l, 5);
    2.33 @@ -324,14 +340,30 @@
    2.34      @Compare public long uShiftR2() {
    2.35          return ushr(0x00fa37d7763e0ca1l, 45);
    2.36      }
    2.37 +    
    2.38 +    @Compare public long uShiftR3() {
    2.39 +        return ushr(0x00fa37d7763e0ca1l, 0);
    2.40 +    }
    2.41 +    
    2.42 +    @Compare public long uShiftR4() {
    2.43 +        return ushr(0x00fa37d7763e0ca1l, 70);
    2.44 +    }
    2.45  
    2.46 -    @Compare public long uShiftR3() {
    2.47 +    @Compare public long uShiftR5() {
    2.48          return ushr(0xf0fa37d7763e0ca1l, 5);
    2.49      }
    2.50  
    2.51 -    @Compare public long uShiftR4() {
    2.52 +    @Compare public long uShiftR6() {
    2.53          return ushr(0xf0fa37d7763e0ca1l, 45);
    2.54      }
    2.55 +    
    2.56 +    @Compare public long uShiftR7() {
    2.57 +        return ushr(0xf0fa37d7763e0ca1l, 0);
    2.58 +    }
    2.59 +    
    2.60 +    @Compare public long uShiftR8() {
    2.61 +        return ushr(0xf0fa37d7763e0ca1l, 70);
    2.62 +    }
    2.63  
    2.64      @Compare public long and1() {
    2.65          return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
     3.1 --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Mon Oct 07 14:20:58 2013 +0200
     3.2 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Wed Oct 09 14:50:29 2013 +0200
     3.3 @@ -176,6 +176,8 @@
     3.4      };
     3.5  
     3.6      numberPrototype.shl64 = function(x) {
     3.7 +        x &= 0x3f;
     3.8 +        if (x == 0) return this;
     3.9          if (x >= 32) {
    3.10              var hi = this << (x - 32);
    3.11              return hi.next32(0);
    3.12 @@ -190,6 +192,8 @@
    3.13      };
    3.14  
    3.15      numberPrototype.shr64 = function(x) {
    3.16 +        x &= 0x3f;
    3.17 +        if (x == 0) return this;
    3.18          if (x >= 32) {
    3.19              var low = this.high32() >> (x - 32);
    3.20              low += (low < 0) ? (__m32 + 1) : 0;
    3.21 @@ -205,6 +209,8 @@
    3.22      };
    3.23  
    3.24      numberPrototype.ushr64 = function(x) {
    3.25 +        x &= 0x3f;
    3.26 +        if (x == 0) return this;
    3.27          if (x >= 32) {
    3.28              var low = this.high32() >>> (x - 32);
    3.29              low += (low < 0) ? (__m32 + 1) : 0;