OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 a[i] = a[high_start]; | 702 a[i] = a[high_start]; |
703 a[high_start] = element; | 703 a[high_start] = element; |
704 } else { // order == 0 | 704 } else { // order == 0 |
705 i++; | 705 i++; |
706 } | 706 } |
707 } | 707 } |
708 QuickSort(a, from, low_end); | 708 QuickSort(a, from, low_end); |
709 QuickSort(a, high_start, to); | 709 QuickSort(a, high_start, to); |
710 } | 710 } |
711 | 711 |
| 712 var length; |
| 713 |
712 // Copies elements in the range 0..length from obj's prototype chain | 714 // Copies elements in the range 0..length from obj's prototype chain |
713 // to obj itself, if obj has holes. Returns one more than the maximal index | 715 // to obj itself, if obj has holes. Returns one more than the maximal index |
714 // of a prototype property. | 716 // of a prototype property. |
715 function CopyFromPrototype(obj, length) { | 717 function CopyFromPrototype(obj, length) { |
716 var max = 0; | 718 var max = 0; |
717 for (var proto = obj.__proto__; proto; proto = proto.__proto__) { | 719 for (var proto = obj.__proto__; proto; proto = proto.__proto__) { |
718 var indices = %GetArrayKeys(proto, length); | 720 var indices = %GetArrayKeys(proto, length); |
719 if (indices.length > 0) { | 721 if (indices.length > 0) { |
720 if (indices[0] == -1) { | 722 if (indices[0] == -1) { |
721 // It's an interval. | 723 // It's an interval. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 obj[i] = void 0; | 821 obj[i] = void 0; |
820 } else { | 822 } else { |
821 delete obj[i]; | 823 delete obj[i]; |
822 } | 824 } |
823 } | 825 } |
824 | 826 |
825 // Return the number of defined elements. | 827 // Return the number of defined elements. |
826 return first_undefined; | 828 return first_undefined; |
827 } | 829 } |
828 | 830 |
829 var length = ToUint32(this.length); | 831 length = ToUint32(this.length); |
830 if (length < 2) return this; | 832 if (length < 2) return this; |
831 | 833 |
832 var is_array = IS_ARRAY(this); | 834 var is_array = IS_ARRAY(this); |
833 var max_prototype_element; | 835 var max_prototype_element; |
834 if (!is_array) { | 836 if (!is_array) { |
835 // For compatibility with JSC, we also sort elements inherited from | 837 // For compatibility with JSC, we also sort elements inherited from |
836 // the prototype chain on non-Array objects. | 838 // the prototype chain on non-Array objects. |
837 // We do this by copying them to this object and sorting only | 839 // We do this by copying them to this object and sorting only |
838 // local elements. This is not very efficient, but sorting with | 840 // local elements. This is not very efficient, but sorting with |
839 // inherited elements happens very, very rarely, if at all. | 841 // inherited elements happens very, very rarely, if at all. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 ArrayIndexOf: 1, | 1111 ArrayIndexOf: 1, |
1110 ArrayLastIndexOf: 1, | 1112 ArrayLastIndexOf: 1, |
1111 ArrayPush: 1, | 1113 ArrayPush: 1, |
1112 ArrayReduce: 1, | 1114 ArrayReduce: 1, |
1113 ArrayReduceRight: 1 | 1115 ArrayReduceRight: 1 |
1114 }); | 1116 }); |
1115 } | 1117 } |
1116 | 1118 |
1117 | 1119 |
1118 SetupArray(); | 1120 SetupArray(); |
OLD | NEW |