summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-10-02 17:28:00 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:39 +0000
commitb95eccd3c957974356edd3c076146c996d76431d (patch)
tree8e843bea3c515fcb3faee44d317eaab1e9261a67 /cop.h
parentbb3300d13ef3aaac93877cf6868160413dd618fa (diff)
downloadperl-b95eccd3c957974356edd3c076146c996d76431d.tar.gz
pp_given: avoid using savestack for old var
Add a new field, defsv_save, to struct block_givwhen, and use this to save the previous $_ in 'when(expr)' rather than saving it on the save stack. Also add POPWHEN and POPGIVEN macros. The former is a no-op for now.
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/cop.h b/cop.h
index a01ddda392..d455478396 100644
--- a/cop.h
+++ b/cop.h
@@ -836,12 +836,23 @@ struct block_loop {
/* given/when context */
struct block_givwhen {
OP *leave_op;
+ SV *defsv_save; /* the original $_ */
};
-#define PUSHGIVEN(cx) \
+#define PUSHWHEN(cx) \
cx->blk_givwhen.leave_op = cLOGOP->op_other;
-#define PUSHWHEN PUSHGIVEN
+#define PUSHGIVEN(cx, orig_var) \
+ PUSHWHEN(cx); \
+ cx->blk_givwhen.defsv_save = orig_var;
+
+#define POPWHEN(cx) \
+ NOOP;
+
+#define POPGIVEN(cx) \
+ SvREFCNT_dec(GvSV(PL_defgv)); \
+ GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;
+
/* context common to subroutines, evals and loops */
struct block {