Commit a46ee10
committed
toke.c dont call libc's memcmp() to test 1 byte in Perl_scan_str()
delim_byte_len is almost always 1, open_delim_str is almost always
'"' or '\'' or something similar. I'm not sure which exact string of
PP code will make delim_byte_len not be 1, but it would be too rare to
optimize for but still must be supported.
Just test the char directly if its length of 1. Invoking libc memcmp()
requires 4 ABI inputs on any CPU, and while most of the code paths
above the memEQ() lines are constants directly initialized inside
Perl_scan_str(), one branch uses "utf8_to_uv_or_die(,,&delim_byte_len)"
which optimizes to Perl_utf8_to_uvchr_buf_helper(,,,&delim_byte_len)
making the value in STRLEN delim_byte_len unbounded according to all CC.
All CCs must assume the value Perl_utf8_to_uvchr_buf_helper() put inside
delim_byte_len could be a 4.7GB DVD or 25GB BD .iso file.
Put the retval of SvGROW() to use.
Don't let C auto var delim_byte_len escape with "&" op thru
utf8_to_uv_or_die(). Var delim_byte_len can never be stored in a register
again by any CC if it escapes and must be reread from C stack after ever
possible call if it escapes.1 parent 52d9c9c commit a46ee10
1 file changed
+20
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11645 | 11645 | | |
11646 | 11646 | | |
11647 | 11647 | | |
11648 | | - | |
| 11648 | + | |
| 11649 | + | |
11649 | 11650 | | |
11650 | | - | |
| 11651 | + | |
| 11652 | + | |
| 11653 | + | |
11651 | 11654 | | |
11652 | 11655 | | |
11653 | 11656 | | |
| |||
11764 | 11767 | | |
11765 | 11768 | | |
11766 | 11769 | | |
11767 | | - | |
| 11770 | + | |
11768 | 11771 | | |
11769 | | - | |
| 11772 | + | |
11770 | 11773 | | |
11771 | 11774 | | |
11772 | 11775 | | |
| |||
11784 | 11787 | | |
11785 | 11788 | | |
11786 | 11789 | | |
11787 | | - | |
11788 | | - | |
11789 | | - | |
11790 | | - | |
11791 | | - | |
| 11790 | + | |
| 11791 | + | |
| 11792 | + | |
| 11793 | + | |
| 11794 | + | |
| 11795 | + | |
| 11796 | + | |
11792 | 11797 | | |
11793 | 11798 | | |
11794 | 11799 | | |
11795 | 11800 | | |
11796 | 11801 | | |
11797 | 11802 | | |
11798 | | - | |
| 11803 | + | |
| 11804 | + | |
| 11805 | + | |
11799 | 11806 | | |
11800 | 11807 | | |
11801 | 11808 | | |
| |||
11824 | 11831 | | |
11825 | 11832 | | |
11826 | 11833 | | |
11827 | | - | |
| 11834 | + | |
| 11835 | + | |
| 11836 | + | |
11828 | 11837 | | |
11829 | 11838 | | |
11830 | 11839 | | |
| |||
0 commit comments