OLD | NEW |
(Empty) | |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 var x; |
| 29 |
| 30 // Converts a number to string respecting -0. |
| 31 function stringify(n) { |
| 32 if ((1 / n) === -Infinity) return "-0"; |
| 33 return String(n); |
| 34 } |
| 35 |
| 36 function f(expected, y) { |
| 37 function testEval(string, x, y) { |
| 38 var mulFunction = Function("x, y", "return " + string); |
| 39 return mulFunction(x, y); |
| 40 } |
| 41 function mulTest(expected, x, y) { |
| 42 assertEquals(expected, x * y); |
| 43 assertEquals(expected, testEval(stringify(x) + " * y", x, y)); |
| 44 assertEquals(expected, testEval("x * " + stringify(y), x, y)); |
| 45 assertEquals(expected, testEval(stringify(x) + " * " + stringify(y), x, y)); |
| 46 } |
| 47 mulTest(expected, x, y); |
| 48 mulTest(-expected, -x, y); |
| 49 mulTest(-expected, x, -y); |
| 50 mulTest(expected, -x, -y); |
| 51 if (x === y) return; // Symmetric cases not necessary. |
| 52 mulTest(expected, y, x); |
| 53 mulTest(-expected, -y, x); |
| 54 mulTest(-expected, y, -x); |
| 55 mulTest(expected, -y, -x); |
| 56 } |
| 57 |
| 58 x = 8388607; |
| 59 f(0, 0); |
| 60 f(8388607, 1); |
| 61 f(16777214, 2); |
| 62 f(25165821, 3); |
| 63 f(33554428, 4); |
| 64 f(41943035, 5); |
| 65 f(58720249, 7); |
| 66 f(67108856, 8); |
| 67 f(75497463, 9); |
| 68 f(125829105, 15); |
| 69 f(134217712, 16); |
| 70 f(142606319, 17); |
| 71 f(260046817, 31); |
| 72 f(268435424, 32); |
| 73 f(276824031, 33); |
| 74 f(528482241, 63); |
| 75 f(536870848, 64); |
| 76 f(545259455, 65); |
| 77 f(1065353089, 127); |
| 78 f(1073741696, 128); |
| 79 f(1082130303, 129); |
| 80 f(2139094785, 255); |
| 81 f(2147483392, 256); |
| 82 f(2155871999, 257); |
| 83 f(4286578177, 511); |
| 84 f(4294966784, 512); |
| 85 f(4303355391, 513); |
| 86 f(8581544961, 1023); |
| 87 f(8589933568, 1024); |
| 88 f(8598322175, 1025); |
| 89 f(17171478529, 2047); |
| 90 f(17179867136, 2048); |
| 91 f(17188255743, 2049); |
| 92 f(34351345665, 4095); |
| 93 f(34359734272, 4096); |
| 94 f(34368122879, 4097); |
| 95 f(68711079937, 8191); |
| 96 f(68719468544, 8192); |
| 97 f(68727857151, 8193); |
| 98 f(137430548481, 16383); |
| 99 f(137438937088, 16384); |
| 100 f(137447325695, 16385); |
| 101 f(274869485569, 32767); |
| 102 f(274877874176, 32768); |
| 103 f(274886262783, 32769); |
| 104 f(549747359745, 65535); |
| 105 f(549755748352, 65536); |
| 106 f(549764136959, 65537); |
| 107 f(1099503108097, 131071); |
| 108 f(1099511496704, 131072); |
| 109 f(1099519885311, 131073); |
| 110 f(2199014604801, 262143); |
| 111 f(2199022993408, 262144); |
| 112 f(2199031382015, 262145); |
| 113 f(4398037598209, 524287); |
| 114 f(4398045986816, 524288); |
| 115 f(4398054375423, 524289); |
| 116 f(8796083585025, 1048575); |
| 117 f(8796091973632, 1048576); |
| 118 f(8796100362239, 1048577); |
| 119 f(17592175558657, 2097151); |
| 120 f(17592183947264, 2097152); |
| 121 f(17592192335871, 2097153); |
| 122 f(35184359505921, 4194303); |
| 123 f(35184367894528, 4194304); |
| 124 f(35184376283135, 4194305); |
| 125 f(70368727400449, 8388607); |
| 126 x = 8388608; |
| 127 f(0, 0); |
| 128 f(8388608, 1); |
| 129 f(16777216, 2); |
| 130 f(25165824, 3); |
| 131 f(33554432, 4); |
| 132 f(41943040, 5); |
| 133 f(58720256, 7); |
| 134 f(67108864, 8); |
| 135 f(75497472, 9); |
| 136 f(125829120, 15); |
| 137 f(134217728, 16); |
| 138 f(142606336, 17); |
| 139 f(260046848, 31); |
| 140 f(268435456, 32); |
| 141 f(276824064, 33); |
| 142 f(528482304, 63); |
| 143 f(536870912, 64); |
| 144 f(545259520, 65); |
| 145 f(1065353216, 127); |
| 146 f(1073741824, 128); |
| 147 f(1082130432, 129); |
| 148 f(2139095040, 255); |
| 149 f(2147483648, 256); |
| 150 f(2155872256, 257); |
| 151 f(4286578688, 511); |
| 152 f(4294967296, 512); |
| 153 f(4303355904, 513); |
| 154 f(8581545984, 1023); |
| 155 f(8589934592, 1024); |
| 156 f(8598323200, 1025); |
| 157 f(17171480576, 2047); |
| 158 f(17179869184, 2048); |
| 159 f(17188257792, 2049); |
| 160 f(34351349760, 4095); |
| 161 f(34359738368, 4096); |
| 162 f(34368126976, 4097); |
| 163 f(68711088128, 8191); |
| 164 f(68719476736, 8192); |
| 165 f(68727865344, 8193); |
| 166 f(137430564864, 16383); |
| 167 f(137438953472, 16384); |
| 168 f(137447342080, 16385); |
| 169 f(274869518336, 32767); |
| 170 f(274877906944, 32768); |
| 171 f(274886295552, 32769); |
| 172 f(549747425280, 65535); |
| 173 f(549755813888, 65536); |
| 174 f(549764202496, 65537); |
| 175 f(1099503239168, 131071); |
| 176 f(1099511627776, 131072); |
| 177 f(1099520016384, 131073); |
| 178 f(2199014866944, 262143); |
| 179 f(2199023255552, 262144); |
| 180 f(2199031644160, 262145); |
| 181 f(4398038122496, 524287); |
| 182 f(4398046511104, 524288); |
| 183 f(4398054899712, 524289); |
| 184 f(8796084633600, 1048575); |
| 185 f(8796093022208, 1048576); |
| 186 f(8796101410816, 1048577); |
| 187 f(17592177655808, 2097151); |
| 188 f(17592186044416, 2097152); |
| 189 f(17592194433024, 2097153); |
| 190 f(35184363700224, 4194303); |
| 191 f(35184372088832, 4194304); |
| 192 f(35184380477440, 4194305); |
| 193 f(70368735789056, 8388607); |
| 194 f(70368744177664, 8388608); |
| 195 x = 8388609; |
| 196 f(0, 0); |
| 197 f(8388609, 1); |
| 198 f(16777218, 2); |
| 199 f(25165827, 3); |
| 200 f(33554436, 4); |
| 201 f(41943045, 5); |
| 202 f(58720263, 7); |
| 203 f(67108872, 8); |
| 204 f(75497481, 9); |
| 205 f(125829135, 15); |
| 206 f(134217744, 16); |
| 207 f(142606353, 17); |
| 208 f(260046879, 31); |
| 209 f(268435488, 32); |
| 210 f(276824097, 33); |
| 211 f(528482367, 63); |
| 212 f(536870976, 64); |
| 213 f(545259585, 65); |
| 214 f(1065353343, 127); |
| 215 f(1073741952, 128); |
| 216 f(1082130561, 129); |
| 217 f(2139095295, 255); |
| 218 f(2147483904, 256); |
| 219 f(2155872513, 257); |
| 220 f(4286579199, 511); |
| 221 f(4294967808, 512); |
| 222 f(4303356417, 513); |
| 223 f(8581547007, 1023); |
| 224 f(8589935616, 1024); |
| 225 f(8598324225, 1025); |
| 226 f(17171482623, 2047); |
| 227 f(17179871232, 2048); |
| 228 f(17188259841, 2049); |
| 229 f(34351353855, 4095); |
| 230 f(34359742464, 4096); |
| 231 f(34368131073, 4097); |
| 232 f(68711096319, 8191); |
| 233 f(68719484928, 8192); |
| 234 f(68727873537, 8193); |
| 235 f(137430581247, 16383); |
| 236 f(137438969856, 16384); |
| 237 f(137447358465, 16385); |
| 238 f(274869551103, 32767); |
| 239 f(274877939712, 32768); |
| 240 f(274886328321, 32769); |
| 241 f(549747490815, 65535); |
| 242 f(549755879424, 65536); |
| 243 f(549764268033, 65537); |
| 244 f(1099503370239, 131071); |
| 245 f(1099511758848, 131072); |
| 246 f(1099520147457, 131073); |
| 247 f(2199015129087, 262143); |
| 248 f(2199023517696, 262144); |
| 249 f(2199031906305, 262145); |
| 250 f(4398038646783, 524287); |
| 251 f(4398047035392, 524288); |
| 252 f(4398055424001, 524289); |
| 253 f(8796085682175, 1048575); |
| 254 f(8796094070784, 1048576); |
| 255 f(8796102459393, 1048577); |
| 256 f(17592179752959, 2097151); |
| 257 f(17592188141568, 2097152); |
| 258 f(17592196530177, 2097153); |
| 259 f(35184367894527, 4194303); |
| 260 f(35184376283136, 4194304); |
| 261 f(35184384671745, 4194305); |
| 262 f(70368744177663, 8388607); |
| 263 f(70368752566272, 8388608); |
| 264 f(70368760954881, 8388609); |
| 265 x = 16777215; |
| 266 f(0, 0); |
| 267 f(16777215, 1); |
| 268 f(33554430, 2); |
| 269 f(50331645, 3); |
| 270 f(67108860, 4); |
| 271 f(83886075, 5); |
| 272 f(117440505, 7); |
| 273 f(134217720, 8); |
| 274 f(150994935, 9); |
| 275 f(251658225, 15); |
| 276 f(268435440, 16); |
| 277 f(285212655, 17); |
| 278 f(520093665, 31); |
| 279 f(536870880, 32); |
| 280 f(553648095, 33); |
| 281 f(1056964545, 63); |
| 282 f(1073741760, 64); |
| 283 f(1090518975, 65); |
| 284 f(2130706305, 127); |
| 285 f(2147483520, 128); |
| 286 f(2164260735, 129); |
| 287 f(4278189825, 255); |
| 288 f(4294967040, 256); |
| 289 f(4311744255, 257); |
| 290 f(8573156865, 511); |
| 291 f(8589934080, 512); |
| 292 f(8606711295, 513); |
| 293 f(17163090945, 1023); |
| 294 f(17179868160, 1024); |
| 295 f(17196645375, 1025); |
| 296 f(34342959105, 2047); |
| 297 f(34359736320, 2048); |
| 298 f(34376513535, 2049); |
| 299 f(68702695425, 4095); |
| 300 f(68719472640, 4096); |
| 301 f(68736249855, 4097); |
| 302 f(137422168065, 8191); |
| 303 f(137438945280, 8192); |
| 304 f(137455722495, 8193); |
| 305 f(274861113345, 16383); |
| 306 f(274877890560, 16384); |
| 307 f(274894667775, 16385); |
| 308 f(549739003905, 32767); |
| 309 f(549755781120, 32768); |
| 310 f(549772558335, 32769); |
| 311 f(1099494785025, 65535); |
| 312 f(1099511562240, 65536); |
| 313 f(1099528339455, 65537); |
| 314 f(2199006347265, 131071); |
| 315 f(2199023124480, 131072); |
| 316 f(2199039901695, 131073); |
| 317 f(4398029471745, 262143); |
| 318 f(4398046248960, 262144); |
| 319 f(4398063026175, 262145); |
| 320 f(8796075720705, 524287); |
| 321 f(8796092497920, 524288); |
| 322 f(8796109275135, 524289); |
| 323 f(17592168218625, 1048575); |
| 324 f(17592184995840, 1048576); |
| 325 f(17592201773055, 1048577); |
| 326 f(35184353214465, 2097151); |
| 327 f(35184369991680, 2097152); |
| 328 f(35184386768895, 2097153); |
| 329 f(70368723206145, 4194303); |
| 330 f(70368739983360, 4194304); |
| 331 f(70368756760575, 4194305); |
| 332 f(140737463189505, 8388607); |
| 333 f(140737479966720, 8388608); |
| 334 f(140737496743935, 8388609); |
| 335 f(281474943156225, 16777215); |
| 336 x = 16777216; |
| 337 f(0, 0); |
| 338 f(16777216, 1); |
| 339 f(33554432, 2); |
| 340 f(50331648, 3); |
| 341 f(67108864, 4); |
| 342 f(83886080, 5); |
| 343 f(117440512, 7); |
| 344 f(134217728, 8); |
| 345 f(150994944, 9); |
| 346 f(251658240, 15); |
| 347 f(268435456, 16); |
| 348 f(285212672, 17); |
| 349 f(520093696, 31); |
| 350 f(536870912, 32); |
| 351 f(553648128, 33); |
| 352 f(1056964608, 63); |
| 353 f(1073741824, 64); |
| 354 f(1090519040, 65); |
| 355 f(2130706432, 127); |
| 356 f(2147483648, 128); |
| 357 f(2164260864, 129); |
| 358 f(4278190080, 255); |
| 359 f(4294967296, 256); |
| 360 f(4311744512, 257); |
| 361 f(8573157376, 511); |
| 362 f(8589934592, 512); |
| 363 f(8606711808, 513); |
| 364 f(17163091968, 1023); |
| 365 f(17179869184, 1024); |
| 366 f(17196646400, 1025); |
| 367 f(34342961152, 2047); |
| 368 f(34359738368, 2048); |
| 369 f(34376515584, 2049); |
| 370 f(68702699520, 4095); |
| 371 f(68719476736, 4096); |
| 372 f(68736253952, 4097); |
| 373 f(137422176256, 8191); |
| 374 f(137438953472, 8192); |
| 375 f(137455730688, 8193); |
| 376 f(274861129728, 16383); |
| 377 f(274877906944, 16384); |
| 378 f(274894684160, 16385); |
| 379 f(549739036672, 32767); |
| 380 f(549755813888, 32768); |
| 381 f(549772591104, 32769); |
| 382 f(1099494850560, 65535); |
| 383 f(1099511627776, 65536); |
| 384 f(1099528404992, 65537); |
| 385 f(2199006478336, 131071); |
| 386 f(2199023255552, 131072); |
| 387 f(2199040032768, 131073); |
| 388 f(4398029733888, 262143); |
| 389 f(4398046511104, 262144); |
| 390 f(4398063288320, 262145); |
| 391 f(8796076244992, 524287); |
| 392 f(8796093022208, 524288); |
| 393 f(8796109799424, 524289); |
| 394 f(17592169267200, 1048575); |
| 395 f(17592186044416, 1048576); |
| 396 f(17592202821632, 1048577); |
| 397 f(35184355311616, 2097151); |
| 398 f(35184372088832, 2097152); |
| 399 f(35184388866048, 2097153); |
| 400 f(70368727400448, 4194303); |
| 401 f(70368744177664, 4194304); |
| 402 f(70368760954880, 4194305); |
| 403 f(140737471578112, 8388607); |
| 404 f(140737488355328, 8388608); |
| 405 f(140737505132544, 8388609); |
| 406 f(281474959933440, 16777215); |
| 407 f(281474976710656, 16777216); |
| 408 x = 16777217; |
| 409 f(0, 0); |
| 410 f(16777217, 1); |
| 411 f(33554434, 2); |
| 412 f(50331651, 3); |
| 413 f(67108868, 4); |
| 414 f(83886085, 5); |
| 415 f(117440519, 7); |
| 416 f(134217736, 8); |
| 417 f(150994953, 9); |
| 418 f(251658255, 15); |
| 419 f(268435472, 16); |
| 420 f(285212689, 17); |
| 421 f(520093727, 31); |
| 422 f(536870944, 32); |
| 423 f(553648161, 33); |
| 424 f(1056964671, 63); |
| 425 f(1073741888, 64); |
| 426 f(1090519105, 65); |
| 427 f(2130706559, 127); |
| 428 f(2147483776, 128); |
| 429 f(2164260993, 129); |
| 430 f(4278190335, 255); |
| 431 f(4294967552, 256); |
| 432 f(4311744769, 257); |
| 433 f(8573157887, 511); |
| 434 f(8589935104, 512); |
| 435 f(8606712321, 513); |
| 436 f(17163092991, 1023); |
| 437 f(17179870208, 1024); |
| 438 f(17196647425, 1025); |
| 439 f(34342963199, 2047); |
| 440 f(34359740416, 2048); |
| 441 f(34376517633, 2049); |
| 442 f(68702703615, 4095); |
| 443 f(68719480832, 4096); |
| 444 f(68736258049, 4097); |
| 445 f(137422184447, 8191); |
| 446 f(137438961664, 8192); |
| 447 f(137455738881, 8193); |
| 448 f(274861146111, 16383); |
| 449 f(274877923328, 16384); |
| 450 f(274894700545, 16385); |
| 451 f(549739069439, 32767); |
| 452 f(549755846656, 32768); |
| 453 f(549772623873, 32769); |
| 454 f(1099494916095, 65535); |
| 455 f(1099511693312, 65536); |
| 456 f(1099528470529, 65537); |
| 457 f(2199006609407, 131071); |
| 458 f(2199023386624, 131072); |
| 459 f(2199040163841, 131073); |
| 460 f(4398029996031, 262143); |
| 461 f(4398046773248, 262144); |
| 462 f(4398063550465, 262145); |
| 463 f(8796076769279, 524287); |
| 464 f(8796093546496, 524288); |
| 465 f(8796110323713, 524289); |
| 466 f(17592170315775, 1048575); |
| 467 f(17592187092992, 1048576); |
| 468 f(17592203870209, 1048577); |
| 469 f(35184357408767, 2097151); |
| 470 f(35184374185984, 2097152); |
| 471 f(35184390963201, 2097153); |
| 472 f(70368731594751, 4194303); |
| 473 f(70368748371968, 4194304); |
| 474 f(70368765149185, 4194305); |
| 475 f(140737479966719, 8388607); |
| 476 f(140737496743936, 8388608); |
| 477 f(140737513521153, 8388609); |
| 478 f(281474976710655, 16777215); |
| 479 f(281474993487872, 16777216); |
| 480 f(281475010265089, 16777217); |
| 481 x = 33554431; |
| 482 f(0, 0); |
| 483 f(33554431, 1); |
| 484 f(67108862, 2); |
| 485 f(100663293, 3); |
| 486 f(134217724, 4); |
| 487 f(167772155, 5); |
| 488 f(234881017, 7); |
| 489 f(268435448, 8); |
| 490 f(301989879, 9); |
| 491 f(503316465, 15); |
| 492 f(536870896, 16); |
| 493 f(570425327, 17); |
| 494 f(1040187361, 31); |
| 495 f(1073741792, 32); |
| 496 f(1107296223, 33); |
| 497 f(2113929153, 63); |
| 498 f(2147483584, 64); |
| 499 f(2181038015, 65); |
| 500 f(4261412737, 127); |
| 501 f(4294967168, 128); |
| 502 f(4328521599, 129); |
| 503 f(8556379905, 255); |
| 504 f(8589934336, 256); |
| 505 f(8623488767, 257); |
| 506 f(17146314241, 511); |
| 507 f(17179868672, 512); |
| 508 f(17213423103, 513); |
| 509 f(34326182913, 1023); |
| 510 f(34359737344, 1024); |
| 511 f(34393291775, 1025); |
| 512 f(68685920257, 2047); |
| 513 f(68719474688, 2048); |
| 514 f(68753029119, 2049); |
| 515 f(137405394945, 4095); |
| 516 f(137438949376, 4096); |
| 517 f(137472503807, 4097); |
| 518 f(274844344321, 8191); |
| 519 f(274877898752, 8192); |
| 520 f(274911453183, 8193); |
| 521 f(549722243073, 16383); |
| 522 f(549755797504, 16384); |
| 523 f(549789351935, 16385); |
| 524 f(1099478040577, 32767); |
| 525 f(1099511595008, 32768); |
| 526 f(1099545149439, 32769); |
| 527 f(2198989635585, 65535); |
| 528 f(2199023190016, 65536); |
| 529 f(2199056744447, 65537); |
| 530 f(4398012825601, 131071); |
| 531 f(4398046380032, 131072); |
| 532 f(4398079934463, 131073); |
| 533 f(8796059205633, 262143); |
| 534 f(8796092760064, 262144); |
| 535 f(8796126314495, 262145); |
| 536 f(17592151965697, 524287); |
| 537 f(17592185520128, 524288); |
| 538 f(17592219074559, 524289); |
| 539 f(35184337485825, 1048575); |
| 540 f(35184371040256, 1048576); |
| 541 f(35184404594687, 1048577); |
| 542 f(70368708526081, 2097151); |
| 543 f(70368742080512, 2097152); |
| 544 f(70368775634943, 2097153); |
| 545 f(140737450606593, 4194303); |
| 546 f(140737484161024, 4194304); |
| 547 f(140737517715455, 4194305); |
| 548 f(281474934767617, 8388607); |
| 549 f(281474968322048, 8388608); |
| 550 f(281475001876479, 8388609); |
| 551 f(562949903089665, 16777215); |
| 552 f(562949936644096, 16777216); |
| 553 f(562949970198527, 16777217); |
| 554 f(1125899839733761, 33554431); |
OLD | NEW |