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

Side by Side Diff: src/array.js

Issue 11365189: Optimizing the loop algorithm for Array.prototype.map. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 1 month 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 | « AUTHORS ('k') | no next file » | 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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 if (IS_NULL_OR_UNDEFINED(receiver)) { 1232 if (IS_NULL_OR_UNDEFINED(receiver)) {
1233 receiver = %GetDefaultReceiver(f) || receiver; 1233 receiver = %GetDefaultReceiver(f) || receiver;
1234 } else if (!IS_SPEC_OBJECT(receiver)) { 1234 } else if (!IS_SPEC_OBJECT(receiver)) {
1235 receiver = ToObject(receiver); 1235 receiver = ToObject(receiver);
1236 } 1236 }
1237 1237
1238 var result = new $Array(); 1238 var result = new $Array();
1239 var accumulator = new InternalArray(length); 1239 var accumulator = new InternalArray(length);
1240 if (%DebugCallbackSupportsStepping(f)) { 1240 if (%DebugCallbackSupportsStepping(f)) {
1241 for (var i = 0; i < length; i++) { 1241 for (var i = 0; i < length; i++) {
1242 if (i in array) { 1242 var element = array[i];
1243 var element = array[i]; 1243 if (!IS_UNDEFINED(element)) {
Sven Panne 2012/11/11 15:51:41 Quick drive-by-comment: I think that this "optimiz
1244 // Prepare break slots for debugger step in. 1244 // Prepare break slots for debugger step in.
1245 %DebugPrepareStepInIfStepping(f); 1245 %DebugPrepareStepInIfStepping(f);
1246 accumulator[i] = %_CallFunction(receiver, element, i, array, f); 1246 accumulator[i] = %_CallFunction(receiver, element, i, array, f);
1247 } 1247 }
1248 } 1248 }
1249 } else { 1249 } else {
1250 // This is a duplicate of the previous loop sans debug stepping. 1250 // This is a duplicate of the previous loop sans debug stepping.
1251 for (var i = 0; i < length; i++) { 1251 for (var i = 0; i < length; i++) {
1252 if (i in array) { 1252 var element = array[i];
1253 var element = array[i]; 1253 if (!IS_UNDEFINED(element)) {
1254 accumulator[i] = %_CallFunction(receiver, element, i, array, f); 1254 accumulator[i] = %_CallFunction(receiver, element, i, array, f);
1255 } 1255 }
1256 } 1256 }
1257 // End of duplicate. 1257 // End of duplicate.
1258 } 1258 }
1259 %MoveArrayContents(accumulator, result); 1259 %MoveArrayContents(accumulator, result);
1260 return result; 1260 return result;
1261 } 1261 }
1262 1262
1263 1263
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 SetUpLockedPrototype(InternalArray, $Array(), $Array( 1554 SetUpLockedPrototype(InternalArray, $Array(), $Array(
1555 "indexOf", getFunction("indexOf", ArrayIndexOf), 1555 "indexOf", getFunction("indexOf", ArrayIndexOf),
1556 "join", getFunction("join", ArrayJoin), 1556 "join", getFunction("join", ArrayJoin),
1557 "pop", getFunction("pop", ArrayPop), 1557 "pop", getFunction("pop", ArrayPop),
1558 "push", getFunction("push", ArrayPush), 1558 "push", getFunction("push", ArrayPush),
1559 "splice", getFunction("splice", ArraySplice) 1559 "splice", getFunction("splice", ArraySplice)
1560 )); 1560 ));
1561 } 1561 }
1562 1562
1563 SetUpArray(); 1563 SetUpArray();
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698