-
Notifications
You must be signed in to change notification settings - Fork 587
(diff name?) perl.h add SVVALIDIVX()/SVVALIDRV/SVVALILDNVX/SVVALIDPVX bitfield testers #23415
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
base: blead
Are you sure you want to change the base?
(diff name?) perl.h add SVVALIDIVX()/SVVALIDRV/SVVALILDNVX/SVVALIDPVX bitfield testers #23415
Conversation
BEFORE:
AFTER:
|
d1a5b41
to
c1ad847
Compare
repushed with C++ fixes |
|
- 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.
c1ad847
to
9a545bb
Compare
LOL. Good catch. Repushed. I said from the start I didn't like the spelling of the macros and thought they could be better, but I couldn't figure out why I didn't like the names I invented, I simply didn't like them. Too many UC letters in a row. But its P5P/generic C code style for constants and macros to be all UC. IDK enough, to pick a mixed case name like |
I think adding an underscore would make these much more readable |
Agreed, |
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.