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

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

Issue 1172683003: Use the LookupIterator for SetElement and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 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 | « src/elements.cc ('k') | src/ic/ic.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 result.length = k; 231 result.length = k;
232 return result; 232 return result;
233 } 233 }
234 234
235 nextValue = next.value; 235 nextValue = next.value;
236 if (mapping) { 236 if (mapping) {
237 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); 237 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn);
238 } else { 238 } else {
239 mappedValue = nextValue; 239 mappedValue = nextValue;
240 } 240 }
241 %AddElement(result, k++, mappedValue, NONE); 241 // TODO(verwaest): This should redefine rather than adding.
242 %AddElement(result, k++, mappedValue);
242 } 243 }
243 } else { 244 } else {
244 var len = $toLength(items.length); 245 var len = $toLength(items.length);
245 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); 246 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len);
246 247
247 for (k = 0; k < len; ++k) { 248 for (k = 0; k < len; ++k) {
248 nextValue = items[k]; 249 nextValue = items[k];
249 if (mapping) { 250 if (mapping) {
250 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); 251 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn);
251 } else { 252 } else {
252 mappedValue = nextValue; 253 mappedValue = nextValue;
253 } 254 }
254 %AddElement(result, k, mappedValue, NONE); 255 // TODO(verwaest): This should redefine rather than adding.
256 %AddElement(result, k, mappedValue);
255 } 257 }
256 258
257 result.length = k; 259 result.length = k;
258 return result; 260 return result;
259 } 261 }
260 } 262 }
261 263
262 // ES6, draft 05-22-14, section 22.1.2.3 264 // ES6, draft 05-22-14, section 22.1.2.3
263 function ArrayOf() { 265 function ArrayOf() {
264 var length = %_ArgumentsLength(); 266 var length = %_ArgumentsLength();
265 var constructor = this; 267 var constructor = this;
266 // TODO: Implement IsConstructor (ES6 section 7.2.5) 268 // TODO: Implement IsConstructor (ES6 section 7.2.5)
267 var array = %IsConstructor(constructor) ? new constructor(length) : []; 269 var array = %IsConstructor(constructor) ? new constructor(length) : [];
268 for (var i = 0; i < length; i++) { 270 for (var i = 0; i < length; i++) {
269 %AddElement(array, i, %_Arguments(i), NONE); 271 // TODO(verwaest): This should redefine rather than adding.
272 %AddElement(array, i, %_Arguments(i));
270 } 273 }
271 array.length = length; 274 array.length = length;
272 return array; 275 return array;
273 } 276 }
274 277
275 // ------------------------------------------------------------------- 278 // -------------------------------------------------------------------
276 279
277 utils.InstallConstants(GlobalSymbol, [ 280 utils.InstallConstants(GlobalSymbol, [
278 // TODO(dslomov, caitp): Move to symbol.js when shipping 281 // TODO(dslomov, caitp): Move to symbol.js when shipping
279 "isConcatSpreadable", symbolIsConcatSpreadable 282 "isConcatSpreadable", symbolIsConcatSpreadable
(...skipping 24 matching lines...) Expand all
304 307
305 utils.Export(function(to) { 308 utils.Export(function(to) {
306 to.ArrayFrom = ArrayFrom; 309 to.ArrayFrom = ArrayFrom;
307 to.InnerArrayCopyWithin = InnerArrayCopyWithin; 310 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
308 to.InnerArrayFill = InnerArrayFill; 311 to.InnerArrayFill = InnerArrayFill;
309 to.InnerArrayFind = InnerArrayFind; 312 to.InnerArrayFind = InnerArrayFind;
310 to.InnerArrayFindIndex = InnerArrayFindIndex; 313 to.InnerArrayFindIndex = InnerArrayFindIndex;
311 }); 314 });
312 315
313 }) 316 })
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698