summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-08-05 00:48:00 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-08-05 13:18:58 -0700
commitbb02a38febc60a289c616282d720015be97842a4 (patch)
treec4815a82ac0e870532c5d44f70f4a6fb04c9c0bd
parentdea823b3f7c22fea989211dbe1bed7a34d49e39a (diff)
downloadperl-bb02a38febc60a289c616282d720015be97842a4.tar.gz
Add a depth field to formats
Instead of lengthening the struct, we can reuse SvCUR, which is cur- rently unused.
-rw-r--r--cv.h14
-rw-r--r--dump.c3
-rw-r--r--ext/B/B.xs6
-rw-r--r--sv.h7
4 files changed, 22 insertions, 8 deletions
diff --git a/cv.h b/cv.h
index e2644e1de1..a94d2481bd 100644
--- a/cv.h
+++ b/cv.h
@@ -61,13 +61,21 @@ See L<perlguts/Autoloading with XSUBs>.
(CvFILE(sv) = CopFILE(cop), CvDYNFILE_off(sv))
#endif
#define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)))
+PERL_STATIC_INLINE I32 *
+S_CvDEPTHp(const CV * const sv)
+{
+ return SvTYPE(sv) == SVt_PVCV
+ ? &((XPVCV*)SvANY(sv))->xcv_depth
+ : &((XPVCV*)SvANY(sv))->xpv_cur_u.xpvcuru_fmdepth;
+}
#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
# define CvDEPTH(sv) (*({const CV *const _cvdepth = (const CV *)sv; \
- assert(SvTYPE(_cvdepth) == SVt_PVCV); \
- &((XPVCV*)SvANY(_cvdepth))->xcv_depth; \
+ assert(SvTYPE(_cvdepth) == SVt_PVCV \
+ || SvTYPE(_cvdepth) == SVt_PVFM); \
+ S_CvDEPTHp(_cvdepth); \
}))
#else
-# define CvDEPTH(sv) ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_depth
+# define CvDEPTH(sv) *S_CvDEPTHp((const CV *)sv)
#endif
#define CvPADLIST(sv) ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_padlist
#define CvOUTSIDE(sv) ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_outside
diff --git a/dump.c b/dump.c
index ca5d12584c..0c5cc75d81 100644
--- a/dump.c
+++ b/dump.c
@@ -1920,8 +1920,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
do_gvgv_dump(level, file, " GVGV::GV", CvGV(sv));
Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", CvFILE(sv));
- if (type == SVt_PVCV)
- Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
+ Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)CvFLAGS(sv));
Perl_dump_indent(aTHX_ level, file, " OUTSIDE_SEQ = %"UVuf"\n", (UV)CvOUTSIDE_SEQ(sv));
Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%"UVxf"\n", PTR2UV(CvPADLIST(sv)));
diff --git a/ext/B/B.xs b/ext/B/B.xs
index 9c9133b9ff..2c3d7f8b94 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -1449,7 +1449,6 @@ MODULE = B PACKAGE = B::IV
#define PVCV_stash_ix sv_SVp | offsetof(struct xpvcv, xcv_stash)
#define PVCV_gv_ix sv_SVp | offsetof(struct xpvcv, xcv_gv)
#define PVCV_file_ix sv_char_pp | offsetof(struct xpvcv, xcv_file)
-#define PVCV_depth_ix sv_I32p | offsetof(struct xpvcv, xcv_depth)
#define PVCV_padlist_ix sv_SVp | offsetof(struct xpvcv, xcv_padlist)
#define PVCV_outside_ix sv_SVp | offsetof(struct xpvcv, xcv_outside)
#define PVCV_outside_seq_ix sv_U32p | offsetof(struct xpvcv, xcv_outside_seq)
@@ -1505,7 +1504,6 @@ IVX(sv)
B::CV::STASH = PVCV_stash_ix
B::CV::GV = PVCV_gv_ix
B::CV::FILE = PVCV_file_ix
- B::CV::DEPTH = PVCV_depth_ix
B::CV::PADLIST = PVCV_padlist_ix
B::CV::OUTSIDE = PVCV_outside_ix
B::CV::OUTSIDE_SEQ = PVCV_outside_seq_ix
@@ -1984,6 +1982,10 @@ CvSTART(cv)
PUSHs(make_op_object(aTHX_ CvISXSUB(cv) ? NULL
: ix ? CvROOT(cv) : CvSTART(cv)));
+I32
+CvDEPTH(cv)
+ B::CV cv
+
void
CvXSUB(cv)
B::CV cv
diff --git a/sv.h b/sv.h
index b2385d0a6d..4c9bc55e92 100644
--- a/sv.h
+++ b/sv.h
@@ -415,9 +415,14 @@ perform the upgrade if necessary. See C<svtype>.
#define _XPV_HEAD \
HV* xmg_stash; /* class package */ \
union _xmgu xmg_u; \
- STRLEN xpv_cur; /* length of svu_pv as a C string */ \
+ union { \
+ STRLEN xpvcuru_cur; /* length of svu_pv as a C string */ \
+ I32 xpvcuru_fmdepth; \
+ } xpv_cur_u; \
STRLEN xpv_len /* allocated size */
+#define xpv_cur xpv_cur_u.xpvcuru_cur
+
union _xnvu {
NV xnv_nv; /* numeric value, if any */
HV * xgv_stash;