Changeset 199128 in webkit for trunk/Source/JavaScriptCore/builtins
- Timestamp:
- Apr 6, 2016, 5:50:44 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r198844 r199128 647 647 } 648 648 649 function concatSlowPath() 650 { 651 "use strict"; 652 653 var argCount = arguments.length; 654 var result = new this.species(0); 655 var resultIsArray = @isJSArray(result); 656 657 var currentElement = this.array; 658 var resultIndex = 0; 659 var argIndex = 0; 660 661 do { 662 var spreadable = @isObject(currentElement) && currentElement[@symbolIsConcatSpreadable]; 663 if ((spreadable == @undefined && @isArray(currentElement)) || spreadable) { 664 var length = @toLength(currentElement.length); 665 if (resultIsArray && @isJSArray(currentElement) 666 && @appendMemcpy(result, currentElement)) { 667 668 resultIndex += length; 669 } else { 670 if (length + resultIndex > @MAX_SAFE_INTEGER) 671 throw @TypeError("length exceeded the maximum safe integer"); 672 for (var i = 0; i < length; i++) { 673 if (i in currentElement) 674 @putByValDirect(result, resultIndex, currentElement[i]); 675 resultIndex++; 676 } 677 } 678 } else { 679 if (resultIndex >= @MAX_SAFE_INTEGER) 680 throw @TypeError("length exceeded the maximum safe integer"); 681 @putByValDirect(result, resultIndex++, currentElement); 682 } 683 currentElement = arguments[argIndex]; 684 } while (argIndex++ < argCount); 685 686 result.length = resultIndex; 687 return result; 688 } 689 690 function concat(first) 691 { 692 "use strict"; 693 694 if (this == null) { 695 if (this === null) 696 throw new @TypeError("Array.prototype.concat requires that |this| not be null"); 697 throw new @TypeError("Array.prototype.concat requires that |this| not be undefined"); 698 } 699 700 var array = @Object(this); 701 702 var constructor; 703 if (@isArray(array)) { 704 constructor = array.constructor; 705 // We have this check so that if some array from a different global object 706 // calls this map they don't get an array with the Array.prototype of the 707 // other global object. 708 if (@isArrayConstructor(constructor) && @Array !== constructor) 709 constructor = @undefined; 710 if (@isObject(constructor)) { 711 constructor = constructor[@symbolSpecies]; 712 if (constructor === null) 713 constructor = @Array; 714 } 715 } 716 if (constructor === @undefined) 717 constructor = @Array; 718 719 var result; 720 if (arguments.length === 1 721 && constructor === @Array 722 && @isJSArray(array) 723 && @isJSArray(first) 724 // FIXME: these get_by_ids should be "in"s but using "in" here is a 10% regression. 725 // https://bugs.webkit.org/show_bug.cgi?id=155590 726 && array[@symbolIsConcatSpreadable] == @undefined 727 && first[@symbolIsConcatSpreadable] == @undefined) { 728 729 result = @concatMemcpy(array, first); 730 if (result !== null) 731 return result; 732 } 733 734 return @concatSlowPath.@apply({ array: array, species: constructor }, arguments); 735 } 736 649 737 function copyWithin(target, start /*, end */) 650 738 {
Note:
See TracChangeset
for help on using the changeset viewer.