[svn:ponie] r373 - trunk/src/pmc
[email protected] 9 Dec 2005 01:27:29 -0000
| Newsgroups | perl.ponie.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: nicholas
Date: Thu Dec 8 17:27:29 2005
New Revision: 373
Modified:
trunk/src/pmc/perl5cargo_cult.pmc
trunk/src/pmc/perl5cargo_cult_statics.c
Log:
Reference counts can be done throught the ptr_table
Modified: trunk/src/pmc/perl5cargo_cult.pmc
==============================================================================
--- trunk/src/pmc/perl5cargo_cult.pmc (original)
+++ trunk/src/pmc/perl5cargo_cult.pmc Thu Dec 8 17:27:29 2005
@@ -17,7 +17,7 @@
#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) - 1)
+#define PERL5_REFCNT(interp, pmc) ptr_table_val(PL_sv_arenatable, MUMBLE(pmc))
#include "perl5cargo_cult_statics.c"
@@ -72,17 +72,11 @@ pmclass Perl5cargo_cult dynpmc {
PMC_struct_val(SELF) = head = malloc(sizeof(struct STRUCT_SV));
PMC_pmc_val(SELF) = NULL;
- /* 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);
+ /* This is the moral equivalent of SvREFCNT_inc(), and given that we
+ start at a 0 refcount, we're setting it to 1 here */
ptr_table_inc(PL_sv_arenatable, sv);
++PL_sv_count;
@@ -741,12 +735,6 @@ pmclass Perl5cargo_cult dynpmc {
{
--PL_sv_count;
- if (!Perl_ptr_table_delete(PL_sv_arenatable, MUMBLE(SELF))) {
- Perl_croak("Attempt to free non-arena SV: 0x%"UVxf
- pTHX__FORMAT, PTR2UV(MUMBLE(SELF)) pTHX__VALUE);
- return;
- }
-
assert(PMC_struct_val(SELF));
if (key != Ponie_P_JOIN_CHOIR_INVISIBLE) {
/* Immortals will always report a non-zero reference count.
@@ -770,10 +758,19 @@ pmclass Perl5cargo_cult dynpmc {
if (!PL_in_clean_all) {
FREE_SV_DEBUG_FILE(p);
+ /* Anchor the PMC here. */
Parrot_PMC_push_pmc(INTERP, PL_sv_pining, SELF);
-#ifdef FUDGE
+
+ /* Release anchor here. */
Parrot_PMC_delete_pmckey(INTERP, PL_Refcounts, SELF);
-#endif
+
+ if (!Perl_ptr_table_delete(PL_sv_arenatable,
+ MUMBLE(SELF))) {
+ Perl_croak("Attempt to free non-arena SV: 0x%"UVxf
+ pTHX__FORMAT, PTR2UV(MUMBLE(SELF))
+ pTHX__VALUE);
+ return;
+ }
}
break;
}
Modified: trunk/src/pmc/perl5cargo_cult_statics.c
==============================================================================
--- trunk/src/pmc/perl5cargo_cult_statics.c (original)
+++ trunk/src/pmc/perl5cargo_cult_statics.c Thu Dec 8 17:27:29 2005
@@ -49,13 +49,13 @@ set_integer_keyed_int(Interp* interprete
if (value > 0) {
do {
/* This is the moral equivalent of SvREFCNT_inc() */
- Parrot_PMC_set_pmc_pmckey(interpreter, PL_Refcounts, pmc, 0);
+ ptr_table_inc(PL_sv_arenatable, MUMBLE(pmc));
} while (--value);
} else {
while (value) {
++value;
/* This is the moral equivalent of SvREFCNT_dec() */
- Parrot_PMC_delete_pmckey(interpreter, PL_Refcounts, pmc);
+ ptr_table_dec(PL_sv_arenatable, MUMBLE(pmc));
}
}
return;