From: Father Chrysostomos Date: Sun, 1 Jul 2012 00:37:25 +0000 (-0700) Subject: Put a cap on op slab sizes X-Git-Tag: upstream/5.20.0~6173 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6cee8c0491df869a38a97c153e5013ccd05f6bd;p=platform%2Fupstream%2Fperl.git Put a cap on op slab sizes If a subroutine is *really* big, we don’t want to allocate, say, 4MB for ops when just over 2 will do, just because there was one op more than could fit in 2MB. --- diff --git a/op.c b/op.c index ae0d6e8..ecda97e 100644 --- a/op.c +++ b/op.c @@ -305,6 +305,9 @@ Perl_Slab_Free(pTHX_ void *op) # ifndef PERL_SLAB_SIZE # define PERL_SLAB_SIZE 64 # endif +# ifndef PERL_MAX_SLAB_SIZE +# define PERL_MAX_SLAB_SIZE 2048 +# endif /* rounds up to nearest pointer */ # define SIZE_TO_PSIZE(x) (((x) + sizeof(I32 *) - 1)/sizeof(I32 *)) @@ -391,7 +394,9 @@ Perl_Slab_Alloc(pTHX_ size_t sz) /* Create a new slab. Make this one twice as big. */ slot = slab2->opslab_first; while (slot->opslot_next) slot = slot->opslot_next; - slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2); + slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2 > PERL_MAX_SLAB_SIZE + ? PERL_MAX_SLAB_SIZE + : DIFF(slab2, slot)*2); slab2->opslab_next = slab->opslab_next; slab->opslab_next = slab2; }