| 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 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
| 10 | 10 |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 from = high_start; | 977 from = high_start; |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 }; | 980 }; |
| 981 | 981 |
| 982 // Copy elements in the range 0..length from obj's prototype chain | 982 // Copy elements in the range 0..length from obj's prototype chain |
| 983 // to obj itself, if obj has holes. Return one more than the maximal index | 983 // to obj itself, if obj has holes. Return one more than the maximal index |
| 984 // of a prototype property. | 984 // of a prototype property. |
| 985 var CopyFromPrototype = function CopyFromPrototype(obj, length) { | 985 var CopyFromPrototype = function CopyFromPrototype(obj, length) { |
| 986 var max = 0; | 986 var max = 0; |
| 987 for (var proto = %GetPrototype(obj); proto; proto = %GetPrototype(proto)) { | 987 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ |
| 988 var indices = %GetArrayKeys(proto, length); | 988 var indices = %GetArrayKeys(proto, length); |
| 989 if (IS_NUMBER(indices)) { | 989 if (IS_NUMBER(indices)) { |
| 990 // It's an interval. | 990 // It's an interval. |
| 991 var proto_length = indices; | 991 var proto_length = indices; |
| 992 for (var i = 0; i < proto_length; i++) { | 992 for (var i = 0; i < proto_length; i++) { |
| 993 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { | 993 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { |
| 994 obj[i] = proto[i]; | 994 obj[i] = proto[i]; |
| 995 if (i >= max) { max = i + 1; } | 995 if (i >= max) { max = i + 1; } |
| 996 } | 996 } |
| 997 } | 997 } |
| 998 } else { | 998 } else { |
| 999 for (var i = 0; i < indices.length; i++) { | 999 for (var i = 0; i < indices.length; i++) { |
| 1000 var index = indices[i]; | 1000 var index = indices[i]; |
| 1001 if (!IS_UNDEFINED(index) && !HAS_OWN_PROPERTY(obj, index) | 1001 if (!IS_UNDEFINED(index) && !HAS_OWN_PROPERTY(obj, index) |
| 1002 && HAS_OWN_PROPERTY(proto, index)) { | 1002 && HAS_OWN_PROPERTY(proto, index)) { |
| 1003 obj[index] = proto[index]; | 1003 obj[index] = proto[index]; |
| 1004 if (index >= max) { max = index + 1; } | 1004 if (index >= max) { max = index + 1; } |
| 1005 } | 1005 } |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 } | 1008 } |
| 1009 return max; | 1009 return max; |
| 1010 }; | 1010 }; |
| 1011 | 1011 |
| 1012 // Set a value of "undefined" on all indices in the range from..to | 1012 // Set a value of "undefined" on all indices in the range from..to |
| 1013 // where a prototype of obj has an element. I.e., shadow all prototype | 1013 // where a prototype of obj has an element. I.e., shadow all prototype |
| 1014 // elements in that range. | 1014 // elements in that range. |
| 1015 var ShadowPrototypeElements = function(obj, from, to) { | 1015 var ShadowPrototypeElements = function(obj, from, to) { |
| 1016 for (var proto = %GetPrototype(obj); proto; proto = %GetPrototype(proto)) { | 1016 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto))
{ |
| 1017 var indices = %GetArrayKeys(proto, to); | 1017 var indices = %GetArrayKeys(proto, to); |
| 1018 if (IS_NUMBER(indices)) { | 1018 if (IS_NUMBER(indices)) { |
| 1019 // It's an interval. | 1019 // It's an interval. |
| 1020 var proto_length = indices; | 1020 var proto_length = indices; |
| 1021 for (var i = from; i < proto_length; i++) { | 1021 for (var i = from; i < proto_length; i++) { |
| 1022 if (HAS_OWN_PROPERTY(proto, i)) { | 1022 if (HAS_OWN_PROPERTY(proto, i)) { |
| 1023 obj[i] = UNDEFINED; | 1023 obj[i] = UNDEFINED; |
| 1024 } | 1024 } |
| 1025 } | 1025 } |
| 1026 } else { | 1026 } else { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 // of defined elements. | 1074 // of defined elements. |
| 1075 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; | 1075 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; |
| 1076 // Fill in the undefineds and the holes. There may be a hole where | 1076 // Fill in the undefineds and the holes. There may be a hole where |
| 1077 // an undefined should be and vice versa. | 1077 // an undefined should be and vice versa. |
| 1078 var i; | 1078 var i; |
| 1079 for (i = first_undefined; i < length - num_holes; i++) { | 1079 for (i = first_undefined; i < length - num_holes; i++) { |
| 1080 obj[i] = UNDEFINED; | 1080 obj[i] = UNDEFINED; |
| 1081 } | 1081 } |
| 1082 for (i = length - num_holes; i < length; i++) { | 1082 for (i = length - num_holes; i < length; i++) { |
| 1083 // For compatability with Webkit, do not expose elements in the prototype. | 1083 // For compatability with Webkit, do not expose elements in the prototype. |
| 1084 if (i in %GetPrototype(obj)) { | 1084 if (i in %_GetPrototype(obj)) { |
| 1085 obj[i] = UNDEFINED; | 1085 obj[i] = UNDEFINED; |
| 1086 } else { | 1086 } else { |
| 1087 delete obj[i]; | 1087 delete obj[i]; |
| 1088 } | 1088 } |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 // Return the number of defined elements. | 1091 // Return the number of defined elements. |
| 1092 return first_undefined; | 1092 return first_undefined; |
| 1093 }; | 1093 }; |
| 1094 | 1094 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 )); | 1581 )); |
| 1582 | 1582 |
| 1583 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1583 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
| 1584 "join", getFunction("join", ArrayJoin), | 1584 "join", getFunction("join", ArrayJoin), |
| 1585 "pop", getFunction("pop", ArrayPop), | 1585 "pop", getFunction("pop", ArrayPop), |
| 1586 "push", getFunction("push", ArrayPush) | 1586 "push", getFunction("push", ArrayPush) |
| 1587 )); | 1587 )); |
| 1588 } | 1588 } |
| 1589 | 1589 |
| 1590 SetUpArray(); | 1590 SetUpArray(); |
| OLD | NEW |