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

Side by Side Diff: src/array.js

Issue 251933004: Ignore debug stepin in optimized code for array builtins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1140 }
1141 if (IS_NULL_OR_UNDEFINED(receiver)) { 1141 if (IS_NULL_OR_UNDEFINED(receiver)) {
1142 receiver = %GetDefaultReceiver(f) || receiver; 1142 receiver = %GetDefaultReceiver(f) || receiver;
1143 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) { 1143 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) {
1144 receiver = ToObject(receiver); 1144 receiver = ToObject(receiver);
1145 } 1145 }
1146 1146
1147 var result = new $Array(); 1147 var result = new $Array();
1148 var accumulator = new InternalArray(); 1148 var accumulator = new InternalArray();
1149 var accumulator_length = 0; 1149 var accumulator_length = 0;
1150 if (%DebugCallbackSupportsStepping(f)) { 1150 var stepping = %_DebugCallbackSupportsStepping(f);
1151 for (var i = 0; i < length; i++) { 1151 for (var i = 0; i < length; i++) {
1152 if (i in array) { 1152 if (i in array) {
1153 var element = array[i]; 1153 var element = array[i];
1154 // Prepare break slots for debugger step in. 1154 // Prepare break slots for debugger step in.
1155 %DebugPrepareStepInIfStepping(f); 1155 if (stepping) %DebugPrepareStepInIfStepping(f);
1156 if (%_CallFunction(receiver, element, i, array, f)) { 1156 if (%_CallFunction(receiver, element, i, array, f)) {
1157 accumulator[accumulator_length++] = element; 1157 accumulator[accumulator_length++] = element;
1158 }
1159 } 1158 }
1160 } 1159 }
1161 } else {
1162 // This is a duplicate of the previous loop sans debug stepping.
1163 for (var i = 0; i < length; i++) {
1164 if (i in array) {
1165 var element = array[i];
1166 if (%_CallFunction(receiver, element, i, array, f)) {
1167 accumulator[accumulator_length++] = element;
1168 }
1169 }
1170 }
1171 // End of duplicate.
1172 } 1160 }
1173 %MoveArrayContents(accumulator, result); 1161 %MoveArrayContents(accumulator, result);
1174 return result; 1162 return result;
1175 } 1163 }
1176 1164
1177 1165
1178 function ArrayForEach(f, receiver) { 1166 function ArrayForEach(f, receiver) {
1179 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); 1167 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
1180 1168
1181 // Pull out the length so that modifications to the length in the 1169 // Pull out the length so that modifications to the length in the
1182 // loop will not affect the looping and side effects are visible. 1170 // loop will not affect the looping and side effects are visible.
1183 var array = ToObject(this); 1171 var array = ToObject(this);
1184 var length = TO_UINT32(array.length); 1172 var length = TO_UINT32(array.length);
1185 1173
1186 if (!IS_SPEC_FUNCTION(f)) { 1174 if (!IS_SPEC_FUNCTION(f)) {
1187 throw MakeTypeError('called_non_callable', [ f ]); 1175 throw MakeTypeError('called_non_callable', [ f ]);
1188 } 1176 }
1189 if (IS_NULL_OR_UNDEFINED(receiver)) { 1177 if (IS_NULL_OR_UNDEFINED(receiver)) {
1190 receiver = %GetDefaultReceiver(f) || receiver; 1178 receiver = %GetDefaultReceiver(f) || receiver;
1191 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) { 1179 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) {
1192 receiver = ToObject(receiver); 1180 receiver = ToObject(receiver);
1193 } 1181 }
1194 1182
1195 if (%DebugCallbackSupportsStepping(f)) { 1183 var stepping = %_DebugCallbackSupportsStepping(f);
1196 for (var i = 0; i < length; i++) { 1184 for (var i = 0; i < length; i++) {
1197 if (i in array) { 1185 if (i in array) {
1198 var element = array[i]; 1186 var element = array[i];
1199 // Prepare break slots for debugger step in. 1187 // Prepare break slots for debugger step in.
1200 %DebugPrepareStepInIfStepping(f); 1188 if (stepping) %DebugPrepareStepInIfStepping(f);
1201 %_CallFunction(receiver, element, i, array, f); 1189 %_CallFunction(receiver, element, i, array, f);
1202 }
1203 } 1190 }
1204 } else {
1205 // This is a duplicate of the previous loop sans debug stepping.
1206 for (var i = 0; i < length; i++) {
1207 if (i in array) {
1208 var element = array[i];
1209 %_CallFunction(receiver, element, i, array, f);
1210 }
1211 }
1212 // End of duplicate.
1213 } 1191 }
1214 } 1192 }
1215 1193
1216 1194
1217 // Executes the function once for each element present in the 1195 // Executes the function once for each element present in the
1218 // array until it finds one where callback returns true. 1196 // array until it finds one where callback returns true.
1219 function ArraySome(f, receiver) { 1197 function ArraySome(f, receiver) {
1220 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); 1198 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
1221 1199
1222 // Pull out the length so that modifications to the length in the 1200 // Pull out the length so that modifications to the length in the
1223 // loop will not affect the looping and side effects are visible. 1201 // loop will not affect the looping and side effects are visible.
1224 var array = ToObject(this); 1202 var array = ToObject(this);
1225 var length = TO_UINT32(array.length); 1203 var length = TO_UINT32(array.length);
1226 1204
1227 if (!IS_SPEC_FUNCTION(f)) { 1205 if (!IS_SPEC_FUNCTION(f)) {
1228 throw MakeTypeError('called_non_callable', [ f ]); 1206 throw MakeTypeError('called_non_callable', [ f ]);
1229 } 1207 }
1230 if (IS_NULL_OR_UNDEFINED(receiver)) { 1208 if (IS_NULL_OR_UNDEFINED(receiver)) {
1231 receiver = %GetDefaultReceiver(f) || receiver; 1209 receiver = %GetDefaultReceiver(f) || receiver;
1232 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) { 1210 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) {
1233 receiver = ToObject(receiver); 1211 receiver = ToObject(receiver);
1234 } 1212 }
1235 1213
1236 if (%DebugCallbackSupportsStepping(f)) { 1214 var stepping = %_DebugCallbackSupportsStepping(f);
1237 for (var i = 0; i < length; i++) { 1215 for (var i = 0; i < length; i++) {
1238 if (i in array) { 1216 if (i in array) {
1239 var element = array[i]; 1217 var element = array[i];
1240 // Prepare break slots for debugger step in. 1218 // Prepare break slots for debugger step in.
1241 %DebugPrepareStepInIfStepping(f); 1219 if (stepping) %DebugPrepareStepInIfStepping(f);
1242 if (%_CallFunction(receiver, element, i, array, f)) return true; 1220 if (%_CallFunction(receiver, element, i, array, f)) return true;
1243 }
1244 } 1221 }
1245 } else {
1246 // This is a duplicate of the previous loop sans debug stepping.
1247 for (var i = 0; i < length; i++) {
1248 if (i in array) {
1249 var element = array[i];
1250 if (%_CallFunction(receiver, element, i, array, f)) return true;
1251 }
1252 }
1253 // End of duplicate.
1254 } 1222 }
1255 return false; 1223 return false;
1256 } 1224 }
1257 1225
1258 1226
1259 function ArrayEvery(f, receiver) { 1227 function ArrayEvery(f, receiver) {
1260 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); 1228 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
1261 1229
1262 // Pull out the length so that modifications to the length in the 1230 // Pull out the length so that modifications to the length in the
1263 // loop will not affect the looping and side effects are visible. 1231 // loop will not affect the looping and side effects are visible.
1264 var array = ToObject(this); 1232 var array = ToObject(this);
1265 var length = TO_UINT32(array.length); 1233 var length = TO_UINT32(array.length);
1266 1234
1267 if (!IS_SPEC_FUNCTION(f)) { 1235 if (!IS_SPEC_FUNCTION(f)) {
1268 throw MakeTypeError('called_non_callable', [ f ]); 1236 throw MakeTypeError('called_non_callable', [ f ]);
1269 } 1237 }
1270 if (IS_NULL_OR_UNDEFINED(receiver)) { 1238 if (IS_NULL_OR_UNDEFINED(receiver)) {
1271 receiver = %GetDefaultReceiver(f) || receiver; 1239 receiver = %GetDefaultReceiver(f) || receiver;
1272 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) { 1240 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) {
1273 receiver = ToObject(receiver); 1241 receiver = ToObject(receiver);
1274 } 1242 }
1275 1243
1276 if (%DebugCallbackSupportsStepping(f)) { 1244 var stepping = %_DebugCallbackSupportsStepping(f);
1277 for (var i = 0; i < length; i++) { 1245 for (var i = 0; i < length; i++) {
1278 if (i in array) { 1246 if (i in array) {
1279 var element = array[i]; 1247 var element = array[i];
1280 // Prepare break slots for debugger step in. 1248 // Prepare break slots for debugger step in.
1281 %DebugPrepareStepInIfStepping(f); 1249 if (stepping) %DebugPrepareStepInIfStepping(f);
1282 if (!%_CallFunction(receiver, element, i, array, f)) return false; 1250 if (!%_CallFunction(receiver, element, i, array, f)) return false;
1283 }
1284 } 1251 }
1285 } else {
1286 // This is a duplicate of the previous loop sans debug stepping.
1287 for (var i = 0; i < length; i++) {
1288 if (i in array) {
1289 var element = array[i];
1290 if (!%_CallFunction(receiver, element, i, array, f)) return false;
1291 }
1292 }
1293 // End of duplicate.
1294 } 1252 }
1295 return true; 1253 return true;
1296 } 1254 }
1297 1255
1298 function ArrayMap(f, receiver) { 1256 function ArrayMap(f, receiver) {
1299 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); 1257 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map");
1300 1258
1301 // Pull out the length so that modifications to the length in the 1259 // Pull out the length so that modifications to the length in the
1302 // loop will not affect the looping and side effects are visible. 1260 // loop will not affect the looping and side effects are visible.
1303 var array = ToObject(this); 1261 var array = ToObject(this);
1304 var length = TO_UINT32(array.length); 1262 var length = TO_UINT32(array.length);
1305 1263
1306 if (!IS_SPEC_FUNCTION(f)) { 1264 if (!IS_SPEC_FUNCTION(f)) {
1307 throw MakeTypeError('called_non_callable', [ f ]); 1265 throw MakeTypeError('called_non_callable', [ f ]);
1308 } 1266 }
1309 if (IS_NULL_OR_UNDEFINED(receiver)) { 1267 if (IS_NULL_OR_UNDEFINED(receiver)) {
1310 receiver = %GetDefaultReceiver(f) || receiver; 1268 receiver = %GetDefaultReceiver(f) || receiver;
1311 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) { 1269 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(f)) {
1312 receiver = ToObject(receiver); 1270 receiver = ToObject(receiver);
1313 } 1271 }
1314 1272
1315 var result = new $Array(); 1273 var result = new $Array();
1316 var accumulator = new InternalArray(length); 1274 var accumulator = new InternalArray(length);
1317 if (%DebugCallbackSupportsStepping(f)) { 1275 var stepping = %_DebugCallbackSupportsStepping(f);
1318 for (var i = 0; i < length; i++) { 1276 for (var i = 0; i < length; i++) {
1319 if (i in array) { 1277 if (i in array) {
1320 var element = array[i]; 1278 var element = array[i];
1321 // Prepare break slots for debugger step in. 1279 // Prepare break slots for debugger step in.
1322 %DebugPrepareStepInIfStepping(f); 1280 if (stepping) %DebugPrepareStepInIfStepping(f);
1323 accumulator[i] = %_CallFunction(receiver, element, i, array, f); 1281 accumulator[i] = %_CallFunction(receiver, element, i, array, f);
1324 }
1325 } 1282 }
1326 } else {
1327 // This is a duplicate of the previous loop sans debug stepping.
1328 for (var i = 0; i < length; i++) {
1329 if (i in array) {
1330 var element = array[i];
1331 accumulator[i] = %_CallFunction(receiver, element, i, array, f);
1332 }
1333 }
1334 // End of duplicate.
1335 } 1283 }
1336 %MoveArrayContents(accumulator, result); 1284 %MoveArrayContents(accumulator, result);
1337 return result; 1285 return result;
1338 } 1286 }
1339 1287
1340 1288
1341 function ArrayIndexOf(element, index) { 1289 function ArrayIndexOf(element, index) {
1342 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); 1290 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf");
1343 1291
1344 var length = TO_UINT32(this.length); 1292 var length = TO_UINT32(this.length);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 current = array[i]; 1412 current = array[i];
1465 if (!IS_UNDEFINED(current) || i in array) { 1413 if (!IS_UNDEFINED(current) || i in array) {
1466 i++; 1414 i++;
1467 break find_initial; 1415 break find_initial;
1468 } 1416 }
1469 } 1417 }
1470 throw MakeTypeError('reduce_no_initial', []); 1418 throw MakeTypeError('reduce_no_initial', []);
1471 } 1419 }
1472 1420
1473 var receiver = %GetDefaultReceiver(callback); 1421 var receiver = %GetDefaultReceiver(callback);
1474 1422 var stepping = %_DebugCallbackSupportsStepping(callback);
1475 if (%DebugCallbackSupportsStepping(callback)) { 1423 for (; i < length; i++) {
1476 for (; i < length; i++) { 1424 if (i in array) {
1477 if (i in array) { 1425 var element = array[i];
1478 var element = array[i]; 1426 // Prepare break slots for debugger step in.
1479 // Prepare break slots for debugger step in. 1427 if (stepping) %DebugPrepareStepInIfStepping(callback);
1480 %DebugPrepareStepInIfStepping(callback); 1428 current = %_CallFunction(receiver, current, element, i, array, callback);
1481 current =
1482 %_CallFunction(receiver, current, element, i, array, callback);
1483 }
1484 } 1429 }
1485 } else {
1486 // This is a duplicate of the previous loop sans debug stepping.
1487 for (; i < length; i++) {
1488 if (i in array) {
1489 var element = array[i];
1490 current =
1491 %_CallFunction(receiver, current, element, i, array, callback);
1492 }
1493 }
1494 // End of duplicate.
1495 } 1430 }
1496 return current; 1431 return current;
1497 } 1432 }
1498 1433
1499 function ArrayReduceRight(callback, current) { 1434 function ArrayReduceRight(callback, current) {
1500 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); 1435 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight");
1501 1436
1502 // Pull out the length so that side effects are visible before the 1437 // Pull out the length so that side effects are visible before the
1503 // callback function is checked. 1438 // callback function is checked.
1504 var array = ToObject(this); 1439 var array = ToObject(this);
1505 var length = ToUint32(array.length); 1440 var length = ToUint32(array.length);
1506 1441
1507 if (!IS_SPEC_FUNCTION(callback)) { 1442 if (!IS_SPEC_FUNCTION(callback)) {
1508 throw MakeTypeError('called_non_callable', [callback]); 1443 throw MakeTypeError('called_non_callable', [callback]);
1509 } 1444 }
1510 1445
1511 var i = length - 1; 1446 var i = length - 1;
1512 find_initial: if (%_ArgumentsLength() < 2) { 1447 find_initial: if (%_ArgumentsLength() < 2) {
1513 for (; i >= 0; i--) { 1448 for (; i >= 0; i--) {
1514 current = array[i]; 1449 current = array[i];
1515 if (!IS_UNDEFINED(current) || i in array) { 1450 if (!IS_UNDEFINED(current) || i in array) {
1516 i--; 1451 i--;
1517 break find_initial; 1452 break find_initial;
1518 } 1453 }
1519 } 1454 }
1520 throw MakeTypeError('reduce_no_initial', []); 1455 throw MakeTypeError('reduce_no_initial', []);
1521 } 1456 }
1522 1457
1523 var receiver = %GetDefaultReceiver(callback); 1458 var receiver = %GetDefaultReceiver(callback);
1524 1459 var stepping = %_DebugCallbackSupportsStepping(callback);
1525 if (%DebugCallbackSupportsStepping(callback)) { 1460 for (; i >= 0; i--) {
1526 for (; i >= 0; i--) { 1461 if (i in array) {
1527 if (i in array) { 1462 var element = array[i];
1528 var element = array[i]; 1463 // Prepare break slots for debugger step in.
1529 // Prepare break slots for debugger step in. 1464 if (stepping) %DebugPrepareStepInIfStepping(callback);
1530 %DebugPrepareStepInIfStepping(callback); 1465 current = %_CallFunction(receiver, current, element, i, array, callback);
1531 current =
1532 %_CallFunction(receiver, current, element, i, array, callback);
1533 }
1534 } 1466 }
1535 } else {
1536 // This is a duplicate of the previous loop sans debug stepping.
1537 for (; i >= 0; i--) {
1538 if (i in array) {
1539 var element = array[i];
1540 current =
1541 %_CallFunction(receiver, current, element, i, array, callback);
1542 }
1543 }
1544 // End of duplicate.
1545 } 1467 }
1546 return current; 1468 return current;
1547 } 1469 }
1548 1470
1549 // ES5, 15.4.3.2 1471 // ES5, 15.4.3.2
1550 function ArrayIsArray(obj) { 1472 function ArrayIsArray(obj) {
1551 return IS_ARRAY(obj); 1473 return IS_ARRAY(obj);
1552 } 1474 }
1553 1475
1554 1476
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 )); 1544 ));
1623 1545
1624 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1546 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1625 "join", getFunction("join", ArrayJoin), 1547 "join", getFunction("join", ArrayJoin),
1626 "pop", getFunction("pop", ArrayPop), 1548 "pop", getFunction("pop", ArrayPop),
1627 "push", getFunction("push", ArrayPush) 1549 "push", getFunction("push", ArrayPush)
1628 )); 1550 ));
1629 } 1551 }
1630 1552
1631 SetUpArray(); 1553 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698