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

Side by Side Diff: src/array.js

Issue 673893002: Fix sparse versions of Array slice/splice to use [[DefineOwnProperty]] to generate return value (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « no previous file | test/mjsunit/regress/regress-423633.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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declarations have been made 7 // This file relies on the fact that the following declarations have been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // This function implements the optimized splice implementation that can use 205 // This function implements the optimized splice implementation that can use
206 // special array operations to handle sparse arrays in a sensible fashion. 206 // special array operations to handle sparse arrays in a sensible fashion.
207 function SparseSlice(array, start_i, del_count, len, deleted_elements) { 207 function SparseSlice(array, start_i, del_count, len, deleted_elements) {
208 // Move deleted elements to a new array (the return value from splice). 208 // Move deleted elements to a new array (the return value from splice).
209 var indices = %GetArrayKeys(array, start_i + del_count); 209 var indices = %GetArrayKeys(array, start_i + del_count);
210 if (IS_NUMBER(indices)) { 210 if (IS_NUMBER(indices)) {
211 var limit = indices; 211 var limit = indices;
212 for (var i = start_i; i < limit; ++i) { 212 for (var i = start_i; i < limit; ++i) {
213 var current = array[i]; 213 var current = array[i];
214 if (!IS_UNDEFINED(current) || i in array) { 214 if (!IS_UNDEFINED(current) || i in array) {
215 deleted_elements[i - start_i] = current; 215 %AddElement(deleted_elements, i - start_i, current, NONE);
216 } 216 }
217 } 217 }
218 } else { 218 } else {
219 var length = indices.length; 219 var length = indices.length;
220 for (var k = 0; k < length; ++k) { 220 for (var k = 0; k < length; ++k) {
221 var key = indices[k]; 221 var key = indices[k];
222 if (!IS_UNDEFINED(key)) { 222 if (!IS_UNDEFINED(key)) {
223 if (key >= start_i) { 223 if (key >= start_i) {
224 var current = array[key]; 224 var current = array[key];
225 if (!IS_UNDEFINED(current) || key in array) { 225 if (!IS_UNDEFINED(current) || key in array) {
226 deleted_elements[key - start_i] = current; 226 %AddElement(deleted_elements, key - start_i, current, NONE);
227 } 227 }
228 } 228 }
229 } 229 }
230 } 230 }
231 } 231 }
232 } 232 }
233 233
234 234
235 // This function implements the optimized splice implementation that can use 235 // This function implements the optimized splice implementation that can use
236 // special array operations to handle sparse arrays in a sensible fashion. 236 // special array operations to handle sparse arrays in a sensible fashion.
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 )); 1567 ));
1568 1568
1569 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1569 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1570 "join", getFunction("join", ArrayJoin), 1570 "join", getFunction("join", ArrayJoin),
1571 "pop", getFunction("pop", ArrayPop), 1571 "pop", getFunction("pop", ArrayPop),
1572 "push", getFunction("push", ArrayPush) 1572 "push", getFunction("push", ArrayPush)
1573 )); 1573 ));
1574 } 1574 }
1575 1575
1576 SetUpArray(); 1576 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-423633.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698