(diff name?) perl.h add SVVALIDIVX()/SVVAILDRV/SVVAILDNVX/SVVAILDPVX bitfield testers #23415
+202
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
edit: this commit originally had a misspelled in english title and misspelled in english macros, now fixed
I think the spelling and capitalization of the macros SVVALIDIVX()/SVVALIDRV/SVVALIDNVX/SVVALIDPVX could be better. But I couldn't think of anything better than what is in this commit. Anyone have ideas for better identifiers?
I cant think of much use right now for these macros as production perl code except for future improvements to
CV*
API, since varioussv_cat*()
/sv_set*()
and other parts of the SVPV APIs hate dealing withCV*
s. Either they have breakage, SEGVs or -DDEBUGGING only assert() fails.CV*
s are ultimately POK strings considering XS AUTOLOAD sub name passing, and that prototype string grammar has a rarely used provision for random 3P strings like HTTP URLs, JSON, and REST IDLs.Another reason I made them is, I really really don't like that SVt_PVGV sits below SVt_PVLV as a SEGV bomb. Since SVt_PVLV is the last traditional POK-able type. An algo that down cast to U8, shift, &, against a bitfield literal is much more production/runtime/speed reasonable, vs these 17 byte arrays. And XS modules will need an angel to save them from double or triple indirection to reach libperl data vars on WinOS and ELF.
SVt_PVCVs can not be passed to
SvPV();
IIRC but its been a year since I tried doing that. I did prove that cv_name()/GvNAME/CvNAME are unreachable from miniperl and PP. stringifying aCV*
the waycroak_xs_usage()
/cv_name()
do it, AFAIK is impossible from PP space using a standalone libperl.Add faster versions of the PL_valid_types_IVX[], PL_valid_types_PVX[], etc array tests intended for use in -O2/not -DDEBUGGING builds.
Currently the PL_valid_types_VX[] arrays are all 17 bytes long and only used for -DDEBUGGING assert()s in sv.h. The same information can be stored in a U32 literal integer instead. By making these macros use a U32 literal integer instead of a const array of bool/8 vars, there is no performance or overhead concerns anymore, if someone finds a reason to use these macros, in an optimized perl build. The U32 literal integers are now part of the CPU's instruction stream like in all other SV flag tests.
It is not known yet if there is any good reason to these faster macros, or the old slower PL_valid_types_VX[]s arrays, in an optimized blead perl or optimized stable perl. All "correct enough" code either in CORE or on CPAN already has macros or expressions using existing macros, to test whatever flags they need to test inside a SV head struct.