This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
OPSLAB: always have opslab_size field
authorDavid Mitchell <davem@iabyn.com>
Sat, 13 Jul 2019 17:53:08 +0000 (18:53 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Aug 2019 10:30:29 +0000 (11:30 +0100)
Currently this struct only has the opslab_size field on debugging
builds. Change it so that this field is always present. This will make
it easier to not need a fake partial OPSLOT at the end of the slab with
a NULL opslot_next field, which will in turn simplify converting
opslot_next into  U16 size field shortly.

op.c
op.h

diff --git a/op.c b/op.c
index 0ccde31..7712124 100644 (file)
--- a/op.c
+++ b/op.c
@@ -236,10 +236,11 @@ S_new_slab(pTHX_ OPSLAB *head, size_t sz)
        perror("mmap failed");
        abort();
     }
-    slab->opslab_size = (U16)sz;
 #else
     slab = (OPSLAB *)PerlMemShared_calloc(sz, sizeof(I32 *));
 #endif
+    slab->opslab_size = (U16)sz;
+
 #ifndef WIN32
     /* The context is unused in non-Windows */
     PERL_UNUSED_CONTEXT;
diff --git a/op.h b/op.h
index 9a6d6fb..e97683e 100644 (file)
--- a/op.h
+++ b/op.h
@@ -701,8 +701,9 @@ struct opslab {
     OPSLAB *   opslab_head;            /* first slab in chain */
     OP *       opslab_freed;           /* chain of freed ops */
     size_t     opslab_refcnt;          /* number of ops (head slab only) */
+    U16                opslab_size;            /* size of slab in pointers,
+                                           including header */
 # ifdef PERL_DEBUG_READONLY_OPS
-    U16                opslab_size;            /* size of slab in pointers */
     bool       opslab_readonly;
 # endif
     OPSLOT     opslab_slots;           /* slots begin here */