[svn:parrot] r47880 - trunk/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Jun 26 20:54:21 UTC 2010


Author: chromatic
Date: Sat Jun 26 20:54:21 2010
New Revision: 47880
URL: https://trac.parrot.org/parrot/changeset/47880

Log:
[PMC] Cleaned and optimized CallContext's mark.

Modified:
   trunk/src/pmc/callcontext.pmc

Modified: trunk/src/pmc/callcontext.pmc
==============================================================================
--- trunk/src/pmc/callcontext.pmc	Sat Jun 26 20:54:18 2010	(r47879)
+++ trunk/src/pmc/callcontext.pmc	Sat Jun 26 20:54:21 2010	(r47880)
@@ -359,14 +359,18 @@
 mark_positionals(PARROT_INTERP, ARGIN(PMC *self))
 {
     ASSERT_ARGS(mark_positionals)
-    INTVAL size, i;
-    Pcc_cell *cells;
+    INTVAL size;
 
     GETATTR_CallContext_num_positionals(interp, self, size);
-    GETATTR_CallContext_positionals(interp, self, cells);
 
-    for (i = 0; i < size; ++i)
-        mark_cell(interp, &cells[i]);
+    if (size) {
+        Pcc_cell *cells;
+        INTVAL i;
+        GETATTR_CallContext_positionals(interp, self, cells);
+
+        for (i = 0; i < size; ++i)
+            mark_cell(interp, &cells[i]);
+    }
 }
 
 /* don't look now, but here goes encapsulation.... */
@@ -494,35 +498,32 @@
 */
     VTABLE void mark() {
         Hash     *hash;
+        PMC      *tmp;
         STRING   *short_sig;
         Pcc_cell *positionals;
-        INTVAL    num_positionals;
-        PMC      *arg_flags, *type_tuple, *return_flags, *tmp;
-        UINTVAL   i;
         UINTVAL  *n_regs_used;
-        Regs_ps   bp_ps;
 
         if (!PMC_data(SELF))
             return;
 
-        GET_ATTR_type_tuple(INTERP, SELF, type_tuple);
         GET_ATTR_short_sig(INTERP, SELF, short_sig);
-        GET_ATTR_arg_flags(INTERP, SELF, arg_flags);
-        GET_ATTR_return_flags(INTERP, SELF, return_flags);
-        GET_ATTR_num_positionals(INTERP, SELF, num_positionals);
-        GET_ATTR_positionals(INTERP, SELF, positionals);
-        GET_ATTR_hash(INTERP, SELF, hash);
-
-        Parrot_gc_mark_PMC_alive(INTERP, type_tuple);
         Parrot_gc_mark_STRING_alive(INTERP, short_sig);
-        Parrot_gc_mark_PMC_alive(INTERP, arg_flags);
-        Parrot_gc_mark_PMC_alive(INTERP, return_flags);
 
         mark_positionals(INTERP, SELF);
 
+        GET_ATTR_hash(INTERP, SELF, hash);
         if (hash)
             mark_hash(INTERP, hash);
 
+        GET_ATTR_arg_flags(INTERP, SELF, tmp);
+        Parrot_gc_mark_PMC_alive(INTERP, tmp);
+
+        GET_ATTR_return_flags(INTERP, SELF, tmp);
+        Parrot_gc_mark_PMC_alive(INTERP, tmp);
+
+        GET_ATTR_type_tuple(INTERP, SELF, tmp);
+        Parrot_gc_mark_PMC_alive(INTERP, tmp);
+
         GET_ATTR_caller_ctx(INTERP, SELF, tmp);
         Parrot_gc_mark_PMC_alive(INTERP, tmp);
 
@@ -551,21 +552,26 @@
         Parrot_gc_mark_PMC_alive(INTERP, tmp);
 
         GET_ATTR_n_regs_used(INTERP, SELF, n_regs_used);
-        if (!n_regs_used)
-            return;
 
-        GET_ATTR_bp_ps(INTERP, SELF, bp_ps);
-        for (i = 0; i < n_regs_used[REGNO_PMC]; ++i) {
-            PMC * const p = bp_ps.regs_p[-1L-(i)];
-            /* Original code from CTX_REG_PMC */
-            if (p)
-                Parrot_gc_mark_PMC_alive(INTERP, p);
-        }
+        if (n_regs_used) {
+            Regs_ps         bp_ps;
+            const UINTVAL   regs_p = n_regs_used[REGNO_PMC];
+            const UINTVAL   regs_s = n_regs_used[REGNO_STR];
+            UINTVAL         i;
+
+            GET_ATTR_bp_ps(INTERP, SELF, bp_ps);
+            for (i = 0; i < regs_p; ++i) {
+                PMC * const p = bp_ps.regs_p[-1L-(i)];
+                /* Original code from CTX_REG_PMC */
+                if (p)
+                    Parrot_gc_mark_PMC_alive(INTERP, p);
+            }
 
-        for (i = 0; i < n_regs_used[REGNO_STR]; ++i) {
-            STRING * const s = bp_ps.regs_s[i];
-            if (s)
-                Parrot_gc_mark_STRING_alive(INTERP, s);
+            for (i = 0; i < regs_s; ++i) {
+                STRING * const s = bp_ps.regs_s[i];
+                if (s)
+                    Parrot_gc_mark_STRING_alive(INTERP, s);
+            }
         }
     }
 


More information about the parrot-commits mailing list