1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/gc/bug888463.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +var sjcl = { 1.5 + hash: {}, 1.6 +}; 1.7 +sjcl.bitArray = { 1.8 + concat: function (a, b) { 1.9 + var c = a[a.length - 1], 1.10 + d = sjcl.bitArray.getPartial(c); 1.11 + return d === 32 ? a.concat(b) : sjcl.bitArray.P(b, d, c | 0, a.slice(0, a.length - 1)) 1.12 + }, 1.13 + getPartial: function (a) { 1.14 + return Math.round(a / 0x10000000000) || 32 1.15 + } 1.16 +}; 1.17 +sjcl.hash.sha256 = function (a) { 1.18 + this.a[0] || this.w(); 1.19 + this.reset() 1.20 +}; 1.21 +sjcl.hash.sha256.prototype = { 1.22 + reset: function () { 1.23 + this.n = this.N.slice(0); 1.24 + this.i = []; 1.25 + }, 1.26 + update: function (a) { 1.27 + var b, c = this.i = sjcl.bitArray.concat(this.i, a); 1.28 + return this 1.29 + }, 1.30 + finalize: function () { 1.31 + var a, b = this.i, 1.32 + c = this.n; 1.33 + this.C(b.splice(0, 16)); 1.34 + return c 1.35 + }, 1.36 + N: [], 1.37 + a: [], 1.38 + w: function () { 1.39 + function a(e) { 1.40 + return (e - Math.floor(e)) * 0x100000000 | 0 1.41 + } 1.42 + var b = 0, 1.43 + c = 2, 1.44 + d; 1.45 + a: for (; b < 64; c++) { 1.46 + if (b < 8) 1.47 + this.N[b] = a(Math.pow(c, 0.5)); 1.48 + b++ 1.49 + } 1.50 + }, 1.51 + C: function (a) { 1.52 + var b, c, d = a.slice(0), 1.53 + e = this.n, 1.54 + h = e[1], 1.55 + i = e[2], 1.56 + k = e[3], 1.57 + n = e[7]; 1.58 + for (a = 0; a < 64; a++) { 1.59 + b = d[a + 1 & 15]; 1.60 + g = b + (h & i ^ k & (h ^ i)) + (h >>> 2 ^ h >>> 13 ^ h >>> 22 ^ h << 30 ^ h << 19 ^ h << 10) | 0 1.61 + } 1.62 + e[0] = e[0] + g | 0; 1.63 + } 1.64 +}; 1.65 +var ax1 = [-1862726214, -1544935945, -1650904951, -1523200565, 1783959997, -1422527763, -1915825893, 67249414]; 1.66 +var ax2 = ax1; 1.67 +for (var aix = 0; aix < 200; aix++) ax1 = (new sjcl.hash.sha256(undefined)).update(ax1, undefined).finalize(); 1.68 +eval("for (var aix = 0; aix < 200; aix++) ax2 = (new sjcl.hash.sha256(undefined)).update(ax2, undefined).finalize();" + 1.69 + "assertEq(ax2.toString(), ax1.toString());");