Changeset 242081 in webkit
- Timestamp:
- Feb 26, 2019 12:50:48 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r241968 r242081 1 2019-02-26 Guillaume Emont <guijemont@igalia.com> 2 3 [JSC] Repeat string created from Array.prototype.join() take too much memory 4 https://bugs.webkit.org/show_bug.cgi?id=193912 5 6 Reviewed by Saam Barati. 7 8 Added a test and a microbenchmark for corner cases of 9 Array.prototype.join() with an uninitialized array. 10 11 * microbenchmarks/array-prototype-join-uninitialized.js: Added. 12 * stress/array-prototype-join-uninitialized.js: Added. 13 (testArray): 14 (testABC): 15 (B): 16 (C): 17 1 18 2019-02-22 Robin Morisset <rmorisset@apple.com> 2 19 -
trunk/Source/JavaScriptCore/ChangeLog
r242071 r242081 1 2019-02-26 Guillaume Emont <guijemont@igalia.com> 2 3 [JSC] Repeat string created from Array.prototype.join() take too much memory 4 https://bugs.webkit.org/show_bug.cgi?id=193912 5 6 Reviewed by Saam Barati. 7 8 Added a fast case in Array.prototype.join when the array is 9 uninitialized. 10 11 * runtime/ArrayPrototype.cpp: 12 (JSC::canUseFastJoin): 13 (JSC::fastJoin): 14 * runtime/JSStringInlines.h: 15 (JSC::repeatCharacter): moved from StringPrototype.cpp 16 * runtime/StringPrototype.cpp: 17 1 18 2019-02-25 Mark Lam <mark.lam@apple.com> 2 19 -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r236697 r242081 391 391 case ALL_INT32_INDEXING_TYPES: 392 392 case ALL_DOUBLE_INDEXING_TYPES: 393 case ALL_UNDECIDED_INDEXING_TYPES: 393 394 return true; 394 395 default: … … 504 505 RELEASE_AND_RETURN(scope, joiner.join(state)); 505 506 } 507 case ALL_UNDECIDED_INDEXING_TYPES: { 508 if (length && holesMustForwardToPrototype(vm, thisObject)) 509 goto generalCase; 510 switch (separator.length()) { 511 case 0: 512 RELEASE_AND_RETURN(scope, jsEmptyString(&state)); 513 case 1: { 514 if (length <= 1) 515 RELEASE_AND_RETURN(scope, jsEmptyString(&state)); 516 if (separator.is8Bit()) 517 RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters8()[0], length - 1)); 518 RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters16()[0], length - 1)); 519 } 520 } 521 } 506 522 } 507 523 -
trunk/Source/JavaScriptCore/runtime/JSStringInlines.h
r236804 r242081 55 55 } 56 56 57 template <typename CharacterType> 58 inline JSString* repeatCharacter(ExecState& exec, CharacterType character, unsigned repeatCount) 59 { 60 VM& vm = exec.vm(); 61 auto scope = DECLARE_THROW_SCOPE(vm); 62 63 CharacterType* buffer = nullptr; 64 auto impl = StringImpl::tryCreateUninitialized(repeatCount, buffer); 65 if (!impl) { 66 throwOutOfMemoryError(&exec, scope); 67 return nullptr; 68 } 69 70 std::fill_n(buffer, repeatCount, character); 71 72 RELEASE_AND_RETURN(scope, jsString(&exec, WTFMove(impl))); 73 } 74 57 75 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r242064 r242081 838 838 } 839 839 840 template <typename CharacterType>841 static inline JSString* repeatCharacter(ExecState& exec, CharacterType character, unsigned repeatCount)842 {843 VM& vm = exec.vm();844 auto scope = DECLARE_THROW_SCOPE(vm);845 846 CharacterType* buffer = nullptr;847 auto impl = StringImpl::tryCreateUninitialized(repeatCount, buffer);848 if (!impl) {849 throwOutOfMemoryError(&exec, scope);850 return nullptr;851 }852 853 std::fill_n(buffer, repeatCount, character);854 855 RELEASE_AND_RETURN(scope, jsString(&exec, WTFMove(impl)));856 }857 858 840 EncodedJSValue JSC_HOST_CALL stringProtoFuncRepeatCharacter(ExecState* exec) 859 841 {
Note: See TracChangeset
for help on using the changeset viewer.