Skip to content

regcomp_invlist.c: Perl_populate_bitmap_from_invlist() optimize asserts #23376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from

Conversation

bulk88
Copy link
Contributor

@bulk88 bulk88 commented Jun 17, 2025

Inside re.xs/re.dll, Perl_populate_bitmap_from_invlist() has half a dozen if(!invlist) _assert_libc() call sites. Atleast
PERL_ARGS_ASSERT_POPULATE_BITMAP_FROM_INVLIST, invlist_iterinit(), invlist_iternext(), invlist_iterfinish() are all testing a C auto var that was proven inside PERL_ARGS_ASSERT_POPULATE_BITMAP_FROM_INVLIST to be true. "SV * invlist" is a C auto and I don't belive it is "reachable" under ISO C. Perl_populate_bitmap_from_invlist() never does & operator on it. But atleast MSVC 2022 is constantly re-reading this C auto. Also Perl_populate_bitmap_from_invlist() has only 1 call site, and MSVC hoisted/folded/inlined away "const Size_t len" since its always 8.

#define REGNODE_BBM_BITMAP_LEN /* 6 info bits requires 64 bits; 5 => 32 */ ((1 << (UTF_CONTINUATION_BYTE_INFO_BITS)) / CHARBITS)

since MSVC doesnt inline memcpy symbol func calls b/c WinPerl doesnt request it, make it obvious here to skip the libc call on all platforms.


  • This set of changes does not require a perldelta entry.

…ts()

Inside re.xs/re.dll,  Perl_populate_bitmap_from_invlist() has half a dozen
if(!invlist) _assert_libc() call sites. Atleast
PERL_ARGS_ASSERT_POPULATE_BITMAP_FROM_INVLIST, invlist_iterinit(),
invlist_iternext(), invlist_iterfinish() are all testing a C auto var that
was proven inside PERL_ARGS_ASSERT_POPULATE_BITMAP_FROM_INVLIST to be true.
"SV * invlist" is a C auto and I don't belive it is "reachable" under ISO
C. Perl_populate_bitmap_from_invlist() never does & operator on it. But
atleast MSVC 2022 is constantly re-reading this C auto. Also
Perl_populate_bitmap_from_invlist() has only 1 call site, and
MSVC hoisted/folded/inlined away "const Size_t len" since its always 8.

#define REGNODE_BBM_BITMAP_LEN /* 6 info bits requires 64 bits; 5 => 32 */
((1 << (UTF_CONTINUATION_BYTE_INFO_BITS)) / CHARBITS)

since MSVC doesnt inline memcpy symbol func calls b/c WinPerl doesnt
request it, make it obvious here to skip the libc call on all platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant