[svn:parrot] r48272 - trunk/src

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Aug 3 04:38:50 UTC 2010


Author: chromatic
Date: Tue Aug  3 04:38:49 2010
New Revision: 48272
URL: https://trac.parrot.org/parrot/changeset/48272

Log:
[freeze] Tidied code; no functional changes.

Modified:
   trunk/src/pmc_freeze.c

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Tue Aug  3 03:59:08 2010	(r48271)
+++ trunk/src/pmc_freeze.c	Tue Aug  3 04:38:49 2010	(r48272)
@@ -11,7 +11,7 @@
 Thawing PMCs uses a list with (maximum) size of the amount of PMCs to
 keep track of retrieved PMCs.
 
-The individual information of PMCs is frozen/thawed by their vtables.
+PMCs freeze and thaw their own information through their vtables.
 
 To avoid recursion, the whole functionality is driven by
 C<< pmc->vtable->visit >>, which is called for the first PMC initially.
@@ -59,12 +59,13 @@
     return VTABLE_get_string(interp, image);
 }
 
+
 /*
 
 =item C<STRING * Parrot_freeze_pbc(PARROT_INTERP, PMC *pmc, const
 PackFile_ConstTable *pf)>
 
-Freeze to a PackFile.
+Freezes a PMC to a PackFile.
 
 =cut
 
@@ -81,7 +82,8 @@
     PMC * const pf_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
     DECL_CONST_CAST;
 
-    VTABLE_set_pointer(interp, pf_pmc, PARROT_const_cast(void *, (const void*)pf));
+    VTABLE_set_pointer(interp, pf_pmc,
+        PARROT_const_cast(void *, (const void *)pf));
 
     visitor  = Parrot_pmc_new_init(interp, enum_class_ImageIO, pf_pmc);
     VTABLE_set_pmc(interp, visitor, pmc);
@@ -94,7 +96,7 @@
 
 =item C<UINTVAL Parrot_freeze_size(PARROT_INTERP, PMC *pmc)>
 
-Get the size of an image to be frozen without allocating a large buffer.
+Gets the size of an image to be frozen without allocating a large buffer.
 
 =cut
 
@@ -106,21 +108,21 @@
 Parrot_freeze_size(PARROT_INTERP, ARGIN(PMC *pmc))
 {
     ASSERT_ARGS(Parrot_freeze_size)
-    UINTVAL int_result;
     PMC    *pmc_result;
     PMC    * const visitor = Parrot_pmc_new(interp, enum_class_ImageIOSize);
     VTABLE_set_pmc(interp, visitor, pmc);
     pmc_result = VTABLE_get_pmc(interp, visitor);
-    int_result = VTABLE_get_integer(interp, pmc_result);
-    return int_result;
+
+    return VTABLE_get_integer(interp, pmc_result);
 }
 
+
 /*
 
 =item C<UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP, PMC *pmc, const
 PackFile_ConstTable *pf)>
 
-Get the size of an image if it were created using C<Parrot_freeze_pbc>.
+Gets the size of an image if it were created using C<Parrot_freeze_pbc>.
 
 =cut
 
@@ -136,7 +138,8 @@
     PMC *visitor, *pmc_result;
     DECL_CONST_CAST;
 
-    VTABLE_set_pointer(interp, pf_pmc, PARROT_const_cast(void *, (const void *)pf));
+    VTABLE_set_pointer(interp, pf_pmc,
+        PARROT_const_cast(void *, (const void *)pf));
 
     visitor = Parrot_pmc_new_init(interp, enum_class_ImageIOSize, pf_pmc);
     VTABLE_set_pmc(interp, visitor, pmc);
@@ -150,7 +153,7 @@
 
 =item C<PMC * Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)>
 
-Get the strings of a PMC to be frozen.
+Gets the strings of a PMC to be frozen.
 
 =cut
 
@@ -175,11 +178,10 @@
 
 Thaws a PMC.  Called from the C<thaw> opcode.
 
-For now it seems cheaper to use a list for remembering contained
-aggregates. We could of course decide dynamically, which strategy to
-use, e.g.: given a big image, the first thawed item is a small
-aggregate. This implies, it probably contains (or some big strings) more
-nested containers, for which another approach could be a win.
+For now it seems cheaper to use a list for remembering contained aggregates. We
+could of course decide dynamically, which strategy to use: given a big image,
+the first thawed item is a small aggregate. This implies it probably contains
+more nested containers, for which another approach could be a win.
 
 =cut
 
@@ -188,14 +190,14 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC*
+PMC *
 Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image))
 {
     ASSERT_ARGS(Parrot_thaw)
 
-    PMC * const info = Parrot_pmc_new(interp, enum_class_ImageIO);
-    int         gc_block = 0;
     PMC        *result;
+    PMC * const info     = Parrot_pmc_new(interp, enum_class_ImageIO);
+    int         gc_block = 0;
 
     /*
      * if we are thawing a lot of PMCs, it's cheaper to do
@@ -244,35 +246,23 @@
 Parrot_thaw_pbc(PARROT_INTERP, ARGIN(STRING *image), ARGIN(PackFile_ConstTable *pf))
 {
     ASSERT_ARGS(Parrot_thaw_pbc)
-    PMC *info, *pf_pmc, *result;
+    PMC *pf_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
+    PMC *info;
 
-    pf_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
     VTABLE_set_pointer(interp, pf_pmc, pf);
 
     info = Parrot_pmc_new_init(interp, enum_class_ImageIO, pf_pmc);
 
-    /* TODO
-     * Find out what broken code depends on blocking GC here and fix it, regardless of performance
-     * wins.
-     */
-    Parrot_block_GC_mark(interp);
-    Parrot_block_GC_sweep(interp);
-
     VTABLE_set_string_native(interp, info, image);
-    result = VTABLE_get_pmc(interp, info);
-
-    Parrot_unblock_GC_mark(interp);
-    Parrot_unblock_GC_sweep(interp);
-
-    return result;
+    return VTABLE_get_pmc(interp, info);
 }
 
+
 /*
 
 =item C<PMC* Parrot_thaw_constants(PARROT_INTERP, STRING *image)>
 
-Thaws constants, used by PackFile for unpacking PMC constants.
-This is a lie. It does nothing different from Parrot_thaw at the moment.
+This does nothing different from Parrot_thaw at the moment.
 
 =cut
 
@@ -310,6 +300,7 @@
     return VTABLE_clone(interp, pmc);
 }
 
+
 /*
 
 =item C<void Parrot_visit_loop_visit(PARROT_INTERP, PMC *info)>
@@ -325,9 +316,10 @@
 {
     ASSERT_ARGS(Parrot_visit_loop_visit)
 
-    INTVAL      i;
+    PMC * const  todo   = VTABLE_get_iter(interp, info);
     const INTVAL action = VTABLE_get_integer(interp, info);
-    PMC * const todo    = VTABLE_get_iter(interp, info);
+    const INTVAL e      = VTABLE_elements(interp, todo);
+    INTVAL       i;
 
     /* can't cache upper limit, visit may append items */
     for (i = 0; i < VTABLE_elements(interp, todo); ++i) {
@@ -349,11 +341,12 @@
     }
 }
 
+
 /*
 
 =item C<void Parrot_visit_loop_thawfinish(PARROT_INTERP, PMC *info)>
 
-Iterate a visitor PMC thawfinishing each encountered target PMC.
+Iterates a visitor PMC, thawfinishing each encountered target PMC.
 
 =cut
 
@@ -374,17 +367,18 @@
      *      order here is likely broken.
      */
 
-    PMC * const todo    = VTABLE_get_iter(interp, info);
-    const INTVAL n = VTABLE_elements(interp, todo);
+    PMC * const  todo = VTABLE_get_iter(interp, info);
+    const INTVAL n    = VTABLE_elements(interp, todo);
     int          i;
 
-    for (i = n-1; i >= 0; --i) {
+    for (i = n - 1; i >= 0; --i) {
         PMC *current = VTABLE_get_pmc_keyed_int(interp, todo, i);
         if (!PMC_IS_NULL(current))
             VTABLE_thawfinish(interp, current, info);
     }
 }
 
+
 /*
 
 =back


More information about the parrot-commits mailing list