[svn:parrot] r43359 - in branches/pmc_freeze_cleanup/src: . pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Fri Jan 1 20:31:12 UTC 2010


Author: plobsing
Date: Fri Jan  1 20:31:11 2010
New Revision: 43359
URL: https://trac.parrot.org/parrot/changeset/43359

Log:
various small changes moving towards eliminating extra_flags+EXTRA_IS_PROP_HASH

* clean up creation of pmcs being thawed
* reduce the scope of EXTRA_IS_PROP_HASH in default.visit
* extra_flags implies EXTRA_IS_PROP_HASH, no need to use an INTVAL in the image to denote this
* add assertions to freeze and thaw visit methods
* clean up thawing of seen/prophash pmcs

Modified:
   branches/pmc_freeze_cleanup/src/pmc/default.pmc
   branches/pmc_freeze_cleanup/src/pmc_freeze.c

Modified: branches/pmc_freeze_cleanup/src/pmc/default.pmc
==============================================================================
--- branches/pmc_freeze_cleanup/src/pmc/default.pmc	Fri Jan  1 18:37:07 2010	(r43358)
+++ branches/pmc_freeze_cleanup/src/pmc/default.pmc	Fri Jan  1 20:31:11 2010	(r43359)
@@ -1057,17 +1057,19 @@
     VTABLE void visit(visit_info *info) {
         /* default - mark prop hash */
         if (PMC_metadata(SELF) &&
-            info->extra_flags != EXTRA_IS_PROP_HASH) {
-            const INTVAL old_extra_flags = info->extra_flags;
-            info->extra_flags = EXTRA_IS_PROP_HASH;
-
+             info->extra_flags != EXTRA_IS_PROP_HASH) {
             /* place escape mark */
-            (info->visit_pmc_now)(INTERP, SELF, info);
+            {
+                const INTVAL old_extra_flags = info->extra_flags;
+                info->extra_flags = EXTRA_IS_PROP_HASH;
 
-            /* place and the prop hash */
-            (info->visit_pmc_now)(INTERP, PMC_metadata(SELF), info);
+                (info->visit_pmc_now)(INTERP, SELF, info);
 
-            info->extra_flags = old_extra_flags;
+                info->extra_flags = old_extra_flags;
+            }
+
+            /* place and the prop hash */
+            VISIT_PMC(INTERP, info, PMC_metadata(SELF));
         }
     }
 

Modified: branches/pmc_freeze_cleanup/src/pmc_freeze.c
==============================================================================
--- branches/pmc_freeze_cleanup/src/pmc_freeze.c	Fri Jan  1 18:37:07 2010	(r43358)
+++ branches/pmc_freeze_cleanup/src/pmc_freeze.c	Fri Jan  1 20:31:11 2010	(r43359)
@@ -592,23 +592,23 @@
     UINTVAL  n            = VTABLE_shift_integer(interp, info);
     UINTVAL  id           = PackID_get_PMCID(n);
     int      packid_flags = PackID_get_FLAGS(n);
-    PMC     *pmc;
-    info->extra_flags     = EXTRA_IS_NULL;
+    PMC     *pmc          = PMCNULL;
+    int      is_prophash  = 0;
+
+    PARROT_ASSERT(info->what == VISIT_THAW_NORMAL);
 
     switch (packid_flags) {
       case enum_PackID_extra_info: /* pmc has extra data */
-        info->extra_flags = VTABLE_shift_integer(interp, info);
+        is_prophash = 1;
         /* FALL THROUGH */
       case enum_PackID_seen:
         {
-            if (!id) /* got a NULL PMC */
-                pmc = PMCNULL;
-            else if ((pmc = id_list_get(interp, info, id))) {
-                if (info->extra_flags == EXTRA_IS_PROP_HASH) {
-                    info->thaw_ptr = &PMC_metadata(pmc);
-                    (info->visit_pmc_now)(interp, PMC_metadata(pmc), info);
-                    return;
-                }
+            if (id) /* got a non-NULL PMC */
+                pmc = id_list_get(interp, info, id);
+
+            if (is_prophash) {
+                VISIT_PMC(interp, info, PMC_metadata(pmc));
+                return;
             }
         }
         break;
@@ -618,13 +618,7 @@
             if (type <= 0 || type > interp->n_vtable_max)
                 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown PMC type to thaw %d", type);
 
-            /* BEGIN create appropriate pmc */
-            if (info->what == VISIT_THAW_NORMAL)
-                pmc = pmc_new_noinit(interp, type);
-            else
-                Parrot_ex_throw_from_c_args(interp, NULL, 1, "Illegal info->what type");
-            /* END create appropriate pmc */
-
+            pmc = pmc_new_noinit(interp, type);
             VTABLE_thaw(interp, pmc, info);
 
             {
@@ -663,6 +657,8 @@
     UINTVAL id;
     int packid_type;
 
+    PARROT_ASSERT(info->what == VISIT_FREEZE_NORMAL);
+
     if (PMC_IS_NULL(pmc)) {
         id   = 0;
         packid_type = enum_PackID_seen;
@@ -686,10 +682,7 @@
 
     VTABLE_push_integer(interp, info, PackID_new(id, packid_type));
 
-    if (packid_type == enum_PackID_extra_info) {
-        VTABLE_push_integer(interp, info, info->extra_flags);
-    }
-    else if (packid_type == enum_PackID_normal) {
+    if (packid_type == enum_PackID_normal) {
         Hash *hash = (Hash *)VTABLE_get_pointer(interp, info->seen);
         PARROT_ASSERT(pmc);
         VTABLE_push_integer(interp, info,


More information about the parrot-commits mailing list