Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: mozilla-tests/js1_5/Regress/regress-452008.js

Issue 2865028: Update the mozilla tests to new version (as of 2010-06-29). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Name: svn:executable
+ *
OLDNEW
(Empty)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is JavaScript Engine testing utilities.
16 *
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s): Marco Fabbri
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 var gTestfile = 'regress-452008.js';
39 //-----------------------------------------------------------------------------
40 var BUGNUMBER = 452008;
41 var summary = 'Bad math with JIT';
42 var actual = '';
43 var expect = '';
44
45
46 //-----------------------------------------------------------------------------
47 test();
48 //-----------------------------------------------------------------------------
49
50 function test()
51 {
52 enterFunc ('test');
53 printBugNumber(BUGNUMBER);
54 printStatus (summary);
55
56 jit(true);
57
58 // regression test for Bug 452008 - TM: SRP in Clipperz crypto library fails whe n JIT (TraceMonkey) is enabled.
59
60 var x = [9385, 32112, 25383, 16317, 30138, 14565, 17812, 24500, 2719, 30174, 3 546, 9096, 15352, 19120, 20648, 14334, 7426, 0, 0, 0];
61 var n = [27875, 25925, 30422, 12227, 27798, 32170, 10873, 21748, 30629, 26296, 20697, 5125, 4815, 2221, 14392, 23369, 5560, 2, 0, 0];
62 var np = 18229;
63 var expected = [18770, 31456, 17999, 32635, 27508, 29131, 2856, 16233, 5439, 2 7580, 7093, 18192, 30804, 5472, 8529, 28649, 14852, 0, 0, 0];
64
65 //globals
66 bpe=0; //bits stored per array element
67 mask=0; //AND this with an array element to chop it down to bpe bits
68
69 //initialize the global variables
70 for (bpe=0; (1<<(bpe+1)) > (1<<bpe); bpe++); //bpe=number of bits in the mant issa on this platform
71 bpe>>=1; //bpe=number of bits in one element of the array re presenting the bigInt
72 mask=(1<<bpe)-1; //AND the mask with an integer to get its bpe least significant bits
73
74
75 //the following global variables are scratchpad memory to
76 //reduce dynamic memory allocation in the inner loop
77 sa = new Array(0); //used in mont_()
78
79 //do x=y on bigInts x and y. x must be an array at least as big as y (not count ing the leading zeros in y).
80 function copy_(x,y) {
81 var i;
82 var k=x.length<y.length ? x.length : y.length;
83 for (i=0;i<k;i++)
84 x[i]=y[i];
85 for (i=k;i<x.length;i++)
86 x[i]=0;
87 }
88
89 //do x=y on bigInt x and integer y.
90 function copyInt_(x,n) {
91 var i,c;
92 for (c=n,i=0;i<x.length;i++) {
93 x[i]=c & mask;
94 c>>=bpe;
95 }
96 }
97
98 //is x > y? (x and y both nonnegative)
99 function greater(x,y) {
100 var i;
101 var k=(x.length<y.length) ? x.length : y.length;
102
103 for (i=x.length;i<y.length;i++)
104 if (y[i])
105 return 0; //y has more digits
106
107 for (i=y.length;i<x.length;i++)
108 if (x[i])
109 return 1; //x has more digits
110
111 for (i=k-1;i>=0;i--)
112 if (x[i]>y[i])
113 return 1;
114 else if (x[i]<y[i])
115 return 0;
116 return 0;
117 }
118
119
120 //do x=x*y*Ri mod n for bigInts x,y,n,
121 // where Ri = 2**(-kn*bpe) mod n, and kn is the
122 // number of elements in the n array, not
123 // counting leading zeros.
124 //x must be large enough to hold the answer.
125 //It's OK if x and y are the same variable.
126 //must have:
127 // x,y < n
128 // n is odd
129 // np = -(n^(-1)) mod radix
130 function mont_(x,y,n,np) {
131 var i,j,c,ui,t;
132 var kn=n.length;
133 var ky=y.length;
134
135 if (sa.length!=kn)
136 sa=new Array(kn);
137
138 for (;kn>0 && n[kn-1]==0;kn--); //ignore leading zeros of n
139 for (;ky>0 && y[ky-1]==0;ky--); //ignore leading zeros of y
140
141 copyInt_(sa,0);
142
143 //the following loop consumes 95% of the runtime for randTruePrime_() and po wMod_() for large keys
144 for (i=0; i<kn; i++) {
145 t=sa[0]+x[i]*y[0];
146 ui=((t & mask) * np) & mask; //the inner "& mask" is needed on Macintosh MSIE, but not windows MSIE
147 c=(t+ui*n[0]) >> bpe;
148 t=x[i];
149
150 //do sa=(sa+x[i]*y+ui*n)/b where b=2**bpe
151 for (j=1;j<ky;j++) {
152 c+=sa[j]+t*y[j]+ui*n[j];
153 sa[j-1]=c & mask;
154 c>>=bpe;
155 }
156 for (;j<kn;j++) {
157 c+=sa[j]+ui*n[j];
158 sa[j-1]=c & mask;
159 c>>=bpe;
160 }
161 sa[j-1]=c & mask;
162 }
163
164 if (!greater(n,sa))
165 sub_(sa,n);
166 copy_(x,sa);
167 }
168
169 mont_(x, x, n, np);
170
171 var passed = expected.length == x.length;
172 for (var i = 0; i < expected.length; i++) {
173 if (passed)
174 passed = expected[i] == x[i];
175 }
176 print(passed);
177
178 jit(false);
179
180 expect = true;
181 actual = passed;
182
183 reportCompare(expect, actual, summary);
184
185 exitFunc ('test');
186 }
OLDNEW
« no previous file with comments | « mozilla-tests/js1_5/Regress/regress-451946.js ('k') | mozilla-tests/js1_5/Regress/regress-452170.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698