Skip to content
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

Newsvuvnviv taint api speedup #22662

Open
wants to merge 6 commits into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -3433,7 +3433,7 @@ Adp |SV * |sv_strftime_tm |NN SV *fmt \
Adp |SV * |sv_string_from_errnum \
|int errnum \
|NULLOK SV *tgtsv
CMbdp |void |sv_taint |NN SV *sv
ACdp |SV * |sv_taint |NN SV *sv
CRdp |bool |sv_tainted |NN SV * const sv
Adip |bool |SvTRUE |NULLOK SV *sv
Cdp |I32 |sv_true |NULLOK SV * const sv
Expand Down
1 change: 1 addition & 0 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@
# define sv_strftime_ints(a,b,c,d,e,f,g,h) Perl_sv_strftime_ints(aTHX_ a,b,c,d,e,f,g,h)
# define sv_strftime_tm(a,b) Perl_sv_strftime_tm(aTHX_ a,b)
# define sv_string_from_errnum(a,b) Perl_sv_string_from_errnum(aTHX_ a,b)
# define sv_taint(a) Perl_sv_taint(aTHX_ a)
# define sv_tainted(a) Perl_sv_tainted(aTHX_ a)
# define sv_true(a) Perl_sv_true(aTHX_ a)
# define sv_uni_display(a,b,c,d) Perl_sv_uni_display(aTHX_ a,b,c,d)
Expand Down
3 changes: 1 addition & 2 deletions embedvar.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,12 +1130,12 @@ Perl_hv_scalar(pTHX_ HV *hv)
if (u <= (UV)IV_MAX) {
SvIV_set(sv, (IV)u);
(void)SvIOK_only(sv);
SvTAINT(sv);
sv = SvTAINTTC(sv);
} else {
SvIV_set(sv, 0);
SvUV_set(sv, u);
(void)SvIOK_only_UV(sv);
SvTAINT(sv);
sv = SvTAINTTC(sv);
}

return sv;
Expand Down
5 changes: 3 additions & 2 deletions intrpvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ PERLVAR(I, multideref_pc, UNOP_AUX_item *)
PERLVAR(I, curpm, PMOP *) /* what to do \ interps in REs from */
PERLVAR(I, curpm_under, PMOP *) /* what to do \ interps in REs from */

PERLVAR(I, tainting, bool) /* ? doing taint checks */
PERLVARI(I, tainted, bool, FALSE) /* using variables controlled by $< */
/* bool PL_tainting --- ? doing taint checks */
/* bool PL_tainted --- using variables controlled by $< */
PERLVAR(I, taint, TAINT_U)

/* PL_delaymagic is currently used for two purposes: to assure simultaneous
* updates in ($<,$>) = ..., and to assure atomic update in push/unshift
Expand Down
17 changes: 0 additions & 17 deletions mathoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,6 @@ Perl_sv_unref(pTHX_ SV *sv)
sv_unref_flags(sv, 0);
}

/*
=for apidoc_section $tainting
=for apidoc sv_taint

Taint an SV. Use C<SvTAINTED_on> instead.

=cut
*/

void
Perl_sv_taint(pTHX_ SV *sv)
{
PERL_ARGS_ASSERT_SV_TAINT;

sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
}

/* sv_2iv() is now a macro using Perl_sv_2iv_flags();
* this function provided for binary compatibility only
*/
Expand Down
11 changes: 11 additions & 0 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ perl_construct(pTHXx)
SvREADONLY_on(&PL_sv_placeholder);
SvREFCNT(&PL_sv_placeholder) = SvREFCNT_IMMORTAL;

STATIC_ASSERT_STMT(
sizeof(((TAINT_U *)0)->both)
== (sizeof(((TAINT_U *)0)->u.tainting) + sizeof(((TAINT_U *)0)->u.tainted))
);
STATIC_ASSERT_STMT(
sizeof(((TAINT_U *)0)->both)
== (STRUCT_OFFSET(TAINT_U, u.tainted) + sizeof(((TAINT_U *)0)->u.tainted))
);
STATIC_ASSERT_STMT(STRUCT_OFFSET(TAINT_U, both) == STRUCT_OFFSET(TAINT_U, u.tainting));
/* PL_taint.u.both = 0; */

PL_sighandlerp = Perl_sighandler;
PL_sighandler1p = Perl_sighandler1;
PL_sighandler3p = Perl_sighandler3;
Expand Down
17 changes: 17 additions & 0 deletions perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,8 @@ symbol would not be defined on C<L</EBCDIC>> platforms.
* know what you're doing: tests and CPAN modules' tests are bound to fail.
*/
#ifdef NO_TAINT_SUPPORT
# define PL_tainting PL_taint.u.tainting
# define PL_tainted PL_taint.u.tainted
# define TAINT NOOP
# define TAINT_NOT NOOP
# define TAINT_IF(c) NOOP
Expand All @@ -948,6 +950,7 @@ symbol would not be defined on C<L</EBCDIC>> platforms.
# define TAINT_set(s) NOOP
# define TAINT_get 0
# define TAINTING_get 0
# define TAINT_AND_TAINTING_get 0
# define TAINTING_set(s) NOOP
# define TAINT_WARN_get 0
# define TAINT_WARN_set(s) NOOP
Expand Down Expand Up @@ -1014,6 +1017,10 @@ violations are fatal.

=cut
*/

#define PL_tainting PL_taint.u.tainting
#define PL_tainted PL_taint.u.tainted

/* Set to tainted if we are running under tainting mode */
# define TAINT (PL_tainted = PL_tainting)

Expand All @@ -1027,6 +1034,8 @@ violations are fatal.
# define TAINT_set(s) (PL_tainted = cBOOL(s))
# define TAINT_get (cBOOL(UNLIKELY(PL_tainted))) /* Is something tainted? */
# define TAINTING_get (cBOOL(UNLIKELY(PL_tainting)))
/* Efficient version of (PL_tainted && PL_tainting) */
# define TAINT_AND_TAINTING_get (UNLIKELY(PL_taint.both == (TRUE | (TRUE << 8))))
# define TAINTING_set(s) (PL_tainting = cBOOL(s))
# define TAINT_WARN_get (PL_taint_warn)
# define TAINT_WARN_set(s) (PL_taint_warn = cBOOL(s))
Expand Down Expand Up @@ -3309,6 +3318,14 @@ typedef struct padname PADNAME;
#include "handy.h"
#include "charclass_invlists.h"

typedef union {
U16 both;
struct {
bool tainting;
bool tainted;
} u;
} TAINT_U;

#if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_RAWIO)
# if LSEEKSIZE == 8 && !defined(USE_64_BIT_RAWIO)
# define USE_64_BIT_RAWIO /* implicit */
Expand Down
10 changes: 5 additions & 5 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading