OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 from = high_start; | 891 from = high_start; |
892 } | 892 } |
893 } | 893 } |
894 }; | 894 }; |
895 | 895 |
896 // Copy elements in the range 0..length from obj's prototype chain | 896 // Copy elements in the range 0..length from obj's prototype chain |
897 // to obj itself, if obj has holes. Return one more than the maximal index | 897 // to obj itself, if obj has holes. Return one more than the maximal index |
898 // of a prototype property. | 898 // of a prototype property. |
899 var CopyFromPrototype = function CopyFromPrototype(obj, length) { | 899 var CopyFromPrototype = function CopyFromPrototype(obj, length) { |
900 var max = 0; | 900 var max = 0; |
901 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ | 901 for (var proto = %object_get_prototype_of(obj); proto; |
| 902 proto = %object_get_prototype_of(proto)) { |
902 var indices = IS_PROXY(proto) ? length : %GetArrayKeys(proto, length); | 903 var indices = IS_PROXY(proto) ? length : %GetArrayKeys(proto, length); |
903 if (IS_NUMBER(indices)) { | 904 if (IS_NUMBER(indices)) { |
904 // It's an interval. | 905 // It's an interval. |
905 var proto_length = indices; | 906 var proto_length = indices; |
906 for (var i = 0; i < proto_length; i++) { | 907 for (var i = 0; i < proto_length; i++) { |
907 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { | 908 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { |
908 obj[i] = proto[i]; | 909 obj[i] = proto[i]; |
909 if (i >= max) { max = i + 1; } | 910 if (i >= max) { max = i + 1; } |
910 } | 911 } |
911 } | 912 } |
912 } else { | 913 } else { |
913 for (var i = 0; i < indices.length; i++) { | 914 for (var i = 0; i < indices.length; i++) { |
914 var index = indices[i]; | 915 var index = indices[i]; |
915 if (!HAS_OWN_PROPERTY(obj, index) && HAS_OWN_PROPERTY(proto, index)) { | 916 if (!HAS_OWN_PROPERTY(obj, index) && HAS_OWN_PROPERTY(proto, index)) { |
916 obj[index] = proto[index]; | 917 obj[index] = proto[index]; |
917 if (index >= max) { max = index + 1; } | 918 if (index >= max) { max = index + 1; } |
918 } | 919 } |
919 } | 920 } |
920 } | 921 } |
921 } | 922 } |
922 return max; | 923 return max; |
923 }; | 924 }; |
924 | 925 |
925 // Set a value of "undefined" on all indices in the range from..to | 926 // Set a value of "undefined" on all indices in the range from..to |
926 // where a prototype of obj has an element. I.e., shadow all prototype | 927 // where a prototype of obj has an element. I.e., shadow all prototype |
927 // elements in that range. | 928 // elements in that range. |
928 var ShadowPrototypeElements = function(obj, from, to) { | 929 var ShadowPrototypeElements = function(obj, from, to) { |
929 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ | 930 for (var proto = %object_get_prototype_of(obj); proto; |
| 931 proto = %object_get_prototype_of(proto)) { |
930 var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to); | 932 var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to); |
931 if (IS_NUMBER(indices)) { | 933 if (IS_NUMBER(indices)) { |
932 // It's an interval. | 934 // It's an interval. |
933 var proto_length = indices; | 935 var proto_length = indices; |
934 for (var i = from; i < proto_length; i++) { | 936 for (var i = from; i < proto_length; i++) { |
935 if (HAS_OWN_PROPERTY(proto, i)) { | 937 if (HAS_OWN_PROPERTY(proto, i)) { |
936 obj[i] = UNDEFINED; | 938 obj[i] = UNDEFINED; |
937 } | 939 } |
938 } | 940 } |
939 } else { | 941 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 // of defined elements. | 988 // of defined elements. |
987 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; | 989 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; |
988 // Fill in the undefineds and the holes. There may be a hole where | 990 // Fill in the undefineds and the holes. There may be a hole where |
989 // an undefined should be and vice versa. | 991 // an undefined should be and vice versa. |
990 var i; | 992 var i; |
991 for (i = first_undefined; i < length - num_holes; i++) { | 993 for (i = first_undefined; i < length - num_holes; i++) { |
992 obj[i] = UNDEFINED; | 994 obj[i] = UNDEFINED; |
993 } | 995 } |
994 for (i = length - num_holes; i < length; i++) { | 996 for (i = length - num_holes; i < length; i++) { |
995 // For compatability with Webkit, do not expose elements in the prototype. | 997 // For compatability with Webkit, do not expose elements in the prototype. |
996 if (i in %_GetPrototype(obj)) { | 998 if (i in %object_get_prototype_of(obj)) { |
997 obj[i] = UNDEFINED; | 999 obj[i] = UNDEFINED; |
998 } else { | 1000 } else { |
999 delete obj[i]; | 1001 delete obj[i]; |
1000 } | 1002 } |
1001 } | 1003 } |
1002 | 1004 |
1003 // Return the number of defined elements. | 1005 // Return the number of defined elements. |
1004 return first_undefined; | 1006 return first_undefined; |
1005 }; | 1007 }; |
1006 | 1008 |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 %InstallToContext([ | 1796 %InstallToContext([ |
1795 "array_pop", ArrayPop, | 1797 "array_pop", ArrayPop, |
1796 "array_push", ArrayPush, | 1798 "array_push", ArrayPush, |
1797 "array_shift", ArrayShift, | 1799 "array_shift", ArrayShift, |
1798 "array_splice", ArraySplice, | 1800 "array_splice", ArraySplice, |
1799 "array_slice", ArraySlice, | 1801 "array_slice", ArraySlice, |
1800 "array_unshift", ArrayUnshift, | 1802 "array_unshift", ArrayUnshift, |
1801 ]); | 1803 ]); |
1802 | 1804 |
1803 }); | 1805 }); |
OLD | NEW |