Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: src/js/array.js

Issue 1849723002: Version 5.0.71.27 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.0
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8-version.h ('k') | test/mjsunit/array-sort.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 });
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | test/mjsunit/array-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698