Changeset 247296 in webkit
- Timestamp:
- Jul 10, 2019 1:24:52 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r247194 r247296 1 2019-07-10 Tadeu Zagallo <tzagallo@apple.com> 2 3 Optimize join of large empty arrays 4 https://bugs.webkit.org/show_bug.cgi?id=199636 5 6 Reviewed by Mark Lam. 7 8 * microbenchmarks/large-empty-array-join.js: Added. 9 * microbenchmarks/large-empty-array-join-resolve-rope.js: Added. 10 1 11 2019-07-06 Michael Saboff <msaboff@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r247247 r247296 1 2019-07-10 Tadeu Zagallo <tzagallo@apple.com> 2 3 Optimize join of large empty arrays 4 https://bugs.webkit.org/show_bug.cgi?id=199636 5 6 Reviewed by Mark Lam. 7 8 Replicate the behavior of `str.repeat(count)` when performing `new Array(count + 1).join(str)`. 9 I added two new microbenchmarks: 10 - large-empty-array-join, which does not use the result of the join and runs ~44x faster and uses ~18x less memory. 11 - large-empty-array-join-resolve-rope, which uses the result of the join and runs 2x faster. 12 13 baseline diff 14 large-empty-array-join 2713.9698+-72.7621 ^ 61.2335+-10.4836 ^ definitely 44.3217x faster 15 large-empty-array-join-resolve-string 26.5517+-0.3995 ^ 12.9309+-0.5516 ^ definitely 2.0533x faster 16 17 large-empty-array-join memory usage with baseline (dirty): 18 733012 kB current_mem 19 756824 kB lifetime_peak 20 21 large-empty-array-join memory usage with diff (dirty): 22 41904 kB current_mem 23 41972 kB lifetime_peak 24 25 Additionally, I ran JetStream2, sunspider and v8-spider and all were neutral. 26 27 * runtime/ArrayPrototype.cpp: 28 (JSC::fastJoin): 29 1 30 2019-07-08 Keith Miller <keith_miller@apple.com> 2 31 -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r247175 r247296 541 541 RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters8()[0], length - 1)); 542 542 RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters16()[0], length - 1)); 543 default: 544 JSString* result = jsEmptyString(&state); 545 if (length <= 1) 546 return result; 547 548 JSString* operand = jsString(&vm, separator.toString()); 549 RETURN_IF_EXCEPTION(scope, { }); 550 unsigned count = length - 1; 551 for (;;) { 552 if (count & 1) { 553 result = jsString(&state, result, operand); 554 RETURN_IF_EXCEPTION(scope, { }); 555 } 556 count >>= 1; 557 if (!count) 558 return result; 559 operand = jsString(&state, operand, operand); 560 RETURN_IF_EXCEPTION(scope, { }); 561 } 543 562 } 544 563 }
Note: See TracChangeset
for help on using the changeset viewer.