Commit 8b7e7ed
committed
[JSC] Improve String#split for uglify-js-wtb
https://bugs.webkit.org/show_bug.cgi?id=251823
rdar://105104781
Reviewed by Michael Saboff.
This patch improves JetStream2/uglify-js-wtb by 1% with String#split optimizations.
1. We should just use ArrayWithContigous array for result of String#split, and let's say `1` capacity at least.
At that point, we will always return an array with at least one capacity. So, let's avoid structure transition,
and butterfly reallocation.
2. We should search for BoyerMoore lookahead character patterns with Greedy one-character pattern. For example,
/\r?\n/ is very frequently used. We should search for [\r\n] character to start matching in this case.
However, if we have /\r?\n/ pattern,
1. first character can be [\r\n]
2. second character can be null, or [\n]
So, this confuses fixed-sized BoyerMoore lookahead generation. So, when we encounter greedy one-character pattern, we cut
the BM prefix length at this point. So, in the above case, we only consider about first character [\r\n] case.
This is still beneficial since previously we give up completely when we encounter greedy fixed-sized one-character pattern.
ToT Patched
string-split-space 130.3261+-0.7798 ^ 125.6028+-0.4402 ^ definitely 1.0376x faster
string-split 206.8225+-1.1932 ^ 128.5716+-0.7137 ^ definitely 1.6086x faster
* JSTests/microbenchmarks/string-split-space.js: Added.
(split):
* JSTests/microbenchmarks/string-split.js: Added.
(split):
* Source/JavaScriptCore/runtime/RegExpPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
Canonical link: https://commits.webkit.org/259941@main1 parent 35591d2 commit 8b7e7ed
4 files changed
Lines changed: 134 additions & 18 deletions
File tree
- JSTests/microbenchmarks
- Source/JavaScriptCore
- runtime
- yarr
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
509 | | - | |
510 | 508 | | |
511 | 509 | | |
512 | 510 | | |
513 | 511 | | |
514 | 512 | | |
515 | | - | |
| 513 | + | |
516 | 514 | | |
517 | 515 | | |
518 | 516 | | |
| |||
522 | 520 | | |
523 | 521 | | |
524 | 522 | | |
525 | | - | |
| 523 | + | |
526 | 524 | | |
527 | 525 | | |
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
531 | 529 | | |
532 | 530 | | |
| 531 | + | |
| 532 | + | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | | - | |
| 537 | + | |
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
549 | 554 | | |
550 | 555 | | |
551 | 556 | | |
| |||
561 | 566 | | |
562 | 567 | | |
563 | 568 | | |
564 | | - | |
| 569 | + | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
| |||
592 | 597 | | |
593 | 598 | | |
594 | 599 | | |
595 | | - | |
| 600 | + | |
596 | 601 | | |
597 | 602 | | |
598 | 603 | | |
599 | | - | |
| 604 | + | |
600 | 605 | | |
601 | 606 | | |
602 | 607 | | |
| |||
615 | 620 | | |
616 | 621 | | |
617 | 622 | | |
618 | | - | |
| 623 | + | |
619 | 624 | | |
620 | 625 | | |
621 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3890 | 3890 | | |
3891 | 3891 | | |
3892 | 3892 | | |
3893 | | - | |
| 3893 | + | |
3894 | 3894 | | |
3895 | | - | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
3896 | 3898 | | |
3897 | 3899 | | |
3898 | 3900 | | |
3899 | 3901 | | |
3900 | | - | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
| 3907 | + | |
3901 | 3908 | | |
3902 | 3909 | | |
3903 | 3910 | | |
| |||
3908 | 3915 | | |
3909 | 3916 | | |
3910 | 3917 | | |
3911 | | - | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
3912 | 3925 | | |
3913 | 3926 | | |
3914 | 3927 | | |
3915 | | - | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
3916 | 3931 | | |
3917 | | - | |
| 3932 | + | |
3918 | 3933 | | |
3919 | 3934 | | |
3920 | 3935 | | |
| |||
3926 | 3941 | | |
3927 | 3942 | | |
3928 | 3943 | | |
3929 | | - | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
3930 | 3951 | | |
3931 | 3952 | | |
3932 | 3953 | | |
| |||
0 commit comments