diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-05-21 18:19:43 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-05-21 18:19:43 +0000 |
commit | 7b2c381cf37e4e4611c4a864b5d6f7134344e3e6 (patch) | |
tree | 8807ac10b976a808e6707f79fbff58de3476795c /ext | |
parent | 6e3207c2a1cd2d1644ac48e4d8ddd6742391e423 (diff) | |
download | perl-7b2c381cf37e4e4611c4a864b5d6f7134344e3e6.tar.gz |
Move the xpv_pv/xrv_rv member into the SV head, in a union with
IV and UV. Avoid allocating a body for IVs and RVs.
p4raw-id: //depot/perl@24531
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B/C.pm | 1 | ||||
-rw-r--r-- | ext/ByteLoader/bytecode.h | 32 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.c | 6 | ||||
-rw-r--r-- | ext/ByteLoader/byterun.h | 7 |
4 files changed, 25 insertions, 21 deletions
diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index 906c1a4e9c..51b357ef52 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -1416,7 +1416,6 @@ sub output_declarations { * Some pre-Standard compilers can't cope with initialising unions. Ho hum. */ typedef struct { - char * xpv_pv; /* pointer to malloced string */ STRLEN xpv_cur; /* length of xp_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xof_off; /* integer value */ diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h index 40c1e992d6..087e1511ad 100644 --- a/ext/ByteLoader/bytecode.h +++ b/ext/ByteLoader/bytecode.h @@ -31,14 +31,14 @@ typedef char *pvindex; #define BGET_PV(arg) STMT_START { \ BGET_U32(arg); \ if (arg) { \ - New(666, bstate->bs_pv.xpv_pv, arg, char); \ - bl_read(bstate->bs_fdata, bstate->bs_pv.xpv_pv, arg, 1); \ - bstate->bs_pv.xpv_len = arg; \ - bstate->bs_pv.xpv_cur = arg - 1; \ + New(666, bstate->bs_pv.pvx, arg, char); \ + bl_read(bstate->bs_fdata, bstate->bs_pv.pvx, arg, 1); \ + bstate->bs_pv.xpv.xpv_len = arg; \ + bstate->bs_pv.xpv.xpv_cur = arg - 1; \ } else { \ - bstate->bs_pv.xpv_pv = 0; \ - bstate->bs_pv.xpv_len = 0; \ - bstate->bs_pv.xpv_cur = 0; \ + bstate->bs_pv.pvx = 0; \ + bstate->bs_pv.xpv.xpv_len = 0; \ + bstate->bs_pv.xpv.xpv_cur = 0; \ } \ } STMT_END @@ -68,7 +68,7 @@ typedef char *pvindex; arg = (char *) ary; \ } while (0) -#define BGET_pvcontents(arg) arg = bstate->bs_pv.xpv_pv +#define BGET_pvcontents(arg) arg = bstate->bs_pv.pvx #define BGET_strconst(arg) STMT_START { \ for (arg = PL_tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \ arg = PL_tokenbuf; \ @@ -122,7 +122,7 @@ typedef char *pvindex; } STMT_END #define BSET_sv_magic(sv, arg) sv_magic(sv, Nullsv, arg, 0, 0) -#define BSET_mg_name(mg, arg) mg->mg_ptr = arg; mg->mg_len = bstate->bs_pv.xpv_cur +#define BSET_mg_name(mg, arg) mg->mg_ptr = arg; mg->mg_len = bstate->bs_pv.xpv.xpv_cur #define BSET_mg_namex(mg, arg) \ (mg->mg_ptr = (char*)SvREFCNT_inc((SV*)arg), \ mg->mg_len = HEf_SVKEY) @@ -130,9 +130,9 @@ typedef char *pvindex; #define BSET_sv_upgrade(sv, arg) (void)SvUPGRADE(sv, arg) #define BSET_xrv(sv, arg) SvRV_set(sv, arg) #define BSET_xpv(sv) do { \ - SvPV_set(sv, bstate->bs_pv.xpv_pv); \ - SvCUR_set(sv, bstate->bs_pv.xpv_cur); \ - SvLEN_set(sv, bstate->bs_pv.xpv_len); \ + SvPV_set(sv, bstate->bs_pv.pvx); \ + SvCUR_set(sv, bstate->bs_pv.xpv.xpv_cur); \ + SvLEN_set(sv, bstate->bs_pv.xpv.xpv_len); \ } while (0) #define BSET_xpv_cur(sv, arg) SvCUR_set(sv, arg) #define BSET_xpv_len(sv, arg) SvLEN_set(sv, arg) @@ -144,8 +144,8 @@ typedef char *pvindex; #define BSET_av_push(sv, arg) av_push((AV*)sv, arg) #define BSET_av_pushx(sv, arg) (AvARRAY(sv)[++AvFILLp(sv)] = arg) #define BSET_hv_store(sv, arg) \ - hv_store((HV*)sv, bstate->bs_pv.xpv_pv, bstate->bs_pv.xpv_cur, arg, 0) -#define BSET_pv_free(pv) Safefree(pv.xpv_pv) + hv_store((HV*)sv, bstate->bs_pv.pvx, bstate->bs_pv.xpv.xpv_cur, arg, 0) +#define BSET_pv_free(p) Safefree(p) #ifdef USE_ITHREADS @@ -155,7 +155,7 @@ typedef char *pvindex; STMT_START { \ SV* repointer; \ REGEXP* rx = arg ? \ - CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv_cur, cPMOPx(o)) : \ + CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv.xpv_cur, cPMOPx(o)) : \ Null(REGEXP*); \ if(av_len((AV*) PL_regex_pad[0]) > -1) { \ repointer = av_pop((AV*)PL_regex_pad[0]); \ @@ -174,7 +174,7 @@ typedef char *pvindex; #define BSET_pregcomp(o, arg) \ STMT_START { \ PM_SETRE(((PMOP*)o), (arg ? \ - CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv_cur, cPMOPx(o)): \ + CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv.xpv_cur, cPMOPx(o)): \ Null(REGEXP*))); \ } STMT_END diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c index 4506066279..7a8d378d50 100644 --- a/ext/ByteLoader/byterun.c +++ b/ext/ByteLoader/byterun.c @@ -116,7 +116,7 @@ byterun(pTHX_ register struct byteloader_state *bstate) { U32 arg; BGET_U32(arg); - BSET_stpv(bstate->bs_pv.xpv_pv, arg); + BSET_stpv(bstate->bs_pv.pvx, arg); break; } case INSN_LDSPECSV: /* 6 */ @@ -178,12 +178,12 @@ byterun(pTHX_ register struct byteloader_state *bstate) { STRLEN arg; BGET_PADOFFSET(arg); - bstate->bs_pv.xpv_cur = arg; + bstate->bs_pv.xpv.xpv_cur = arg; break; } case INSN_PV_FREE: /* 16 */ { - BSET_pv_free(bstate->bs_pv); + BSET_pv_free(bstate->bs_pv.pvx); break; } case INSN_SV_UPGRADE: /* 17 */ diff --git a/ext/ByteLoader/byterun.h b/ext/ByteLoader/byterun.h index dcd3374620..0ba48c6153 100644 --- a/ext/ByteLoader/byterun.h +++ b/ext/ByteLoader/byterun.h @@ -15,13 +15,18 @@ struct byteloader_fdata { int idx; }; +struct byteloader_pv_state { + char *pvx; + XPV xpv; +}; + struct byteloader_state { struct byteloader_fdata *bs_fdata; SV *bs_sv; void **bs_obj_list; int bs_obj_list_fill; int bs_ix; - XPV bs_pv; + struct byteloader_pv_state bs_pv; int bs_iv_overflows; }; |