Get further through the build with read-only optrees. Free()ing cops
Nicholas Clark [Wed, 4 Apr 2007 17:22:02 +0000 (17:22 +0000)]
as currently implemented seems to want write activity to them. Also we
save a field in PL_curcop at one point, and sometimes this can be in
a read only COP. If so, the end of scope restoration is always to the
same value, but it's easier to cheat and skip the restoration than to
dig around and avoid the save.

p4raw-id: //depot/perl@30843

op.c
scope.c

diff --git a/op.c b/op.c
index 537322a..7c7e74f 100644 (file)
--- a/op.c
+++ b/op.c
@@ -449,8 +449,12 @@ Perl_op_free(pTHX_ OP *o)
 
     /* COP* is not cleared by op_clear() so that we may track line
      * numbers etc even after null() */
-    if (type == OP_NEXTSTATE || type == OP_SETSTATE || type == OP_DBSTATE)
+    if (type == OP_NEXTSTATE || type == OP_SETSTATE || type == OP_DBSTATE) {
+#ifdef PERL_DEBUG_READONLY_OPS
+       Slab_to_rw(o);
+#endif
        cop_free((COP*)o);
+    }
 
     op_clear(o);
     if (o->op_latefree) {
diff --git a/scope.c b/scope.c
index 6bd77da..d52d12d 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -707,7 +707,15 @@ Perl_leave_scope(pTHX_ I32 base)
            break;
        case SAVEt_I32:                         /* I32 reference */
            ptr = SSPOPPTR;
+#ifdef PERL_DEBUG_READONLY_OPS
+           {
+               const I32 val = SSPOPINT;
+               if (*(I32*)ptr != val)
+                   *(I32*)ptr = val;
+           }
+#else
            *(I32*)ptr = (I32)SSPOPINT;
+#endif
            break;
        case SAVEt_SPTR:                        /* SV* reference */
            ptr = SSPOPPTR;