#define PL_oldname (vTHX->Ioldname)
#define PL_op (vTHX->Iop)
#define PL_op_mask (vTHX->Iop_mask)
+#define PL_opfreehook (vTHX->Iopfreehook)
#define PL_opsave (vTHX->Iopsave)
#define PL_origalen (vTHX->Iorigalen)
#define PL_origargc (vTHX->Iorigargc)
#define PL_Ioldname PL_oldname
#define PL_Iop PL_op
#define PL_Iop_mask PL_op_mask
+#define PL_Iopfreehook PL_opfreehook
#define PL_Iopsave PL_opsave
#define PL_Iorigalen PL_origalen
#define PL_Iorigargc PL_origargc
PERLVARI(Ipeepp, peep_t, MEMBER_TO_FPTR(Perl_peep))
/* Pointer to peephole optimizer */
+PERLVARI(Iopfreehook, Perl_check_t, 0) /* op_free() hook */
+
PERLVARI(Imaxscream, I32, -1)
PERLVARI(Ireginterp_cnt,I32, 0) /* Whether "Regexp" was interpolated. */
PERLVARI(Iwatchaddr, char **, 0)
#include "keywords.h"
#define CALL_PEEP(o) CALL_FPTR(PL_peepp)(aTHX_ o)
+#define CALL_OPFREEHOOK(o) if (PL_opfreehook) CALL_FPTR(PL_opfreehook)(aTHX_ o)
#if defined(PL_OP_SLAB_ALLOC)
}
}
+ /* Call the op_free hook if it has been set. Do it now so that it's called
+ * at the right time for refcounted ops, but still before all of the kids
+ * are freed. */
+ CALL_OPFREEHOOK(o);
+
if (o->op_flags & OPf_KIDS) {
register OP *kid, *nextkid;
for (kid = cUNOPo->op_first; kid; kid = nextkid) {
#define PL_op (*Perl_Iop_ptr(aTHX))
#undef PL_op_mask
#define PL_op_mask (*Perl_Iop_mask_ptr(aTHX))
+#undef PL_opfreehook
+#define PL_opfreehook (*Perl_Iopfreehook_ptr(aTHX))
#undef PL_opsave
#define PL_opsave (*Perl_Iopsave_ptr(aTHX))
#undef PL_origalen
/* Pluggable optimizer */
PL_peepp = proto_perl->Ipeepp;
+ /* op_free() hook */
+ PL_opfreehook = proto_perl->Iopfreehook;
PL_stashcache = newHV();