Perl_op_refcnt_inc() and Perl_op_refcnt_dec() now both take care to leave the
slab in the same state as they found it. Previously both would
unconditionally make the slab read-write.
Perl_op_refcnt_inc(pTHX_ OP *o)
{
if(o) {
- Slab_to_rw(o);
- ++o->op_targ;
+ OPSLAB *const slab = o->op_slabbed ? OpSLAB(o) : NULL;
+ if (slab && slab->opslab_readonly) {
+ Slab_to_rw(o);
+ ++o->op_targ;
+ Slab_to_ro(slab);
+ } else {
+ ++o->op_targ;
+ }
}
return o;
PADOFFSET
Perl_op_refcnt_dec(pTHX_ OP *o)
{
+ PADOFFSET result;
+ OPSLAB *const slab = o->op_slabbed ? OpSLAB(o) : NULL;
+
PERL_ARGS_ASSERT_OP_REFCNT_DEC;
- Slab_to_rw(o);
- return --o->op_targ;
+
+ if (slab && slab->opslab_readonly) {
+ Slab_to_rw(o);
+ result = --o->op_targ;
+ Slab_to_ro(slab);
+ } else {
+ result = --o->op_targ;
+ }
+ return result;
}
#endif
/*