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 var $arrayConcat; | 5 var $arrayConcat; |
6 var $arrayJoin; | 6 var $arrayJoin; |
7 var $arrayPush; | 7 var $arrayPush; |
8 var $arrayPop; | 8 var $arrayPop; |
9 var $arrayShift; | 9 var $arrayShift; |
10 var $arraySlice; | 10 var $arraySlice; |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 if (x === y) return 0; | 865 if (x === y) return 0; |
866 if (%_IsSmi(x) && %_IsSmi(y)) { | 866 if (%_IsSmi(x) && %_IsSmi(y)) { |
867 return %SmiLexicographicCompare(x, y); | 867 return %SmiLexicographicCompare(x, y); |
868 } | 868 } |
869 x = ToString(x); | 869 x = ToString(x); |
870 y = ToString(y); | 870 y = ToString(y); |
871 if (x == y) return 0; | 871 if (x == y) return 0; |
872 else return x < y ? -1 : 1; | 872 else return x < y ? -1 : 1; |
873 }; | 873 }; |
874 } | 874 } |
875 var receiver = %GetDefaultReceiver(comparefn); | |
876 | |
877 var InsertionSort = function InsertionSort(a, from, to) { | 875 var InsertionSort = function InsertionSort(a, from, to) { |
878 for (var i = from + 1; i < to; i++) { | 876 for (var i = from + 1; i < to; i++) { |
879 var element = a[i]; | 877 var element = a[i]; |
880 for (var j = i - 1; j >= from; j--) { | 878 for (var j = i - 1; j >= from; j--) { |
881 var tmp = a[j]; | 879 var tmp = a[j]; |
882 var order = %_CallFunction(receiver, tmp, element, comparefn); | 880 var order = %_CallFunction(UNDEFINED, tmp, element, comparefn); |
883 if (order > 0) { | 881 if (order > 0) { |
884 a[j + 1] = tmp; | 882 a[j + 1] = tmp; |
885 } else { | 883 } else { |
886 break; | 884 break; |
887 } | 885 } |
888 } | 886 } |
889 a[j + 1] = element; | 887 a[j + 1] = element; |
890 } | 888 } |
891 }; | 889 }; |
892 | 890 |
893 var GetThirdIndex = function(a, from, to) { | 891 var GetThirdIndex = function(a, from, to) { |
894 var t_array = []; | 892 var t_array = []; |
895 // Use both 'from' and 'to' to determine the pivot candidates. | 893 // Use both 'from' and 'to' to determine the pivot candidates. |
896 var increment = 200 + ((to - from) & 15); | 894 var increment = 200 + ((to - from) & 15); |
897 for (var i = from + 1, j = 0; i < to - 1; i += increment, j++) { | 895 for (var i = from + 1, j = 0; i < to - 1; i += increment, j++) { |
898 t_array[j] = [i, a[i]]; | 896 t_array[j] = [i, a[i]]; |
899 } | 897 } |
900 %_CallFunction(t_array, function(a, b) { | 898 %_CallFunction(t_array, function(a, b) { |
901 return %_CallFunction(receiver, a[1], b[1], comparefn); | 899 return %_CallFunction(UNDEFINED, a[1], b[1], comparefn); |
902 }, ArraySort); | 900 }, ArraySort); |
903 var third_index = t_array[t_array.length >> 1][0]; | 901 var third_index = t_array[t_array.length >> 1][0]; |
904 return third_index; | 902 return third_index; |
905 } | 903 } |
906 | 904 |
907 var QuickSort = function QuickSort(a, from, to) { | 905 var QuickSort = function QuickSort(a, from, to) { |
908 var third_index = 0; | 906 var third_index = 0; |
909 while (true) { | 907 while (true) { |
910 // Insertion sort is faster for short arrays. | 908 // Insertion sort is faster for short arrays. |
911 if (to - from <= 10) { | 909 if (to - from <= 10) { |
912 InsertionSort(a, from, to); | 910 InsertionSort(a, from, to); |
913 return; | 911 return; |
914 } | 912 } |
915 if (to - from > 1000) { | 913 if (to - from > 1000) { |
916 third_index = GetThirdIndex(a, from, to); | 914 third_index = GetThirdIndex(a, from, to); |
917 } else { | 915 } else { |
918 third_index = from + ((to - from) >> 1); | 916 third_index = from + ((to - from) >> 1); |
919 } | 917 } |
920 // Find a pivot as the median of first, last and middle element. | 918 // Find a pivot as the median of first, last and middle element. |
921 var v0 = a[from]; | 919 var v0 = a[from]; |
922 var v1 = a[to - 1]; | 920 var v1 = a[to - 1]; |
923 var v2 = a[third_index]; | 921 var v2 = a[third_index]; |
924 var c01 = %_CallFunction(receiver, v0, v1, comparefn); | 922 var c01 = %_CallFunction(UNDEFINED, v0, v1, comparefn); |
925 if (c01 > 0) { | 923 if (c01 > 0) { |
926 // v1 < v0, so swap them. | 924 // v1 < v0, so swap them. |
927 var tmp = v0; | 925 var tmp = v0; |
928 v0 = v1; | 926 v0 = v1; |
929 v1 = tmp; | 927 v1 = tmp; |
930 } // v0 <= v1. | 928 } // v0 <= v1. |
931 var c02 = %_CallFunction(receiver, v0, v2, comparefn); | 929 var c02 = %_CallFunction(UNDEFINED, v0, v2, comparefn); |
932 if (c02 >= 0) { | 930 if (c02 >= 0) { |
933 // v2 <= v0 <= v1. | 931 // v2 <= v0 <= v1. |
934 var tmp = v0; | 932 var tmp = v0; |
935 v0 = v2; | 933 v0 = v2; |
936 v2 = v1; | 934 v2 = v1; |
937 v1 = tmp; | 935 v1 = tmp; |
938 } else { | 936 } else { |
939 // v0 <= v1 && v0 < v2 | 937 // v0 <= v1 && v0 < v2 |
940 var c12 = %_CallFunction(receiver, v1, v2, comparefn); | 938 var c12 = %_CallFunction(UNDEFINED, v1, v2, comparefn); |
941 if (c12 > 0) { | 939 if (c12 > 0) { |
942 // v0 <= v2 < v1 | 940 // v0 <= v2 < v1 |
943 var tmp = v1; | 941 var tmp = v1; |
944 v1 = v2; | 942 v1 = v2; |
945 v2 = tmp; | 943 v2 = tmp; |
946 } | 944 } |
947 } | 945 } |
948 // v0 <= v1 <= v2 | 946 // v0 <= v1 <= v2 |
949 a[from] = v0; | 947 a[from] = v0; |
950 a[to - 1] = v2; | 948 a[to - 1] = v2; |
951 var pivot = v1; | 949 var pivot = v1; |
952 var low_end = from + 1; // Upper bound of elements lower than pivot. | 950 var low_end = from + 1; // Upper bound of elements lower than pivot. |
953 var high_start = to - 1; // Lower bound of elements greater than pivot. | 951 var high_start = to - 1; // Lower bound of elements greater than pivot. |
954 a[third_index] = a[low_end]; | 952 a[third_index] = a[low_end]; |
955 a[low_end] = pivot; | 953 a[low_end] = pivot; |
956 | 954 |
957 // From low_end to i are elements equal to pivot. | 955 // From low_end to i are elements equal to pivot. |
958 // From i to high_start are elements that haven't been compared yet. | 956 // From i to high_start are elements that haven't been compared yet. |
959 partition: for (var i = low_end + 1; i < high_start; i++) { | 957 partition: for (var i = low_end + 1; i < high_start; i++) { |
960 var element = a[i]; | 958 var element = a[i]; |
961 var order = %_CallFunction(receiver, element, pivot, comparefn); | 959 var order = %_CallFunction(UNDEFINED, element, pivot, comparefn); |
962 if (order < 0) { | 960 if (order < 0) { |
963 a[i] = a[low_end]; | 961 a[i] = a[low_end]; |
964 a[low_end] = element; | 962 a[low_end] = element; |
965 low_end++; | 963 low_end++; |
966 } else if (order > 0) { | 964 } else if (order > 0) { |
967 do { | 965 do { |
968 high_start--; | 966 high_start--; |
969 if (high_start == i) break partition; | 967 if (high_start == i) break partition; |
970 var top_elem = a[high_start]; | 968 var top_elem = a[high_start]; |
971 order = %_CallFunction(receiver, top_elem, pivot, comparefn); | 969 order = %_CallFunction(UNDEFINED, top_elem, pivot, comparefn); |
972 } while (order > 0); | 970 } while (order > 0); |
973 a[i] = a[high_start]; | 971 a[i] = a[high_start]; |
974 a[high_start] = element; | 972 a[high_start] = element; |
975 if (order < 0) { | 973 if (order < 0) { |
976 element = a[i]; | 974 element = a[i]; |
977 a[i] = a[low_end]; | 975 a[i] = a[low_end]; |
978 a[low_end] = element; | 976 a[low_end] = element; |
979 low_end++; | 977 low_end++; |
980 } | 978 } |
981 } | 979 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 function ArrayFilter(f, receiver) { | 1146 function ArrayFilter(f, receiver) { |
1149 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); | 1147 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); |
1150 | 1148 |
1151 // Pull out the length so that modifications to the length in the | 1149 // Pull out the length so that modifications to the length in the |
1152 // loop will not affect the looping and side effects are visible. | 1150 // loop will not affect the looping and side effects are visible. |
1153 var array = ToObject(this); | 1151 var array = ToObject(this); |
1154 var length = ToUint32(array.length); | 1152 var length = ToUint32(array.length); |
1155 | 1153 |
1156 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1154 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1157 var needs_wrapper = false; | 1155 var needs_wrapper = false; |
1158 if (IS_NULL_OR_UNDEFINED(receiver)) { | 1156 if (IS_NULL(receiver)) { |
1159 receiver = %GetDefaultReceiver(f) || receiver; | 1157 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
1160 } else { | 1158 } else if (!IS_UNDEFINED(receiver)) { |
1161 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1159 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
1162 } | 1160 } |
1163 | 1161 |
1164 var result = new GlobalArray(); | 1162 var result = new GlobalArray(); |
1165 var accumulator = new InternalArray(); | 1163 var accumulator = new InternalArray(); |
1166 var accumulator_length = 0; | 1164 var accumulator_length = 0; |
1167 var is_array = IS_ARRAY(array); | 1165 var is_array = IS_ARRAY(array); |
1168 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1166 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
1169 for (var i = 0; i < length; i++) { | 1167 for (var i = 0; i < length; i++) { |
1170 if (HAS_INDEX(array, i, is_array)) { | 1168 if (HAS_INDEX(array, i, is_array)) { |
(...skipping 14 matching lines...) Expand all Loading... |
1185 function ArrayForEach(f, receiver) { | 1183 function ArrayForEach(f, receiver) { |
1186 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); | 1184 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); |
1187 | 1185 |
1188 // Pull out the length so that modifications to the length in the | 1186 // Pull out the length so that modifications to the length in the |
1189 // loop will not affect the looping and side effects are visible. | 1187 // loop will not affect the looping and side effects are visible. |
1190 var array = ToObject(this); | 1188 var array = ToObject(this); |
1191 var length = TO_UINT32(array.length); | 1189 var length = TO_UINT32(array.length); |
1192 | 1190 |
1193 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1191 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1194 var needs_wrapper = false; | 1192 var needs_wrapper = false; |
1195 if (IS_NULL_OR_UNDEFINED(receiver)) { | 1193 if (IS_NULL(receiver)) { |
1196 receiver = %GetDefaultReceiver(f) || receiver; | 1194 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
1197 } else { | 1195 } else if (!IS_UNDEFINED(receiver)) { |
1198 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1196 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
1199 } | 1197 } |
1200 | 1198 |
1201 var is_array = IS_ARRAY(array); | 1199 var is_array = IS_ARRAY(array); |
1202 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1200 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
1203 for (var i = 0; i < length; i++) { | 1201 for (var i = 0; i < length; i++) { |
1204 if (HAS_INDEX(array, i, is_array)) { | 1202 if (HAS_INDEX(array, i, is_array)) { |
1205 var element = array[i]; | 1203 var element = array[i]; |
1206 // Prepare break slots for debugger step in. | 1204 // Prepare break slots for debugger step in. |
1207 if (stepping) %DebugPrepareStepInIfStepping(f); | 1205 if (stepping) %DebugPrepareStepInIfStepping(f); |
1208 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 1206 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
1209 %_CallFunction(new_receiver, element, i, array, f); | 1207 %_CallFunction(new_receiver, element, i, array, f); |
1210 } | 1208 } |
1211 } | 1209 } |
1212 } | 1210 } |
1213 | 1211 |
1214 | 1212 |
1215 // Executes the function once for each element present in the | 1213 // Executes the function once for each element present in the |
1216 // array until it finds one where callback returns true. | 1214 // array until it finds one where callback returns true. |
1217 function ArraySome(f, receiver) { | 1215 function ArraySome(f, receiver) { |
1218 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); | 1216 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); |
1219 | 1217 |
1220 // Pull out the length so that modifications to the length in the | 1218 // Pull out the length so that modifications to the length in the |
1221 // loop will not affect the looping and side effects are visible. | 1219 // loop will not affect the looping and side effects are visible. |
1222 var array = ToObject(this); | 1220 var array = ToObject(this); |
1223 var length = TO_UINT32(array.length); | 1221 var length = TO_UINT32(array.length); |
1224 | 1222 |
1225 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1223 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1226 var needs_wrapper = false; | 1224 var needs_wrapper = false; |
1227 if (IS_NULL_OR_UNDEFINED(receiver)) { | 1225 if (IS_NULL(receiver)) { |
1228 receiver = %GetDefaultReceiver(f) || receiver; | 1226 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
1229 } else { | 1227 } else if (!IS_UNDEFINED(receiver)) { |
1230 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1228 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
1231 } | 1229 } |
1232 | 1230 |
1233 var is_array = IS_ARRAY(array); | 1231 var is_array = IS_ARRAY(array); |
1234 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1232 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
1235 for (var i = 0; i < length; i++) { | 1233 for (var i = 0; i < length; i++) { |
1236 if (HAS_INDEX(array, i, is_array)) { | 1234 if (HAS_INDEX(array, i, is_array)) { |
1237 var element = array[i]; | 1235 var element = array[i]; |
1238 // Prepare break slots for debugger step in. | 1236 // Prepare break slots for debugger step in. |
1239 if (stepping) %DebugPrepareStepInIfStepping(f); | 1237 if (stepping) %DebugPrepareStepInIfStepping(f); |
1240 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 1238 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
1241 if (%_CallFunction(new_receiver, element, i, array, f)) return true; | 1239 if (%_CallFunction(new_receiver, element, i, array, f)) return true; |
1242 } | 1240 } |
1243 } | 1241 } |
1244 return false; | 1242 return false; |
1245 } | 1243 } |
1246 | 1244 |
1247 | 1245 |
1248 function ArrayEvery(f, receiver) { | 1246 function ArrayEvery(f, receiver) { |
1249 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); | 1247 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); |
1250 | 1248 |
1251 // Pull out the length so that modifications to the length in the | 1249 // Pull out the length so that modifications to the length in the |
1252 // loop will not affect the looping and side effects are visible. | 1250 // loop will not affect the looping and side effects are visible. |
1253 var array = ToObject(this); | 1251 var array = ToObject(this); |
1254 var length = TO_UINT32(array.length); | 1252 var length = TO_UINT32(array.length); |
1255 | 1253 |
1256 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1254 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1257 var needs_wrapper = false; | 1255 var needs_wrapper = false; |
1258 if (IS_NULL_OR_UNDEFINED(receiver)) { | 1256 if (IS_NULL(receiver)) { |
1259 receiver = %GetDefaultReceiver(f) || receiver; | 1257 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
1260 } else { | 1258 } else if (!IS_UNDEFINED(receiver)) { |
1261 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1259 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
1262 } | 1260 } |
1263 | 1261 |
1264 var is_array = IS_ARRAY(array); | 1262 var is_array = IS_ARRAY(array); |
1265 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1263 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
1266 for (var i = 0; i < length; i++) { | 1264 for (var i = 0; i < length; i++) { |
1267 if (HAS_INDEX(array, i, is_array)) { | 1265 if (HAS_INDEX(array, i, is_array)) { |
1268 var element = array[i]; | 1266 var element = array[i]; |
1269 // Prepare break slots for debugger step in. | 1267 // Prepare break slots for debugger step in. |
1270 if (stepping) %DebugPrepareStepInIfStepping(f); | 1268 if (stepping) %DebugPrepareStepInIfStepping(f); |
1271 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 1269 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
1272 if (!%_CallFunction(new_receiver, element, i, array, f)) return false; | 1270 if (!%_CallFunction(new_receiver, element, i, array, f)) return false; |
1273 } | 1271 } |
1274 } | 1272 } |
1275 return true; | 1273 return true; |
1276 } | 1274 } |
1277 | 1275 |
1278 | 1276 |
1279 function ArrayMap(f, receiver) { | 1277 function ArrayMap(f, receiver) { |
1280 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); | 1278 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); |
1281 | 1279 |
1282 // Pull out the length so that modifications to the length in the | 1280 // Pull out the length so that modifications to the length in the |
1283 // loop will not affect the looping and side effects are visible. | 1281 // loop will not affect the looping and side effects are visible. |
1284 var array = ToObject(this); | 1282 var array = ToObject(this); |
1285 var length = TO_UINT32(array.length); | 1283 var length = TO_UINT32(array.length); |
1286 | 1284 |
1287 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1285 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1288 var needs_wrapper = false; | 1286 var needs_wrapper = false; |
1289 if (IS_NULL_OR_UNDEFINED(receiver)) { | 1287 if (IS_NULL(receiver)) { |
1290 receiver = %GetDefaultReceiver(f) || receiver; | 1288 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
1291 } else { | 1289 } else if (!IS_UNDEFINED(receiver)) { |
1292 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1290 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
1293 } | 1291 } |
1294 | 1292 |
1295 var result = new GlobalArray(); | 1293 var result = new GlobalArray(); |
1296 var accumulator = new InternalArray(length); | 1294 var accumulator = new InternalArray(length); |
1297 var is_array = IS_ARRAY(array); | 1295 var is_array = IS_ARRAY(array); |
1298 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1296 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
1299 for (var i = 0; i < length; i++) { | 1297 for (var i = 0; i < length; i++) { |
1300 if (HAS_INDEX(array, i, is_array)) { | 1298 if (HAS_INDEX(array, i, is_array)) { |
1301 var element = array[i]; | 1299 var element = array[i]; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 find_initial: if (%_ArgumentsLength() < 2) { | 1435 find_initial: if (%_ArgumentsLength() < 2) { |
1438 for (; i < length; i++) { | 1436 for (; i < length; i++) { |
1439 if (HAS_INDEX(array, i, is_array)) { | 1437 if (HAS_INDEX(array, i, is_array)) { |
1440 current = array[i++]; | 1438 current = array[i++]; |
1441 break find_initial; | 1439 break find_initial; |
1442 } | 1440 } |
1443 } | 1441 } |
1444 throw MakeTypeError(kReduceNoInitial); | 1442 throw MakeTypeError(kReduceNoInitial); |
1445 } | 1443 } |
1446 | 1444 |
1447 var receiver = %GetDefaultReceiver(callback); | |
1448 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1445 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
1449 for (; i < length; i++) { | 1446 for (; i < length; i++) { |
1450 if (HAS_INDEX(array, i, is_array)) { | 1447 if (HAS_INDEX(array, i, is_array)) { |
1451 var element = array[i]; | 1448 var element = array[i]; |
1452 // Prepare break slots for debugger step in. | 1449 // Prepare break slots for debugger step in. |
1453 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1450 if (stepping) %DebugPrepareStepInIfStepping(callback); |
1454 current = %_CallFunction(receiver, current, element, i, array, callback); | 1451 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
1455 } | 1452 } |
1456 } | 1453 } |
1457 return current; | 1454 return current; |
1458 } | 1455 } |
1459 | 1456 |
1460 | 1457 |
1461 function ArrayReduceRight(callback, current) { | 1458 function ArrayReduceRight(callback, current) { |
1462 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | 1459 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); |
1463 | 1460 |
1464 // Pull out the length so that side effects are visible before the | 1461 // Pull out the length so that side effects are visible before the |
(...skipping 10 matching lines...) Expand all Loading... |
1475 find_initial: if (%_ArgumentsLength() < 2) { | 1472 find_initial: if (%_ArgumentsLength() < 2) { |
1476 for (; i >= 0; i--) { | 1473 for (; i >= 0; i--) { |
1477 if (HAS_INDEX(array, i, is_array)) { | 1474 if (HAS_INDEX(array, i, is_array)) { |
1478 current = array[i--]; | 1475 current = array[i--]; |
1479 break find_initial; | 1476 break find_initial; |
1480 } | 1477 } |
1481 } | 1478 } |
1482 throw MakeTypeError(kReduceNoInitial); | 1479 throw MakeTypeError(kReduceNoInitial); |
1483 } | 1480 } |
1484 | 1481 |
1485 var receiver = %GetDefaultReceiver(callback); | |
1486 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1482 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
1487 for (; i >= 0; i--) { | 1483 for (; i >= 0; i--) { |
1488 if (HAS_INDEX(array, i, is_array)) { | 1484 if (HAS_INDEX(array, i, is_array)) { |
1489 var element = array[i]; | 1485 var element = array[i]; |
1490 // Prepare break slots for debugger step in. | 1486 // Prepare break slots for debugger step in. |
1491 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1487 if (stepping) %DebugPrepareStepInIfStepping(callback); |
1492 current = %_CallFunction(receiver, current, element, i, array, callback); | 1488 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
1493 } | 1489 } |
1494 } | 1490 } |
1495 return current; | 1491 return current; |
1496 } | 1492 } |
1497 | 1493 |
1498 // ES5, 15.4.3.2 | 1494 // ES5, 15.4.3.2 |
1499 function ArrayIsArray(obj) { | 1495 function ArrayIsArray(obj) { |
1500 return IS_ARRAY(obj); | 1496 return IS_ARRAY(obj); |
1501 } | 1497 } |
1502 | 1498 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 $arrayConcat = ArrayConcatJS; | 1589 $arrayConcat = ArrayConcatJS; |
1594 $arrayJoin = ArrayJoin; | 1590 $arrayJoin = ArrayJoin; |
1595 $arrayPush = ArrayPush; | 1591 $arrayPush = ArrayPush; |
1596 $arrayPop = ArrayPop; | 1592 $arrayPop = ArrayPop; |
1597 $arrayShift = ArrayShift; | 1593 $arrayShift = ArrayShift; |
1598 $arraySlice = ArraySlice; | 1594 $arraySlice = ArraySlice; |
1599 $arraySplice = ArraySplice; | 1595 $arraySplice = ArraySplice; |
1600 $arrayUnshift = ArrayUnshift; | 1596 $arrayUnshift = ArrayUnshift; |
1601 | 1597 |
1602 })(); | 1598 })(); |
OLD | NEW |