Repository navigation
Commit e6f2e2c
committed
[JSC] DFG strength reduction should not crash when a folded string is too long
https://bugs.webkit.org/show_bug.cgi?id=328022
Reviewed by Yusuke Suzuki.
DFG strength reduction folds MakeRope, StrCat, MakeAtomString and StringReplace
of constant strings with a StringBuilder, and gives up when hasOverflowed() is
true. But the builders used the default policy, which crashes on overflow, so
the compiler thread aborted where the interpreter throws a RangeError.
This patch uses OverflowPolicy::RecordOverflow for them, and adds the missing
check to StringReplace before it commits to the fold.
Tests: JSTests/stress/dfg-strength-reduction-make-rope-overflow-three-strings.js
JSTests/stress/dfg-strength-reduction-make-rope-overflow.js
JSTests/stress/dfg-strength-reduction-string-replace-overflow.js
* JSTests/stress/dfg-strength-reduction-make-rope-overflow-three-strings.js: Added.
(shouldThrowRangeError):
(test):
* JSTests/stress/dfg-strength-reduction-make-rope-overflow.js: Added.
(shouldThrowRangeError):
(test):
* JSTests/stress/dfg-strength-reduction-string-replace-overflow.js: Added.
(shouldThrowRangeError):
(test):
* Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
Canonical link: https://commits.webkit.org/324184@main1 parent b5a0eff commit e6f2e2c
4 files changed
Lines changed: 111 additions & 16 deletions
File tree
- JSTests/stress
- Source/JavaScriptCore/dfg
| 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 | + | |
| 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 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
654 | | - | |
| 654 | + | |
655 | 655 | | |
656 | 656 | | |
657 | | - | |
| 657 | + | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
| 679 | + | |
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
| 683 | + | |
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| |||
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
692 | | - | |
| 692 | + | |
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| |||
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
704 | | - | |
| 704 | + | |
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| |||
1382 | 1382 | | |
1383 | 1383 | | |
1384 | 1384 | | |
1385 | | - | |
| 1385 | + | |
1386 | 1386 | | |
1387 | 1387 | | |
1388 | 1388 | | |
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
| 1416 | + | |
| 1417 | + | |
1421 | 1418 | | |
1422 | 1419 | | |
1423 | 1420 | | |
| |||
1438 | 1435 | | |
1439 | 1436 | | |
1440 | 1437 | | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
1441 | 1445 | | |
1442 | 1446 | | |
1443 | 1447 | | |
| |||
1457 | 1461 | | |
1458 | 1462 | | |
1459 | 1463 | | |
1460 | | - | |
| 1464 | + | |
1461 | 1465 | | |
1462 | | - | |
1463 | | - | |
| 1466 | + | |
1464 | 1467 | | |
1465 | | - | |
1466 | 1468 | | |
1467 | 1469 | | |
1468 | 1470 | | |
| |||
0 commit comments