| 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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } | 1049 } |
| 1050 } | 1050 } |
| 1051 }; | 1051 }; |
| 1052 | 1052 |
| 1053 // Copy elements in the range 0..length from obj's prototype chain | 1053 // Copy elements in the range 0..length from obj's prototype chain |
| 1054 // to obj itself, if obj has holes. Return one more than the maximal index | 1054 // to obj itself, if obj has holes. Return one more than the maximal index |
| 1055 // of a prototype property. | 1055 // of a prototype property. |
| 1056 var CopyFromPrototype = function CopyFromPrototype(obj, length) { | 1056 var CopyFromPrototype = function CopyFromPrototype(obj, length) { |
| 1057 var max = 0; | 1057 var max = 0; |
| 1058 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ | 1058 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ |
| 1059 var indices = %GetArrayKeys(proto, length); | 1059 var indices = IS_PROXY(proto) ? length : %GetArrayKeys(proto, length); |
| 1060 if (IS_NUMBER(indices)) { | 1060 if (IS_NUMBER(indices)) { |
| 1061 // It's an interval. | 1061 // It's an interval. |
| 1062 var proto_length = indices; | 1062 var proto_length = indices; |
| 1063 for (var i = 0; i < proto_length; i++) { | 1063 for (var i = 0; i < proto_length; i++) { |
| 1064 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { | 1064 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { |
| 1065 obj[i] = proto[i]; | 1065 obj[i] = proto[i]; |
| 1066 if (i >= max) { max = i + 1; } | 1066 if (i >= max) { max = i + 1; } |
| 1067 } | 1067 } |
| 1068 } | 1068 } |
| 1069 } else { | 1069 } else { |
| 1070 for (var i = 0; i < indices.length; i++) { | 1070 for (var i = 0; i < indices.length; i++) { |
| 1071 var index = indices[i]; | 1071 var index = indices[i]; |
| 1072 if (!IS_UNDEFINED(index) && !HAS_OWN_PROPERTY(obj, index) | 1072 if (!IS_UNDEFINED(index) && !HAS_OWN_PROPERTY(obj, index) |
| 1073 && HAS_OWN_PROPERTY(proto, index)) { | 1073 && HAS_OWN_PROPERTY(proto, index)) { |
| 1074 obj[index] = proto[index]; | 1074 obj[index] = proto[index]; |
| 1075 if (index >= max) { max = index + 1; } | 1075 if (index >= max) { max = index + 1; } |
| 1076 } | 1076 } |
| 1077 } | 1077 } |
| 1078 } | 1078 } |
| 1079 } | 1079 } |
| 1080 return max; | 1080 return max; |
| 1081 }; | 1081 }; |
| 1082 | 1082 |
| 1083 // Set a value of "undefined" on all indices in the range from..to | 1083 // Set a value of "undefined" on all indices in the range from..to |
| 1084 // where a prototype of obj has an element. I.e., shadow all prototype | 1084 // where a prototype of obj has an element. I.e., shadow all prototype |
| 1085 // elements in that range. | 1085 // elements in that range. |
| 1086 var ShadowPrototypeElements = function(obj, from, to) { | 1086 var ShadowPrototypeElements = function(obj, from, to) { |
| 1087 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ | 1087 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ |
| 1088 var indices = %GetArrayKeys(proto, to); | 1088 var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to); |
| 1089 if (IS_NUMBER(indices)) { | 1089 if (IS_NUMBER(indices)) { |
| 1090 // It's an interval. | 1090 // It's an interval. |
| 1091 var proto_length = indices; | 1091 var proto_length = indices; |
| 1092 for (var i = from; i < proto_length; i++) { | 1092 for (var i = from; i < proto_length; i++) { |
| 1093 if (HAS_OWN_PROPERTY(proto, i)) { | 1093 if (HAS_OWN_PROPERTY(proto, i)) { |
| 1094 obj[i] = UNDEFINED; | 1094 obj[i] = UNDEFINED; |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 } else { | 1097 } else { |
| 1098 for (var i = 0; i < indices.length; i++) { | 1098 for (var i = 0; i < indices.length; i++) { |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 %InstallToContext([ | 1951 %InstallToContext([ |
| 1952 "array_pop", ArrayPop, | 1952 "array_pop", ArrayPop, |
| 1953 "array_push", ArrayPush, | 1953 "array_push", ArrayPush, |
| 1954 "array_shift", ArrayShift, | 1954 "array_shift", ArrayShift, |
| 1955 "array_splice", ArraySplice, | 1955 "array_splice", ArraySplice, |
| 1956 "array_slice", ArraySlice, | 1956 "array_slice", ArraySlice, |
| 1957 "array_unshift", ArrayUnshift, | 1957 "array_unshift", ArrayUnshift, |
| 1958 ]); | 1958 ]); |
| 1959 | 1959 |
| 1960 }); | 1960 }); |
| OLD | NEW |