From: Nicholas Clark Date: Sat, 19 Nov 2005 00:50:33 +0000 (+0000) Subject: With -DPURFIY we change the flags so that everything is allocated X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82048762d5eb8a6153083169da19032a4e6764a4;p=p5sagit%2Fp5-mst-13.2.git With -DPURFIY we change the flags so that everything is allocated directly. (Don't use arenas at all.) This seems a rather elegant way to simplify some of the code in sv.c by removing conditional compilation. p4raw-id: //depot/perl@26172 --- diff --git a/sv.c b/sv.c index 7f8a6b3..f2093fd 100644 --- a/sv.c +++ b/sv.c @@ -1233,7 +1233,13 @@ struct body_details { #define HADNV FALSE #define NONV TRUE +#ifdef PURIFY +/* With -DPURFIY we allocate everything directly, and don't use arenas. + This seems a rather elegant way to simplify some of the code below. */ +#define HASARENA FALSE +#else #define HASARENA TRUE +#endif #define NOARENA FALSE static const struct body_details bodies_by_type[] = { @@ -1551,7 +1557,8 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type) case SVt_PV: assert(new_type_details->size); -#ifndef PURIFY + /* We always allocated the full length item with PURIFY. To do this + we fake things so that arena is false for all 16 types.. */ if(new_type_details->arena) { /* This points to the start of the allocated area. */ new_body_inline(new_body, new_type_details->size, new_type); @@ -1560,10 +1567,6 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type) } else { new_body = new_NOARENAZ(new_type_details); } -#else - /* We always allocated the full length item with PURIFY */ - new_body = new_NOARENAZ(new_type_details); -#endif SvANY(sv) = new_body; if (old_type_details->copy) { @@ -5471,7 +5474,6 @@ Perl_sv_clear(pTHX_ register SV *sv) SvFLAGS(sv) &= SVf_BREAK; SvFLAGS(sv) |= SVTYPEMASK; -#ifndef PURIFY if (sv_type_details->arena) { del_body(((char *)SvANY(sv) - sv_type_details->offset), &PL_body_roots[type]); @@ -5479,11 +5481,6 @@ Perl_sv_clear(pTHX_ register SV *sv) else if (sv_type_details->size) { my_safefree(SvANY(sv)); } -#else - if (sv_type_details->size) { - my_safefree(SvANY(sv)); - } -#endif } /* @@ -10021,7 +10018,6 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param) case SVt_PVIV: case SVt_PV: assert(sv_type_details->copy); -#ifndef PURIFY if (sv_type_details->arena) { new_body_inline(new_body, sv_type_details->copy, sv_type); new_body @@ -10029,10 +10025,6 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param) } else { new_body = new_NOARENA(sv_type_details); } -#else - /* We always allocated the full length item with PURIFY */ - new_body = new_NOARENA(sv_type_details); -#endif } assert(new_body); SvANY(dstr) = new_body;