Lines Matching defs:slab

225 /* the number of bytes to allocate for a slab with sz * sizeof(I32 **) space for op */
229 /* malloc a new op slab (suitable for attaching to PL_compcv).
235 OPSLAB *slab;
244 slab = (OPSLAB *) mmap(0, sz_bytes,
248 (unsigned long) sz, slab));
249 if (slab == MAP_FAILED) {
254 slab = (OPSLAB *)PerlMemShared_malloc(sz_bytes);
255 Zero(slab, sz_bytes, char);
257 slab->opslab_size = (U16)sz;
263 slab->opslab_free_space = sz;
264 slab->opslab_head = head ? head : slab;
265 DEBUG_S_warn((aTHX_ "allocated new op slab sz 0x%x, %p, head slab %p",
266 (unsigned int)slab->opslab_size, (void*)slab,
267 (void*)(slab->opslab_head)));
268 return slab;
273 #define link_freed_op(slab, o) S_link_freed_op(aTHX_ slab, o)
275 S_link_freed_op(pTHX_ OPSLAB *slab, OP *o) {
281 if (!slab->opslab_freed) {
283 slab->opslab_freed_size = index+1;
284 slab->opslab_freed = (OP**)PerlMemShared_calloc((slab->opslab_freed_size), sizeof(OP*));
286 if (!slab->opslab_freed)
289 else if (index >= slab->opslab_freed_size) {
295 OP **p = (OP **)PerlMemShared_realloc(slab->opslab_freed, newsize * sizeof(OP*));
300 Zero(p+slab->opslab_freed_size, newsize - slab->opslab_freed_size, OP *);
302 slab->opslab_freed = p;
303 slab->opslab_freed_size = newsize;
306 o->op_next = slab->opslab_freed[index];
307 slab->opslab_freed[index] = o;
312 * Allocates a new slab if necessary.
319 OPSLAB *head_slab; /* first slab in the chain */
325 /* We only allocate ops from the slab during subroutine compilation.
326 We find the slab via PL_compcv, hence that must be non-NULL. It could
329 which isn't using the slab allocator. If our sanity checks aren't met,
330 don't use a slab, but allocate the OP directly from the heap. */
341 accessed via CvROOT(). So if CvSTART() is NULL, no slab has been
354 /* The head slab for each CV maintains a free list of OPs. In particular, constant folding
371 DEBUG_S_warn((aTHX_ "realloced op at %p, slab %p, head slab %p",
387 /* The partially-filled slab is next in the chain. */
397 DEBUG_S_warn((aTHX_ "linked unused op space at %p, slab %p, head slab %p",
402 /* Create a new slab. Make this one twice as big. */
416 DEBUG_S_warn((aTHX_ "allocating op at %p, slab %p, head slab %p",
431 Perl_Slab_to_ro(pTHX_ OPSLAB *slab)
435 if (slab->opslab_readonly) return;
436 slab->opslab_readonly = 1;
437 for (; slab; slab = slab->opslab_next) {
439 (unsigned long) slab->opslab_size, (void *)slab));*/
440 if (mprotect(slab, OpSLABSizeBytes(slab->opslab_size), PROT_READ))
441 Perl_warn(aTHX_ "mprotect for %p %lu failed with %d", (void *)slab,
442 (unsigned long)slab->opslab_size, errno);
447 Perl_Slab_to_rw(pTHX_ OPSLAB *const slab)
453 if (!slab->opslab_readonly) return;
454 slab2 = slab;
460 Perl_warn(aTHX_ "mprotect RW for %p %lu failed with %d", (void *)slab,
464 slab->opslab_readonly = 0;
482 * the OP slab associated with that op.
489 OPSLAB *slab;
503 slab = OpSLAB(o);
507 link_freed_op(slab, o);
508 DEBUG_S_warn((aTHX_ "freeing op at %p, slab %p, head slab %p",
509 (void*)o, (void *)OpMySLAB(o), (void*)slab));
510 OpslabREFCNT_dec_padok(slab);
514 Perl_opslab_free_nopad(pTHX_ OPSLAB *slab)
522 opslab_free(slab);
530 * (Note that the reference count which PL_compcv held on the slab should
537 Perl_opslab_free(pTHX_ OPSLAB *slab)
542 DEBUG_S_warn((aTHX_ "freeing slab %p", (void*)slab));
543 assert(slab->opslab_refcnt == 1);
544 PerlMemShared_free(slab->opslab_freed);
546 slab2 = slab->opslab_next;
548 slab->opslab_refcnt = ~(size_t)0;
551 DEBUG_m(PerlIO_printf(Perl_debug_log, "Deallocate slab at %p\n",
552 (void*)slab));
553 if (munmap(slab, OpSLABSizeBytes(slab->opslab_size))) {
558 PerlMemShared_free(slab);
560 slab = slab2;
561 } while (slab);
564 /* like opslab_free(), but first calls op_free() on any ops in the slab
569 Perl_opslab_force_free(pTHX_ OPSLAB *slab)
576 slab2 = slab;
592 if (slab->opslab_refcnt == 1) goto free;
597 if (slab->opslab_refcnt > 1) { /* still referenced by the savestack */
599 assert(savestack_count == slab->opslab_refcnt-1);
602 slab->opslab_refcnt--;
606 opslab_free(slab);
614 OPSLAB *const slab = o->op_slabbed ? OpSLAB(o) : NULL;
615 if (slab && slab->opslab_readonly) {
616 Slab_to_rw(slab);
618 Slab_to_ro(slab);
631 OPSLAB *const slab = o->op_slabbed ? OpSLAB(o) : NULL;
635 if (slab && slab->opslab_readonly) {
636 Slab_to_rw(slab);
638 Slab_to_ro(slab);
949 /* Though ops may be freed twice, freeing the op after its slab is a
7506 * outer CV (the one whose slab holds the pm op). The
8204 * allocated below will be allocated from that CV's op slab, and so
10227 OPSLAB *slab = NULL;
10478 /* The cv no longer needs to hold a refcount on the slab, as CvROOT
10483 slab = (OPSLAB *)CvSTART(cv);
10557 if (slab)
10558 Slab_to_ro(slab);
10693 OPSLAB *slab = NULL;
11092 /* The cv no longer needs to hold a refcount on the slab, as CvROOT
11097 slab = (OPSLAB *)CvSTART(cv);
11159 if (slab)
11160 Slab_to_ro(slab);