[svn:ponie] r339 - trunk/perl

[email protected] 24 Aug 2005 13:21:58 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
Author: nicholas
Date: Wed Aug 24 06:21:57 2005
New Revision: 339

Modified:
   trunk/perl/embedvar.h
   trunk/perl/intrpvar.h
   trunk/perl/perl.c
   trunk/perl/perlapi.h
Log:
Add a new global, PL_Refcounts, to hold the reference counts for SVs.
Initialise it with a AddrRegistry PMC and register it with the Parrot
interpreter at startup, unregister it at shutdown.


Modified: trunk/perl/embedvar.h
==============================================================================
--- trunk/perl/embedvar.h	(original)
+++ trunk/perl/embedvar.h	Wed Aug 24 06:21:57 2005
@@ -181,6 +181,7 @@
 #define PL_OpSpace		(vTHX->IOpSpace)
 #define PL_Parrot		(vTHX->IParrot)
 #define PL_Proc			(vTHX->IProc)
+#define PL_Refcounts		(vTHX->IRefcounts)
 #define PL_Sock			(vTHX->ISock)
 #define PL_StdIO		(vTHX->IStdIO)
 #define PL_amagic_generation	(vTHX->Iamagic_generation)
@@ -487,6 +488,7 @@
 #define PL_IOpSpace		PL_OpSpace
 #define PL_IParrot		PL_Parrot
 #define PL_IProc		PL_Proc
+#define PL_IRefcounts		PL_Refcounts
 #define PL_ISock		PL_Sock
 #define PL_IStdIO		PL_StdIO
 #define PL_Iamagic_generation	PL_amagic_generation

Modified: trunk/perl/intrpvar.h
==============================================================================
--- trunk/perl/intrpvar.h	(original)
+++ trunk/perl/intrpvar.h	Wed Aug 24 06:21:57 2005
@@ -542,6 +542,7 @@ PERLVARI(Ifdscript, int, -1)	/* fd for s
 PERLVARI(Isuidscript, int, -1)	/* fd for suid script */
 
 PERLVAR(IParrot, Parrot_Interp)
+PERLVAR(IRefcounts, Parrot_PMC)
 
 #ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
 /* File descriptor to talk to the child which dumps scalars.  */

Modified: trunk/perl/perl.c
==============================================================================
--- trunk/perl/perl.c	(original)
+++ trunk/perl/perl.c	Wed Aug 24 06:21:57 2005
@@ -256,6 +256,9 @@ perl_construct(pTHXx)
     PL_Parrot = Parrot_new(0);
     Parrot_init(PL_Parrot);
 
+    PL_Refcounts = Parrot_PMC_new(PL_Parrot, type_or_bail("AddrRegistry"));
+    Parrot_register_pmc(PL_Parrot, PL_Refcounts);
+
     if(getenv("PONIE_DEBUG_GC")) {
 	Parrot_set_flag(PL_Parrot, PARROT_GC_DEBUG_FLAG);
     }
@@ -1320,6 +1323,7 @@ perl_destruct(pTHXx)
 	PL_mess_sv = Nullsv;
     }
 
+    Parrot_unregister_pmc(PL_Parrot, PL_Refcounts);
     Parrot_destroy(PL_Parrot);
 
     return STATUS_NATIVE_EXPORT;

Modified: trunk/perl/perlapi.h
==============================================================================
--- trunk/perl/perlapi.h	(original)
+++ trunk/perl/perlapi.h	Wed Aug 24 06:21:57 2005
@@ -127,6 +127,8 @@ END_EXTERN_C
 #define PL_Parrot		(*Perl_IParrot_ptr(aTHX))
 #undef  PL_Proc
 #define PL_Proc			(*Perl_IProc_ptr(aTHX))
+#undef  PL_Refcounts
+#define PL_Refcounts		(*Perl_IRefcounts_ptr(aTHX))
 #undef  PL_Sock
 #define PL_Sock			(*Perl_ISock_ptr(aTHX))
 #undef  PL_StdIO