OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 assertEquals(-1, ROR4(-1, i)); | 215 assertEquals(-1, ROR4(-1, i)); |
216 } | 216 } |
217 | 217 |
218 for (var i = 0; i <= 100; i++) { | 218 for (var i = 0; i <= 100; i++) { |
219 assertEquals(1 << ((i % 32)), ROR4(1, i)); | 219 assertEquals(1 << ((i % 32)), ROR4(1, i)); |
220 assertEquals(1 << ((i % 32)), ROR4(1, i)); | 220 assertEquals(1 << ((i % 32)), ROR4(1, i)); |
221 %OptimizeFunctionOnNextCall(ROR4); | 221 %OptimizeFunctionOnNextCall(ROR4); |
222 assertEquals(1 << ((i % 32)), ROR4(1, i)); | 222 assertEquals(1 << ((i % 32)), ROR4(1, i)); |
223 } | 223 } |
224 | 224 |
| 225 //--------------------------------------------------------- |
| 226 // add test cases for constant operand |
| 227 //--------------------------------------------------------- |
| 228 // constant operand: 20 |
| 229 function ROR1_sa20(x) { |
| 230 return (x >>> 20) | (x << 12); |
| 231 } |
| 232 |
| 233 function ROR2_sa20(x) { |
| 234 return (x >>> 12) | (x << 20); |
| 235 } |
| 236 |
| 237 function ROR3_sa20(x, sa) { |
| 238 return (x << 12) | (x >>> 20); |
| 239 } |
| 240 |
| 241 function ROR4_sa20(x) { |
| 242 return (x << 20) | (x >>> 12); |
| 243 } |
| 244 |
| 245 // constant operand: 40 |
| 246 function ROR1_sa40(x) { |
| 247 return (x >>> 40) | (x << -8); |
| 248 } |
| 249 |
| 250 function ROR2_sa40(x) { |
| 251 return (x >>> -8) | (x << 40); |
| 252 } |
| 253 |
| 254 function ROR3_sa40(x, sa) { |
| 255 return (x << -8) | (x >>> 40); |
| 256 } |
| 257 |
| 258 function ROR4_sa40(x) { |
| 259 return (x << 40) | (x >>> -8); |
| 260 } |
| 261 |
| 262 // ROR1_sa20 |
| 263 assertEquals(ROR1(0x0000FFFF, 20), ROR1_sa20(0x0000FFFF)); |
| 264 assertEquals(ROR1(0x0000FFFF, 20), ROR1_sa20(0x0000FFFF)); |
| 265 %OptimizeFunctionOnNextCall(ROR1_sa20); |
| 266 assertEquals(ROR1(0x0000FFFF, 20), ROR1_sa20(0x0000FFFF)); |
| 267 |
| 268 // ROR1_sa40 |
| 269 assertEquals(ROR1(0x0000FFFF, 40), ROR1_sa40(0x0000FFFF)); |
| 270 assertEquals(ROR1(0x0000FFFF, 40), ROR1_sa40(0x0000FFFF)); |
| 271 %OptimizeFunctionOnNextCall(ROR1_sa40); |
| 272 assertEquals(ROR1(0x0000FFFF, 40), ROR1_sa40(0x0000FFFF)); |
| 273 |
| 274 // ROR2_sa20 |
| 275 assertEquals(ROR2(0xFFFFFFFF, 20), ROR2_sa20(0xFFFFFFFF)); |
| 276 assertEquals(ROR2(0xFFFFFFFF, 20), ROR2_sa20(0xFFFFFFFF)); |
| 277 %OptimizeFunctionOnNextCall(ROR2_sa20); |
| 278 assertEquals(ROR2(0xFFFFFFFF, 20), ROR2_sa20(0xFFFFFFFF)); |
| 279 |
| 280 // ROR2_sa40 |
| 281 assertEquals(ROR2(0x0000FFFF, 40), ROR2_sa40(0x0000FFFF)); |
| 282 assertEquals(ROR2(0x0000FFFF, 40), ROR2_sa40(0x0000FFFF)); |
| 283 %OptimizeFunctionOnNextCall(ROR2_sa40); |
| 284 assertEquals(ROR2(0x0000FFFF, 40), ROR2_sa40(0x0000FFFF)); |
| 285 |
| 286 // ROR3_sa20 |
| 287 assertEquals(ROR3(0x0000FFFF, 20), ROR3_sa20(0x0000FFFF)); |
| 288 assertEquals(ROR3(0x0000FFFF, 20), ROR3_sa20(0x0000FFFF)); |
| 289 %OptimizeFunctionOnNextCall(ROR3_sa20); |
| 290 assertEquals(ROR3(0x0000FFFF, 20), ROR3_sa20(0x0000FFFF)); |
| 291 |
| 292 // ROR3_sa40 |
| 293 assertEquals(ROR3(0x0000FFFF, 40), ROR3_sa40(0x0000FFFF)); |
| 294 assertEquals(ROR3(0x0000FFFF, 40), ROR3_sa40(0x0000FFFF)); |
| 295 %OptimizeFunctionOnNextCall(ROR3_sa40); |
| 296 assertEquals(ROR3(0x0000FFFF, 40), ROR3_sa40(0x0000FFFF)); |
| 297 |
| 298 // ROR4_sa20 |
| 299 assertEquals(ROR4(0x0000FFFF, 20), ROR4_sa20(0x0000FFFF)); |
| 300 assertEquals(ROR4(0x0000FFFF, 20), ROR4_sa20(0x0000FFFF)); |
| 301 %OptimizeFunctionOnNextCall(ROR4_sa20); |
| 302 assertEquals(ROR4(0x0000FFFF, 20), ROR4_sa20(0x0000FFFF)); |
| 303 |
| 304 // ROR4_sa40 |
| 305 assertEquals(ROR4(0xFFFFFFFF, 40), ROR4_sa40(0xFFFFFFFF)); |
| 306 assertEquals(ROR4(0xFFFFFFFF, 40), ROR4_sa40(0xFFFFFFFF)); |
| 307 %OptimizeFunctionOnNextCall(ROR4_sa40); |
| 308 assertEquals(ROR4(0xFFFFFFFF, 40), ROR4_sa40(0xFFFFFFFF)); |
| 309 |
| 310 |
OLD | NEW |