summaryrefslogtreecommitdiff
path: root/pad.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-08-16 16:46:20 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-08-21 16:51:14 -0700
commit7261499db89d7afd6c64079406dc32f10acfe512 (patch)
treed28b4da71ab3604a3a0b1258a85fe498d1615cef /pad.h
parentb70d55581aad461af858eb07a2e80ed5fcc653c1 (diff)
downloadperl-7261499db89d7afd6c64079406dc32f10acfe512.tar.gz
Stop padlists from being AVs
In order to fix a bug, I need to add new fields to padlists. But I cannot easily do that as long as they are AVs. So I have created a new padlist struct. This not only allows me to extend the padlist struct with new members as necessary, but also saves memory, as we now have a three-pointer struct where before we had a whole SV head (3-4 pointers) + XPVAV (5 pointers). This will unfortunately break half of CPAN, but the pad API docs clearly say this: NOTE: this function is experimental and may change or be removed without notice. This would have broken B::Debug, but a patch sent upstream has already been integrated into blead with commit 9d2d23d981.
Diffstat (limited to 'pad.h')
-rw-r--r--pad.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/pad.h b/pad.h
index 890ddd1ba3..843cf50206 100644
--- a/pad.h
+++ b/pad.h
@@ -27,6 +27,13 @@ typedef U64TYPE PADOFFSET;
#endif
#define NOT_IN_PAD ((PADOFFSET) -1)
+
+struct padlist {
+ SSize_t xpadl_max; /* max index for which array has space */
+ PAD ** xpadl_alloc; /* pointer to beginning of array of AVs */
+};
+
+
/* a value that PL_cop_seqmax is guaranteed never to be,
* flagging that a lexical is being introduced, or has not yet left scope
*/
@@ -209,6 +216,10 @@ Restore the old pad saved into the local variable opad by PAD_SAVE_LOCAL()
=cut
*/
+#define PADLIST_ARRAY(pl) (pl)->xpadl_alloc
+#define PADLIST_MAX(pl) (pl)->xpadl_max
+#define PADLIST_REFCNT(pl) 1 /* reserved for future use */
+
#ifdef DEBUGGING
# define PAD_SV(po) pad_sv(po)
# define PAD_SETSV(po,sv) pad_setsv(po,sv)
@@ -220,12 +231,13 @@ Restore the old pad saved into the local variable opad by PAD_SAVE_LOCAL()
#define PAD_SVl(po) (PL_curpad[po])
#define PAD_BASE_SV(padlist, po) \
- (AvARRAY(padlist)[1]) \
- ? AvARRAY(MUTABLE_AV((AvARRAY(padlist)[1])))[po] : NULL;
+ (PADLIST_ARRAY(padlist)[1]) \
+ ? AvARRAY(MUTABLE_AV((PADLIST_ARRAY(padlist)[1])))[po] \
+ : NULL;
#define PAD_SET_CUR_NOSAVE(padlist,nth) \
- PL_comppad = (PAD*) (AvARRAY(padlist)[nth]); \
+ PL_comppad = (PAD*) (PADLIST_ARRAY(padlist)[nth]); \
PL_curpad = AvARRAY(PL_comppad); \
DEBUG_Xv(PerlIO_printf(Perl_debug_log, \
"Pad 0x%"UVxf"[0x%"UVxf"] set_cur depth=%d\n", \