[svn:ponie] r374 - in trunk: . src/pmc

[email protected] 9 Dec 2005 17:05:42 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
Author: nicholas
Date: Fri Dec  9 09:05:42 2005
New Revision: 374

Added:
   trunk/src/pmc/perl5refcount.pmc   (contents, props changed)
Modified:
   trunk/write_makefile.pl
Log:
Add a new PMC class, Perl5RefCount, that serves soley to provide a hook to
allow the parrot GC's mark routine to walk the SV pointer table.


Added: trunk/src/pmc/perl5refcount.pmc
==============================================================================
--- (empty file)
+++ trunk/src/pmc/perl5refcount.pmc	Fri Dec  9 09:05:42 2005
@@ -0,0 +1,69 @@
+/* Perl5NULL.pmc -*- c -*-
+ *  Copyright: 2005 The Perl Foundation.  Please see the file README at
+ *  the top level of the distribution for licensing information.
+ *  CVS Info
+ *     $Id$
+ *  Overview:
+ *     This PMC provides a way for the parrot GC to walk the ptr_table holding
+ *     all the referenced SVs. It will go away when reference counting changes
+ *     to proper Mark & Sweep.
+ *  Data Structure and Algorithms:
+ *  History:
+ *  Notes:
+ *  References:
+ */
+
+#include "ponie.h"
+
+pmclass Perl5RefCount dynpmc group Perl5_group {
+    void init () {
+        PMC_struct_val(SELF) = NULL;
+        PObj_custom_mark_SET(SELF);
+    }
+
+    void mark () {
+        /* Yes this is evil and uses global variables. But it is temporary
+           code only needed until reference counting goes away, and this is
+           the simplest thing that could possibly work.  */
+        PTR_TBL_ENT_t **array;
+        PTR_TBL_ENT_t *entry;
+        UV riter;
+        UV max;
+
+        if (!PL_sv_arenatable || !PL_sv_arenatable->tbl_items) {
+            return;
+        }
+
+        array = PL_sv_arenatable->tbl_ary;
+        entry = array[0];
+        max = PL_sv_arenatable->tbl_max;
+        PL_sv_arenatable->iteration_nesting++;
+        riter = 0;
+
+        for (;;) {
+            if (entry) {
+                if (entry->oldval) {
+                    pobject_lives(INTERP, (PObj *)MUMBLE(entry->oldval));
+                }
+                entry = entry->next;
+            }
+            if (!entry) {
+                if (++riter > max) {
+                    break;
+                }
+                entry = array[riter];
+            }
+        }
+        --PL_sv_arenatable->iteration_nesting;
+    }
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/

Modified: trunk/write_makefile.pl
==============================================================================
--- trunk/write_makefile.pl	(original)
+++ trunk/write_makefile.pl	Fri Dec  9 09:05:42 2005
@@ -12,7 +12,7 @@ use FindBin;
 my $top = $FindBin::Bin;
 
 my @allPMCs = map {"Perl5$_"}
-  qw(cargo_cult base NULL Pining PVMG_mess sv_undef sv_yes
+  qw(cargo_cult base NULL Pining PVMG_mess sv_undef sv_yes RefCount
      IV NV RV PV PVIV PVNV PVMG PVBM PVGV PVLV PVAV PVHV PVCV PVFM PVIO);
 
 my $parrotdir = "$top/parrot";