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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 672 |
673 built_in_array = new Array(1.5, 2, 3, 4, 5, 6); | 673 built_in_array = new Array(1.5, 2, 3, 4, 5, 6); |
674 assertEquals(1.5, goo(built_in_array, 0)); | 674 assertEquals(1.5, goo(built_in_array, 0)); |
675 assertEquals(1.5, goo(built_in_array, 0)); | 675 assertEquals(1.5, goo(built_in_array, 0)); |
676 %OptimizeFunctionOnNextCall(goo); | 676 %OptimizeFunctionOnNextCall(goo); |
677 %OptimizeFunctionOnNextCall(boo); | 677 %OptimizeFunctionOnNextCall(boo); |
678 boo(built_in_array, 0, 2.5); | 678 boo(built_in_array, 0, 2.5); |
679 assertEquals(2.5, goo(built_in_array, 0)); | 679 assertEquals(2.5, goo(built_in_array, 0)); |
680 %ClearFunctionTypeFeedback(goo); | 680 %ClearFunctionTypeFeedback(goo); |
681 %ClearFunctionTypeFeedback(boo); | 681 %ClearFunctionTypeFeedback(boo); |
| 682 |
| 683 // Check all int range edge cases |
| 684 function checkRange() { |
| 685 var e32 = Math.pow(2,32); var e31 = Math.pow(2,31); |
| 686 var e16 = Math.pow(2,16); var e15 = Math.pow(2,15); |
| 687 var e8 = Math.pow(2,8); var e7 = Math.pow(2,7); |
| 688 var a7 = new Uint32Array(2); var a71 = new Int32Array(2); |
| 689 var a72 = new Uint16Array(2); var a73 = new Int16Array(2); |
| 690 var a74 = new Uint8Array(2); var a75 = new Int8Array(2); |
| 691 for (i = 1; i <= Math.pow(2,33); i *= 2) { |
| 692 var j = i-1; |
| 693 a7[0] = i; a71[0] = i; a72[0] = i; a73[0] = i; a74[0] = i; a75[0] = i; |
| 694 a7[1] = j; a71[1] = j; a72[1] = j; a73[1] = j; a74[1] = j; a75[1] = j; |
| 695 |
| 696 if (i < e32) { assertEquals(a7[0], i); } else { assertEquals(a7[0], 0); } |
| 697 if (j < e32) { assertEquals(a7[1], j); } else { assertEquals(a7[1],e32-1); } |
| 698 if (i < e31) { assertEquals(a71[0], i); } else { |
| 699 assertEquals(a71[0], (i < e32) ? -e31 : 0 ); } |
| 700 if (j < e31) { assertEquals(a71[1], j); } else { assertEquals(a71[1], -1); } |
| 701 |
| 702 if (i < e16) { assertEquals(a72[0], i); } else { assertEquals(a72[0], 0); } |
| 703 if (j < e16) { assertEquals(a72[1], j); } else { assertEquals(a72[1], e16-1)
; } |
| 704 if (i < e15) { assertEquals(a73[0], i); } else { |
| 705 assertEquals(a73[0], (i < e16) ? -e15 : 0 ); } |
| 706 if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } |
| 707 |
| 708 if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } |
| 709 if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1);
} |
| 710 if (i < e7) { assertEquals(a75[0], i); } else { |
| 711 assertEquals(a75[0], (i < e8) ? -e7 : 0); } |
| 712 if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } |
| 713 } |
| 714 } |
| 715 checkRange(); |
OLD | NEW |