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

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

Issue 1404783002: Debugger: allow stepping into resolver from Promise constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | src/js/collection.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) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1172
1173 // The following functions cannot be made efficient on sparse arrays while 1173 // The following functions cannot be made efficient on sparse arrays while
1174 // preserving the semantics, since the calls to the receiver function can add 1174 // preserving the semantics, since the calls to the receiver function can add
1175 // or delete elements from the array. 1175 // or delete elements from the array.
1176 function InnerArrayFilter(f, receiver, array, length) { 1176 function InnerArrayFilter(f, receiver, array, length) {
1177 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1177 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
1178 1178
1179 var accumulator = new InternalArray(); 1179 var accumulator = new InternalArray();
1180 var accumulator_length = 0; 1180 var accumulator_length = 0;
1181 var is_array = IS_ARRAY(array); 1181 var is_array = IS_ARRAY(array);
1182 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1182 var stepping = DEBUG_IS_STEPPING(f);
1183 for (var i = 0; i < length; i++) { 1183 for (var i = 0; i < length; i++) {
1184 if (HAS_INDEX(array, i, is_array)) { 1184 if (HAS_INDEX(array, i, is_array)) {
1185 var element = array[i]; 1185 var element = array[i];
1186 // Prepare break slots for debugger step in. 1186 // Prepare break slots for debugger step in.
1187 if (stepping) %DebugPrepareStepInIfStepping(f); 1187 if (stepping) %DebugPrepareStepInIfStepping(f);
1188 if (%_Call(f, receiver, element, i, array)) { 1188 if (%_Call(f, receiver, element, i, array)) {
1189 accumulator[accumulator_length++] = element; 1189 accumulator[accumulator_length++] = element;
1190 } 1190 }
1191 } 1191 }
1192 } 1192 }
(...skipping 10 matching lines...) Expand all
1203 var accumulator = InnerArrayFilter(f, receiver, array, length); 1203 var accumulator = InnerArrayFilter(f, receiver, array, length);
1204 var result = new GlobalArray(); 1204 var result = new GlobalArray();
1205 %MoveArrayContents(accumulator, result); 1205 %MoveArrayContents(accumulator, result);
1206 return result; 1206 return result;
1207 } 1207 }
1208 1208
1209 function InnerArrayForEach(f, receiver, array, length) { 1209 function InnerArrayForEach(f, receiver, array, length) {
1210 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1210 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
1211 1211
1212 var is_array = IS_ARRAY(array); 1212 var is_array = IS_ARRAY(array);
1213 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1213 var stepping = DEBUG_IS_STEPPING(f);
1214 for (var i = 0; i < length; i++) { 1214 for (var i = 0; i < length; i++) {
1215 if (HAS_INDEX(array, i, is_array)) { 1215 if (HAS_INDEX(array, i, is_array)) {
1216 var element = array[i]; 1216 var element = array[i];
1217 // Prepare break slots for debugger step in. 1217 // Prepare break slots for debugger step in.
1218 if (stepping) %DebugPrepareStepInIfStepping(f); 1218 if (stepping) %DebugPrepareStepInIfStepping(f);
1219 %_Call(f, receiver, element, i, array); 1219 %_Call(f, receiver, element, i, array);
1220 } 1220 }
1221 } 1221 }
1222 } 1222 }
1223 1223
1224 function ArrayForEach(f, receiver) { 1224 function ArrayForEach(f, receiver) {
1225 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); 1225 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
1226 1226
1227 // Pull out the length so that modifications to the length in the 1227 // Pull out the length so that modifications to the length in the
1228 // loop will not affect the looping and side effects are visible. 1228 // loop will not affect the looping and side effects are visible.
1229 var array = TO_OBJECT(this); 1229 var array = TO_OBJECT(this);
1230 var length = TO_LENGTH_OR_UINT32(array.length); 1230 var length = TO_LENGTH_OR_UINT32(array.length);
1231 InnerArrayForEach(f, receiver, array, length); 1231 InnerArrayForEach(f, receiver, array, length);
1232 } 1232 }
1233 1233
1234 1234
1235 function InnerArraySome(f, receiver, array, length) { 1235 function InnerArraySome(f, receiver, array, length) {
1236 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1236 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
1237 1237
1238 var is_array = IS_ARRAY(array); 1238 var is_array = IS_ARRAY(array);
1239 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1239 var stepping = DEBUG_IS_STEPPING(f);
1240 for (var i = 0; i < length; i++) { 1240 for (var i = 0; i < length; i++) {
1241 if (HAS_INDEX(array, i, is_array)) { 1241 if (HAS_INDEX(array, i, is_array)) {
1242 var element = array[i]; 1242 var element = array[i];
1243 // Prepare break slots for debugger step in. 1243 // Prepare break slots for debugger step in.
1244 if (stepping) %DebugPrepareStepInIfStepping(f); 1244 if (stepping) %DebugPrepareStepInIfStepping(f);
1245 if (%_Call(f, receiver, element, i, array)) return true; 1245 if (%_Call(f, receiver, element, i, array)) return true;
1246 } 1246 }
1247 } 1247 }
1248 return false; 1248 return false;
1249 } 1249 }
1250 1250
1251 1251
1252 // Executes the function once for each element present in the 1252 // Executes the function once for each element present in the
1253 // array until it finds one where callback returns true. 1253 // array until it finds one where callback returns true.
1254 function ArraySome(f, receiver) { 1254 function ArraySome(f, receiver) {
1255 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); 1255 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
1256 1256
1257 // Pull out the length so that modifications to the length in the 1257 // Pull out the length so that modifications to the length in the
1258 // loop will not affect the looping and side effects are visible. 1258 // loop will not affect the looping and side effects are visible.
1259 var array = TO_OBJECT(this); 1259 var array = TO_OBJECT(this);
1260 var length = TO_LENGTH_OR_UINT32(array.length); 1260 var length = TO_LENGTH_OR_UINT32(array.length);
1261 return InnerArraySome(f, receiver, array, length); 1261 return InnerArraySome(f, receiver, array, length);
1262 } 1262 }
1263 1263
1264 1264
1265 function InnerArrayEvery(f, receiver, array, length) { 1265 function InnerArrayEvery(f, receiver, array, length) {
1266 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1266 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
1267 1267
1268 var is_array = IS_ARRAY(array); 1268 var is_array = IS_ARRAY(array);
1269 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1269 var stepping = DEBUG_IS_STEPPING(f);
1270 for (var i = 0; i < length; i++) { 1270 for (var i = 0; i < length; i++) {
1271 if (HAS_INDEX(array, i, is_array)) { 1271 if (HAS_INDEX(array, i, is_array)) {
1272 var element = array[i]; 1272 var element = array[i];
1273 // Prepare break slots for debugger step in. 1273 // Prepare break slots for debugger step in.
1274 if (stepping) %DebugPrepareStepInIfStepping(f); 1274 if (stepping) %DebugPrepareStepInIfStepping(f);
1275 if (!%_Call(f, receiver, element, i, array)) return false; 1275 if (!%_Call(f, receiver, element, i, array)) return false;
1276 } 1276 }
1277 } 1277 }
1278 return true; 1278 return true;
1279 } 1279 }
1280 1280
1281 function ArrayEvery(f, receiver) { 1281 function ArrayEvery(f, receiver) {
1282 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); 1282 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
1283 1283
1284 // Pull out the length so that modifications to the length in the 1284 // Pull out the length so that modifications to the length in the
1285 // loop will not affect the looping and side effects are visible. 1285 // loop will not affect the looping and side effects are visible.
1286 var array = TO_OBJECT(this); 1286 var array = TO_OBJECT(this);
1287 var length = TO_LENGTH_OR_UINT32(array.length); 1287 var length = TO_LENGTH_OR_UINT32(array.length);
1288 return InnerArrayEvery(f, receiver, array, length); 1288 return InnerArrayEvery(f, receiver, array, length);
1289 } 1289 }
1290 1290
1291 1291
1292 function InnerArrayMap(f, receiver, array, length) { 1292 function InnerArrayMap(f, receiver, array, length) {
1293 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1293 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
1294 1294
1295 var accumulator = new InternalArray(length); 1295 var accumulator = new InternalArray(length);
1296 var is_array = IS_ARRAY(array); 1296 var is_array = IS_ARRAY(array);
1297 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1297 var stepping = DEBUG_IS_STEPPING(f);
1298 for (var i = 0; i < length; i++) { 1298 for (var i = 0; i < length; i++) {
1299 if (HAS_INDEX(array, i, is_array)) { 1299 if (HAS_INDEX(array, i, is_array)) {
1300 var element = array[i]; 1300 var element = array[i];
1301 // Prepare break slots for debugger step in. 1301 // Prepare break slots for debugger step in.
1302 if (stepping) %DebugPrepareStepInIfStepping(f); 1302 if (stepping) %DebugPrepareStepInIfStepping(f);
1303 accumulator[i] = %_Call(f, receiver, element, i, array); 1303 accumulator[i] = %_Call(f, receiver, element, i, array);
1304 } 1304 }
1305 } 1305 }
1306 return accumulator; 1306 return accumulator;
1307 } 1307 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 find_initial: if (argumentsLength < 2) { 1456 find_initial: if (argumentsLength < 2) {
1457 for (; i < length; i++) { 1457 for (; i < length; i++) {
1458 if (HAS_INDEX(array, i, is_array)) { 1458 if (HAS_INDEX(array, i, is_array)) {
1459 current = array[i++]; 1459 current = array[i++];
1460 break find_initial; 1460 break find_initial;
1461 } 1461 }
1462 } 1462 }
1463 throw MakeTypeError(kReduceNoInitial); 1463 throw MakeTypeError(kReduceNoInitial);
1464 } 1464 }
1465 1465
1466 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); 1466 var stepping = DEBUG_IS_STEPPING(callback);
1467 for (; i < length; i++) { 1467 for (; i < length; i++) {
1468 if (HAS_INDEX(array, i, is_array)) { 1468 if (HAS_INDEX(array, i, is_array)) {
1469 var element = array[i]; 1469 var element = array[i];
1470 // Prepare break slots for debugger step in. 1470 // Prepare break slots for debugger step in.
1471 if (stepping) %DebugPrepareStepInIfStepping(callback); 1471 if (stepping) %DebugPrepareStepInIfStepping(callback);
1472 current = callback(current, element, i, array); 1472 current = callback(current, element, i, array);
1473 } 1473 }
1474 } 1474 }
1475 return current; 1475 return current;
1476 } 1476 }
(...skipping 22 matching lines...) Expand all
1499 find_initial: if (argumentsLength < 2) { 1499 find_initial: if (argumentsLength < 2) {
1500 for (; i >= 0; i--) { 1500 for (; i >= 0; i--) {
1501 if (HAS_INDEX(array, i, is_array)) { 1501 if (HAS_INDEX(array, i, is_array)) {
1502 current = array[i--]; 1502 current = array[i--];
1503 break find_initial; 1503 break find_initial;
1504 } 1504 }
1505 } 1505 }
1506 throw MakeTypeError(kReduceNoInitial); 1506 throw MakeTypeError(kReduceNoInitial);
1507 } 1507 }
1508 1508
1509 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); 1509 var stepping = DEBUG_IS_STEPPING(callback);
1510 for (; i >= 0; i--) { 1510 for (; i >= 0; i--) {
1511 if (HAS_INDEX(array, i, is_array)) { 1511 if (HAS_INDEX(array, i, is_array)) {
1512 var element = array[i]; 1512 var element = array[i];
1513 // Prepare break slots for debugger step in. 1513 // Prepare break slots for debugger step in.
1514 if (stepping) %DebugPrepareStepInIfStepping(callback); 1514 if (stepping) %DebugPrepareStepInIfStepping(callback);
1515 current = callback(current, element, i, array); 1515 current = callback(current, element, i, array);
1516 } 1516 }
1517 } 1517 }
1518 return current; 1518 return current;
1519 } 1519 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 %InstallToContext([ 1650 %InstallToContext([
1651 "array_pop", ArrayPop, 1651 "array_pop", ArrayPop,
1652 "array_push", ArrayPush, 1652 "array_push", ArrayPush,
1653 "array_shift", ArrayShift, 1653 "array_shift", ArrayShift,
1654 "array_splice", ArraySplice, 1654 "array_splice", ArraySplice,
1655 "array_slice", ArraySlice, 1655 "array_slice", ArraySlice,
1656 "array_unshift", ArrayUnshift, 1656 "array_unshift", ArrayUnshift,
1657 ]); 1657 ]);
1658 1658
1659 }); 1659 });
OLDNEW
« no previous file with comments | « no previous file | src/js/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698