Direct reimplementation of mod64, and64, or64, xor64 functions
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 27 Jan 2016 20:45:14 +0100
changeset 1868cb3c8fb1245d
parent 1867 60e77363650a
child 1869 764f32c645f9
Direct reimplementation of mod64, and64, or64, xor64 functions
rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js
     1.1 --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Wed Jan 27 20:30:33 2016 +0100
     1.2 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Wed Jan 27 20:45:14 2016 +0100
     1.3 @@ -125,33 +125,32 @@
     1.4          return hi.next32(low);
     1.5      };
     1.6  
     1.7 -    numberPrototype.and64 = function(x) {
     1.8 -        var low = this & x;
     1.9 +    function and64(x, y) {
    1.10 +        var low = x & y;
    1.11          low += (low < 0) ? (__m32 + 1) : 0;
    1.12 -        if (this.hi && x.hi) {
    1.13 -            var hi = this.hi & x.hi;
    1.14 +        if (x.hi && y.hi) {
    1.15 +            var hi = x.hi & y.hi;
    1.16              return hi.next32(low);
    1.17          }
    1.18          ;
    1.19          return low;
    1.20      };
    1.21  
    1.22 -    numberPrototype.or64 = function(x) {
    1.23 -        var low = this | x;
    1.24 +    function or64(x, y) {
    1.25 +        var low = x | y;
    1.26          low += (low < 0) ? (__m32 + 1) : 0;
    1.27 -        if (this.hi || x.hi) {
    1.28 -            var hi = this.hi | x.hi;
    1.29 +        if (x.hi || y.hi) {
    1.30 +            var hi = x.hi | y.hi;
    1.31              return hi.next32(low);
    1.32          }
    1.33 -        ;
    1.34          return low;
    1.35      };
    1.36  
    1.37 -    numberPrototype.xor64 = function(x) {
    1.38 -        var low = this ^ x;
    1.39 +    function xor64(x, y) {
    1.40 +        var low = x ^ y;
    1.41          low += (low < 0) ? (__m32 + 1) : 0;
    1.42 -        if (this.hi || x.hi) {
    1.43 -            var hi = this.hi ^ x.hi;
    1.44 +        if (x.hi || y.hi) {
    1.45 +            var hi = x.hi ^ y.hi;
    1.46              return hi.next32(low);
    1.47          }
    1.48          ;
    1.49 @@ -505,21 +504,21 @@
    1.50          return negateResult ? result.neg64() : result; 
    1.51      }
    1.52  
    1.53 -    numberPrototype.mod64 = function(x) {
    1.54 +    function mod64(x, y) {
    1.55          var negateResult = false;
    1.56          var u, v;
    1.57          
    1.58 -        if ((this.high32() & 0x80000000) != 0) {
    1.59 -            u = this.neg64();
    1.60 +        if ((x.high32() & 0x80000000) != 0) {
    1.61 +            u = x.neg64();
    1.62              negateResult = !negateResult;
    1.63          } else {
    1.64 -            u = this;        
    1.65 +            u = x;
    1.66          }
    1.67  
    1.68 -        if ((x.high32() & 0x80000000) != 0) {
    1.69 -            v = x.neg64();
    1.70 +        if ((y.high32() & 0x80000000) != 0) {
    1.71 +            v = y.neg64();
    1.72          } else {
    1.73 -            v = x;
    1.74 +            v = y;
    1.75          }
    1.76  
    1.77          if ((v == 0) && (v.high32() === 0)) {
    1.78 @@ -547,10 +546,10 @@
    1.79      b.sub64 = sub64;
    1.80      b.mul64 = mul64;
    1.81      b.div64 = div64;
    1.82 -    b.mod64 = function(x,y) { return x.mod64(y); };
    1.83 -    b.and64 = function(x,y) { return x.and64(y); };
    1.84 -    b.or64 = function(x,y) { return x.or64(y); };
    1.85 -    b.xor64 = function(x,y) { return x.xor64(y); };
    1.86 +    b.mod64 = mod64;
    1.87 +    b.and64 = and64;
    1.88 +    b.or64 = or64;
    1.89 +    b.xor64 = xor64;
    1.90      b.neg64 = function(x) { return x.neg64(); };
    1.91      b.shl64 = function(x,y) { return x.shl64(y); };
    1.92      b.shr64 = function(x,y) { return x.shr64(y); };