summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-10 00:26:12 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-07-12 13:20:10 -0700
commit3107b51fb9c191a2ee82450f00c4568640538e12 (patch)
tree8dd54b1256f71ecfd6cd46f74ba82085dc6cc988 /perl.c
parent8f55039992b2378df3dcb99bb2ec67d80b7c8854 (diff)
downloadperl-3107b51fb9c191a2ee82450f00c4568640538e12.tar.gz
PERL_DEBUG_READONLY_OPS with the new allocator
I want to eliminate the old slab allocator (PL_OP_SLAB_ALLOC), but this useful debugging tool needs to be rewritten for the new one first. This is slightly better than under PL_OP_SLAB_ALLOC, in that CVs cre- ated after the main CV starts running will get read-only ops, too. It is when a CV finishes compiling and relinquishes ownership of the slab that the slab is made read-only, because at that point it should not be used again for allocation. BEGIN blocks are exempt, as they are processed before the Slab_to_ro call in newATTRSUB. The Slab_to_ro call must come at the very end, after LEAVE_SCOPE, because otherwise the ops freed via the stack (the SAVEFREEOP calls near the top of newATTRSUB) will make the slab writa- ble again. At that point, the BEGIN block has already been run and its slab freed. Maybe slabs belonging to BEGIN blocks can be made read-only later. Under PERL_DEBUG_READONLY_OPS, op slabs have two extra fields to record the size and readonliness of each slab. (Only the first slab in a CV’s slab chain uses the readonly flag, since it is conceptually simpler to treat them all as one unit.) Without recording this infor- mation manually, things become unbearably slow, the tests taking hours and hours instead of minutes.
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/perl.c b/perl.c
index 71e958a0fb..2c2cdab6b0 100644
--- a/perl.c
+++ b/perl.c
@@ -1218,7 +1218,7 @@ perl_destruct(pTHXx)
#endif
PL_sv_count = 0;
-#ifdef PERL_DEBUG_READONLY_OPS
+#if defined(PERL_DEBUG_READONLY_OPS) && defined(PL_OP_SLAB_ALLOC)
free(PL_slabs);
PL_slabs = NULL;
PL_slab_count = 0;
@@ -2394,7 +2394,12 @@ S_run_body(pTHX_ I32 oldscope)
call_list(oldscope, PL_initav);
}
#ifdef PERL_DEBUG_READONLY_OPS
+# ifdef PL_OP_SLAB_ALLOC
Perl_pending_Slabs_to_ro(aTHX);
+# else
+ if (PL_main_root && PL_main_root->op_slabbed)
+ Slab_to_ro(OpSLAB(PL_main_root));
+# endif
#endif
}