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

Side by Side Diff: src/array.js

Issue 13465008: Fix Array.prototype.concat when exceeding array size limit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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/runtime.cc » ('j') | src/runtime.cc » ('J')
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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 476 }
477 477
478 var array = ToObject(this); 478 var array = ToObject(this);
479 var arg_count = %_ArgumentsLength(); 479 var arg_count = %_ArgumentsLength();
480 var arrays = new InternalArray(1 + arg_count); 480 var arrays = new InternalArray(1 + arg_count);
481 arrays[0] = array; 481 arrays[0] = array;
482 for (var i = 0; i < arg_count; i++) { 482 for (var i = 0; i < arg_count; i++) {
483 arrays[i + 1] = %_Arguments(i); 483 arrays[i + 1] = %_Arguments(i);
484 } 484 }
485 485
486 return %ArrayConcat(arrays); 486 var result = %ArrayConcat(arrays);
487 if (!%_IsSmi(result)) return result;
488
489 // The result is a smi as signal that %ArrayConcat failed because the result
490 // exceeds the array size limit. Overflowing elements turn into properties.
491 var offset = 0;
492 var result = [];
493 for (var i = 0; i < arrays.length; i++) {
494 var array = arrays[i];
495 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, array.length));
496 for (var j = 0; j < keys.length; j++) {
497 var key = keys[j];
498 result[key + offset] = array[key];
499 }
500 offset += array.length;
501 }
502 return result;
487 } 503 }
488 504
489 505
490 // For implementing reverse() on large, sparse arrays. 506 // For implementing reverse() on large, sparse arrays.
491 function SparseReverse(array, len) { 507 function SparseReverse(array, len) {
492 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len)); 508 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
493 var high_counter = keys.length - 1; 509 var high_counter = keys.length - 1;
494 var low_counter = 0; 510 var low_counter = 0;
495 while (low_counter <= high_counter) { 511 while (low_counter <= high_counter) {
496 var i = keys[low_counter]; 512 var i = keys[low_counter];
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 )); 1578 ));
1563 1579
1564 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1580 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1565 "join", getFunction("join", ArrayJoin), 1581 "join", getFunction("join", ArrayJoin),
1566 "pop", getFunction("pop", ArrayPop), 1582 "pop", getFunction("pop", ArrayPop),
1567 "push", getFunction("push", ArrayPush) 1583 "push", getFunction("push", ArrayPush)
1568 )); 1584 ));
1569 } 1585 }
1570 1586
1571 SetUpArray(); 1587 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698