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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 assertEquals(b0.byteLength, b1.byteLength) | 656 assertEquals(b0.byteLength, b1.byteLength) |
657 assertArrayPrefix([1, 2, 3, 4, 5, 6], Int8Array(b1)) | 657 assertArrayPrefix([1, 2, 3, 4, 5, 6], Int8Array(b1)) |
658 | 658 |
659 var b2 = b0.slice(3) | 659 var b2 = b0.slice(3) |
660 assertEquals(b0.byteLength - 3, b2.byteLength) | 660 assertEquals(b0.byteLength - 3, b2.byteLength) |
661 assertArrayPrefix([4, 5, 6], Int8Array(b2)) | 661 assertArrayPrefix([4, 5, 6], Int8Array(b2)) |
662 | 662 |
663 var b3 = b0.slice(2, 4) | 663 var b3 = b0.slice(2, 4) |
664 assertEquals(2, b3.byteLength) | 664 assertEquals(2, b3.byteLength) |
665 assertArrayPrefix([3, 4], Int8Array(b3)) | 665 assertArrayPrefix([3, 4], Int8Array(b3)) |
| 666 |
| 667 function goo(a, i) { |
| 668 return a[i]; |
| 669 } |
| 670 |
| 671 function boo(a, i, v) { |
| 672 return a[i] = v; |
| 673 } |
| 674 |
| 675 function do_tagged_index_external_array_test(constructor) { |
| 676 var t_array = new constructor([1, 2, 3, 4, 5, 6]); |
| 677 assertEquals(1, goo(t_array, 0)); |
| 678 assertEquals(1, goo(t_array, 0)); |
| 679 boo(t_array, 0, 13); |
| 680 assertEquals(13, goo(t_array, 0)); |
| 681 %OptimizeFunctionOnNextCall(goo); |
| 682 %OptimizeFunctionOnNextCall(boo); |
| 683 boo(t_array, 0, 15); |
| 684 assertEquals(15, goo(t_array, 0)); |
| 685 %ClearFunctionTypeFeedback(goo); |
| 686 %ClearFunctionTypeFeedback(boo); |
| 687 } |
| 688 |
| 689 do_tagged_index_external_array_test(Int8Array); |
| 690 do_tagged_index_external_array_test(Uint8Array); |
| 691 do_tagged_index_external_array_test(Int16Array); |
| 692 do_tagged_index_external_array_test(Uint16Array); |
| 693 do_tagged_index_external_array_test(Int32Array); |
| 694 do_tagged_index_external_array_test(Uint32Array); |
| 695 do_tagged_index_external_array_test(Float32Array); |
| 696 do_tagged_index_external_array_test(Float64Array); |
| 697 |
| 698 var built_in_array = new Array(1, 2, 3, 4, 5, 6); |
| 699 assertEquals(1, goo(built_in_array, 0)); |
| 700 assertEquals(1, goo(built_in_array, 0)); |
| 701 %OptimizeFunctionOnNextCall(goo); |
| 702 %OptimizeFunctionOnNextCall(boo); |
| 703 boo(built_in_array, 0, 11); |
| 704 assertEquals(11, goo(built_in_array, 0)); |
| 705 %ClearFunctionTypeFeedback(goo); |
| 706 %ClearFunctionTypeFeedback(boo); |
| 707 |
| 708 built_in_array = new Array(1.5, 2, 3, 4, 5, 6); |
| 709 assertEquals(1.5, goo(built_in_array, 0)); |
| 710 assertEquals(1.5, goo(built_in_array, 0)); |
| 711 %OptimizeFunctionOnNextCall(goo); |
| 712 %OptimizeFunctionOnNextCall(boo); |
| 713 boo(built_in_array, 0, 2.5); |
| 714 assertEquals(2.5, goo(built_in_array, 0)); |
| 715 %ClearFunctionTypeFeedback(goo); |
| 716 %ClearFunctionTypeFeedback(boo); |
OLD | NEW |