develooper Front page | perl.perl5.porters | Postings from November 2013

[perl #120547] [PATCH] remove almost unreachable NULL sv arg code from sv_2*n_flags

From:
Tony Cook via RT
Date:
November 20, 2013 23:58
Subject:
[perl #120547] [PATCH] remove almost unreachable NULL sv arg code from sv_2*n_flags
Message ID:
rt-4.0.18-4748-1384991889-1998.120547-15-0@perl.org
On Fri Nov 15 05:47:07 2013, bulk88 wrote:
> See attached patch. This will break (null segv) XS code that relies on
> the undocumented null-ok feature. perldelta entry added since this
> could
> in theory affect DarkPAN code. I didn't find any examples in the first
> couple pages using CPAN grep of anything but ppport.h type stuff using
> sv_2pv. "make test" passes with DEBUGGING and PERL_POISON for me. The
> code being removed was cargo culted from Perl 4.0 to 5.0 from STR api
> to
> SV api, and originates in 1.0. Core never uses the null branch. Its
> not
> sane for XS code that write their own sv flag checkers to use it
> either
> if SvFLAGS segved a couple instructions ago earlier in the caller func
> in typical XS/Perl C code. Since these 4 functions form the basics of
> all SV usage, slimming them is beneficial where possible. A very tiny,
> maybe noise, improvement is found in perlbench speed. There were no
> responses to null check removal idea in
> http://www.nntp.perl.org/group/perl.perl5.porters/2013/11/msg209687.html
> so this is the patch to do it.

I think this changes makes sense, I tried searching for unguarded sv_2(iv|nv|pv) uses with grep.cpan.me, but they were all guarded either through the associated SvXV macro or by other code that accessed the SV or its flags.

I don't expect any real performance improvement for optimized builds on recent compilers that support __atribute_nonnull__, since they tend to optimize the NULL checks away, but it should help for other builds/compilers.

I plan to apply this, so if anyone objects...

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=120547



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About