Changeset 228102 in webkit
- Timestamp:
- Feb 5, 2018 10:12:23 AM (6 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r228040 r228102 1 2018-02-05 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r228012. 4 https://bugs.webkit.org/show_bug.cgi?id=182493 5 6 "It regressed ARES-6 by 2-4%" (Requested by saamyjoon on 7 #webkit). 8 9 Reverted changeset: 10 11 "[JSC] Clean up ArraySpeciesCreate" 12 https://bugs.webkit.org/show_bug.cgi?id=182434 13 https://trac.webkit.org/changeset/228012 14 1 15 2018-02-02 Ryan Haddad <ryanhaddad@apple.com> 2 16 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r228012 r228102 165 165 } 166 166 167 @globalPrivate 168 function arraySpeciesCreate(array, length) 169 { 170 "use strict"; 171 167 function filter(callback /*, thisArg */) 168 { 169 "use strict"; 170 171 var array = @toObject(this, "Array.prototype.filter requires that |this| not be null or undefined"); 172 var length = @toLength(array.length); 173 174 if (typeof callback !== "function") 175 @throwTypeError("Array.prototype.filter callback must be a function"); 176 177 var thisArg = @argument(1); 178 179 // Do 9.4.2.3 ArraySpeciesCreate 180 var result; 172 181 var constructor; 173 var arrayConstructorInRealm = @Array;174 182 if (@isArray(array)) { 175 183 constructor = array.constructor; … … 177 185 // calls this map they don't get an array with the Array.prototype of the 178 186 // other global object. 179 if (@isArrayConstructor(constructor) && arrayConstructorInRealm!== constructor)187 if (@isArrayConstructor(constructor) && @Array !== constructor) 180 188 constructor = @undefined; 181 elseif (@isObject(constructor)) {189 if (@isObject(constructor)) { 182 190 constructor = constructor.@speciesSymbol; 183 191 if (constructor === null) … … 185 193 } 186 194 } 187 if (constructor === arrayConstructorInRealm || constructor === @undefined) 188 return @newArrayWithSize(length); 189 return new constructor(length); 190 } 191 192 function filter(callback /*, thisArg */) 193 { 194 "use strict"; 195 196 var array = @toObject(this, "Array.prototype.filter requires that |this| not be null or undefined"); 197 var length = @toLength(array.length); 198 199 if (typeof callback !== "function") 200 @throwTypeError("Array.prototype.filter callback must be a function"); 201 202 var thisArg = @argument(1); 203 204 var result = @arraySpeciesCreate(array, 0); 195 if (constructor === @Array || constructor === @undefined) 196 result = @newArrayWithSize(0); 197 else 198 result = new constructor(0); 205 199 206 200 var nextIndex = 0; … … 229 223 var thisArg = @argument(1); 230 224 231 var result = @arraySpeciesCreate(array, length); 225 // Do 9.4.2.3 ArraySpeciesCreate 226 var result; 227 var constructor; 228 if (@isArray(array)) { 229 constructor = array.constructor; 230 // We have this check so that if some array from a different global object 231 // calls this map they don't get an array with the Array.prototype of the 232 // other global object. 233 if (@isArrayConstructor(constructor) && @Array !== constructor) 234 constructor = @undefined; 235 if (@isObject(constructor)) { 236 constructor = constructor.@speciesSymbol; 237 if (constructor === null) 238 constructor = @undefined; 239 } 240 } 241 if (constructor === @Array || constructor === @undefined) 242 result = @newArrayWithSize(length); 243 else 244 result = new constructor(length); 232 245 233 246 for (var i = 0; i < length; i++) { … … 605 618 var currentElement = @toObject(this, "Array.prototype.concat requires that |this| not be null or undefined"); 606 619 607 var result = @arraySpeciesCreate(currentElement, 0); 620 var constructor; 621 if (@isArray(currentElement)) { 622 constructor = currentElement.constructor; 623 // We have this check so that if some array from a different global object 624 // calls this map they don't get an array with the Array.prototype of the 625 // other global object. 626 if (@isArrayConstructor(constructor) && @Array !== constructor) 627 constructor = @undefined; 628 else if (@isObject(constructor)) { 629 constructor = constructor.@speciesSymbol; 630 if (constructor === null) 631 constructor = @Array; 632 } 633 } 634 635 var argCount = arguments.length; 636 var result; 637 if (constructor === @Array || constructor === @undefined) 638 result = @newArrayWithSize(0); 639 else 640 result = new constructor(0); 608 641 var resultIsArray = @isJSArray(result); 609 610 var argCount = arguments.length;611 642 612 643 var resultIndex = 0;
Note: See TracChangeset
for help on using the changeset viewer.