@@ -310,7 +310,7 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
310
310
(I32**)OpSLOT(o) - OpSLOT(o)->opslot_offset,
311
311
(void*)head_slab));
312
312
313
- while (o && DIFF( OpSLOT(o), OpSLOT(o)->opslot_next) < sz) {
313
+ while (o && OpSLOT(o)->opslot_size < sz) {
314
314
DEBUG_S_warn((aTHX_ "Alas! too small"));
315
315
o = *(too = &o->op_next);
316
316
if (o) { DEBUG_S_warn((aTHX_ "found another free op at %p", (void*)o)); }
@@ -325,7 +325,7 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
325
325
326
326
#define INIT_OPSLOT(s) \
327
327
slot->opslot_offset = DIFF(slab2, slot) ; \
328
- slot->opslot_next = ((OPSLOT*)( (I32**)slot + s )); \
328
+ slot->opslot_size = s; \
329
329
slab2->opslab_free_space -= s; \
330
330
o = &slot->opslot_op; \
331
331
o->op_slabbed = 1
@@ -535,7 +535,9 @@ Perl_opslab_force_free(pTHX_ OPSLAB *slab)
535
535
((I32**)&slab2->opslab_slots + slab2->opslab_free_space);
536
536
OPSLOT *end = (OPSLOT*)
537
537
((I32**)slab2 + slab2->opslab_size);
538
- for (; slot <= end -1; slot = slot->opslot_next) {
538
+ for (; slot <= end -1;
539
+ slot = (OPSLOT*) ((I32**)slot + slot->opslot_size) )
540
+ {
539
541
if (slot->opslot_op.op_type != OP_FREED
540
542
&& !(slot->opslot_op.op_savefree
541
543
#ifdef DEBUGGING
@@ -9281,10 +9283,13 @@ Perl_newFOROP(pTHX_ I32 flags, OP *sv, OP *expr, OP *block, OP *cont)
9281
9283
/* for my $x () sets OPpLVAL_INTRO;
9282
9284
* for our $x () sets OPpOUR_INTRO */
9283
9285
loop->op_private = (U8)iterpflags;
9286
+
9287
+ /* upgrade loop from a LISTOP to a LOOPOP;
9288
+ * keep it in-place if there's space */
9284
9289
if (loop->op_slabbed
9285
- && DIFF(loop, OpSLOT(loop)->opslot_next)
9286
- < SIZE_TO_PSIZE(sizeof(LOOP)))
9290
+ && OpSLOT(loop)->opslot_size < SIZE_TO_PSIZE(sizeof(LOOP)))
9287
9291
{
9292
+ /* no space; allocate new op */
9288
9293
LOOP *tmp;
9289
9294
NewOp(1234,tmp,1,LOOP);
9290
9295
Copy(loop,tmp,1,LISTOP);
@@ -9295,6 +9300,7 @@ Perl_newFOROP(pTHX_ I32 flags, OP *sv, OP *expr, OP *block, OP *cont)
9295
9300
}
9296
9301
else if (!loop->op_slabbed)
9297
9302
{
9303
+ /* loop was malloc()ed */
9298
9304
loop = (LOOP*)PerlMemShared_realloc(loop, sizeof(LOOP));
9299
9305
OpLASTSIB_set(loop->op_last, (OP*)loop);
9300
9306
}
0 commit comments