From 51c777cac7e1ad2a9910a6b33dc5e64d48281952 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 26 Jun 2012 13:24:13 -0700 Subject: [PATCH] Enlarge the last slot on an op slab to fit For simplicity, op slots are never resized once they are allocated. But they are reused after they are freed, if they are big enough. When allocating the last op slot that will fit on a slab, we might as well enlarge the slot to contain whatever space is left over, so this slot, after being freed, can be reused for a larger op. --- op.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/op.c b/op.c index 874df5f..67f0cf1 100644 --- a/op.c +++ b/op.c @@ -397,6 +397,9 @@ Perl_Slab_Alloc(pTHX_ size_t sz) /* Create a new op slot */ slot = (OPSLOT *)((I32 **)slab2->opslab_first - sz); assert(slot >= &slab2->opslab_slots); + if (DIFF(&slab2->opslab_slots, slot) + < SIZE_TO_PSIZE(sizeof(OP)) + OPSLOT_HEADER_P) + slot = &slab2->opslab_slots; INIT_OPSLOT; DEBUG_S(Perl_warn(aTHX_ "allocating op at %p, slab %p", o, slab)); return (void *)o; -- 2.7.4