[svn:ponie] r358 - trunk/src/pmc
[email protected] 17 Oct 2005 19:47:02 -0000
| Newsgroups | perl.ponie.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: nicholas
Date: Mon Oct 17 12:47:02 2005
New Revision: 358
Modified:
trunk/src/pmc/perl5cargo_cult.pmc
Log:
For now, fudge the reference counts in the reference counting hash,
so that we don't prematurely hit reference count zero and have GC (quite
rightly) collect things from under us.
Modified: trunk/src/pmc/perl5cargo_cult.pmc
==============================================================================
--- trunk/src/pmc/perl5cargo_cult.pmc (original)
+++ trunk/src/pmc/perl5cargo_cult.pmc Mon Oct 17 12:47:02 2005
@@ -15,8 +15,9 @@
#include "ponie.h"
+#define FUDGE 1
#define PERL5_FLAGS(pmc) (((struct STRUCT_SV *)PMC_struct_val(pmc))->sv_flags)
-#define PERL5_REFCNT(interp, pmc) (Parrot_PMC_get_intval_pmckey(interp, PL_Refcounts, pmc))
+#define PERL5_REFCNT(interp, pmc) (Parrot_PMC_get_intval_pmckey(interp, PL_Refcounts, pmc) - 1)
#include "perl5cargo_cult_statics.c"
@@ -74,7 +75,12 @@ pmclass Perl5cargo_cult dynpmc {
/* This is the moral equivalent of SvREFCNT_inc(), and given that we
start at a 0 refcount, we're setting it to 1 here */
Parrot_PMC_set_pmc_pmckey(INTERP, PL_Refcounts, SELF, 0);
-
+#ifdef FUDGE
+ /* Except that until we have stack walking, we need to fudge things with
+ an extra reference count of our own, whihc we give up when we
+ transfer things to PL_sv_pining. */
+ Parrot_PMC_set_pmc_pmckey(INTERP, PL_Refcounts, SELF, 0);
+#endif
sv = MUMBLE(SELF);
ptr_table_store(PL_sv_arenatable, sv, sv);
@@ -99,7 +105,9 @@ pmclass Perl5cargo_cult dynpmc {
}
void destroy () {
- free(PMC_struct_val(SELF));
+ sv_dump(MUMBLE(SELF));
+ croak("DOD is attempting to collect an SV prematurely at %p", SELF);
+ /*free(PMC_struct_val(SELF));*/
}
void init_pmc (PMC* initializer) {
@@ -763,7 +771,9 @@ pmclass Perl5cargo_cult dynpmc {
if (!PL_in_clean_all) {
FREE_SV_DEBUG_FILE(p);
Parrot_PMC_push_pmc(INTERP, PL_sv_pining, SELF);
+#ifdef FUDGE
Parrot_PMC_delete_pmckey(INTERP, PL_Refcounts, SELF);
+#endif
}
break;
}