[svn:parrot] r48501 - in trunk: include/parrot src

plobsing at svn.parrot.org plobsing at svn.parrot.org
Sun Aug 15 02:38:58 UTC 2010


Author: plobsing
Date: Sun Aug 15 02:38:57 2010
New Revision: 48501
URL: https://trac.parrot.org/parrot/changeset/48501

Log:
move cursor management into Parrot_{freeze,thaw}_pbc
this is the first step towards eliminating unecessary unecessary generation of string headers in packfile freeze/thaw

Modified:
   trunk/include/parrot/pmc_freeze.h
   trunk/src/packfile.c
   trunk/src/packout.c
   trunk/src/pmc_freeze.c

Modified: trunk/include/parrot/pmc_freeze.h
==============================================================================
--- trunk/include/parrot/pmc_freeze.h	Sun Aug 15 02:03:53 2010	(r48500)
+++ trunk/include/parrot/pmc_freeze.h	Sun Aug 15 02:38:57 2010	(r48501)
@@ -123,12 +123,14 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-STRING * Parrot_freeze_pbc(PARROT_INTERP,
+opcode_t * Parrot_freeze_pbc(PARROT_INTERP,
     ARGIN(PMC *pmc),
-    ARGIN(const PackFile_ConstTable *pf))
+    ARGIN(const PackFile_ConstTable *pf),
+    ARGIN(opcode_t *cursor))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3);
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
@@ -170,11 +172,12 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 PMC* Parrot_thaw_pbc(PARROT_INTERP,
-    ARGIN(STRING *image),
-    ARGIN(PackFile_ConstTable *pf))
+    ARGIN(PackFile_ConstTable *ct),
+    ARGMOD(const opcode_t **cursor))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3);
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*cursor);
 
 void Parrot_visit_loop_thawfinish(PARROT_INTERP, ARGIN(PMC *info))
         __attribute__nonnull__(1)
@@ -193,7 +196,8 @@
 #define ASSERT_ARGS_Parrot_freeze_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc) \
-    , PARROT_ASSERT_ARG(pf))
+    , PARROT_ASSERT_ARG(pf) \
+    , PARROT_ASSERT_ARG(cursor))
 #define ASSERT_ARGS_Parrot_freeze_pbc_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc) \
@@ -212,8 +216,8 @@
     , PARROT_ASSERT_ARG(image))
 #define ASSERT_ARGS_Parrot_thaw_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(image) \
-    , PARROT_ASSERT_ARG(pf))
+    , PARROT_ASSERT_ARG(ct) \
+    , PARROT_ASSERT_ARG(cursor))
 #define ASSERT_ARGS_Parrot_visit_loop_thawfinish __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(info))

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Sun Aug 15 02:03:53 2010	(r48500)
+++ trunk/src/packfile.c	Sun Aug 15 02:38:57 2010	(r48501)
@@ -4154,15 +4154,12 @@
     ASSERT_ARGS(PackFile_Constant_unpack_pmc)
     PackFile * const pf   = constt->base.pf;
     STRING          *_sub = CONST_STRING(interp, "Sub");
-    STRING          *image;
     PMC             *pmc;
 
     /* thawing the PMC needs the real packfile in place */
     PackFile_ByteCode * const cs_save = interp->code;
     interp->code                      = pf->cur_cs;
-    image                             = PF_fetch_buf(interp, pf, &cursor);
-
-    pmc         = Parrot_thaw_pbc(interp, image, constt);
+    pmc                               = Parrot_thaw_pbc(interp, constt, &cursor);
 
     /* place item in const_table */
     self->type  = PFC_PMC;

Modified: trunk/src/packout.c
==============================================================================
--- trunk/src/packout.c	Sun Aug 15 02:03:53 2010	(r48500)
+++ trunk/src/packout.c	Sun Aug 15 02:38:57 2010	(r48501)
@@ -361,9 +361,7 @@
         break;
 
       case PFC_PMC:
-        key    = self->u.key;      /* the (Sub) PMC */
-        image  = Parrot_freeze_pbc(interp, key, const_table);
-        cursor = PF_store_buf(cursor, image);
+        cursor  = Parrot_freeze_pbc(interp, self->u.key, const_table, cursor);
         break;
 
       case PFC_KEY:

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Sun Aug 15 02:03:53 2010	(r48500)
+++ trunk/src/pmc_freeze.c	Sun Aug 15 02:38:57 2010	(r48501)
@@ -62,8 +62,8 @@
 
 /*
 
-=item C<STRING * Parrot_freeze_pbc(PARROT_INTERP, PMC *pmc, const
-PackFile_ConstTable *pf)>
+=item C<opcode_t * Parrot_freeze_pbc(PARROT_INTERP, PMC *pmc, const
+PackFile_ConstTable *pf, opcode_t *cursor)>
 
 Freezes a PMC to a PackFile.
 
@@ -74,11 +74,13 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-STRING *
-Parrot_freeze_pbc(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(const PackFile_ConstTable *pf))
+opcode_t *
+Parrot_freeze_pbc(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(const PackFile_ConstTable *pf),
+    ARGIN(opcode_t *cursor))
 {
     ASSERT_ARGS(Parrot_freeze_pbc)
-    PMC *visitor;
+    PMC    *visitor;
+    STRING *image;
     DECL_CONST_CAST;
 
     visitor  = Parrot_pmc_new(interp, enum_class_ImageIO);
@@ -86,7 +88,10 @@
         PARROT_const_cast(void *, (const void *)pf));
     VTABLE_set_pmc(interp, visitor, pmc);
 
-    return VTABLE_get_string(interp, visitor);
+    image  = VTABLE_get_string(interp, visitor);
+    cursor = PF_store_buf(cursor, image);
+
+    return cursor;
 }
 
 
@@ -228,8 +233,8 @@
 
 /*
 
-=item C<PMC* Parrot_thaw_pbc(PARROT_INTERP, STRING *image, PackFile_ConstTable
-*pf)>
+=item C<PMC* Parrot_thaw_pbc(PARROT_INTERP, PackFile_ConstTable *ct, const
+opcode_t **cursor)>
 
 Thaw a pmc frozen by Parrot_freeze_pbc.
 
@@ -241,13 +246,13 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 PMC*
-Parrot_thaw_pbc(PARROT_INTERP, ARGIN(STRING *image), ARGIN(PackFile_ConstTable *pf))
+Parrot_thaw_pbc(PARROT_INTERP, ARGIN(PackFile_ConstTable *ct), ARGMOD(const opcode_t **cursor))
 {
     ASSERT_ARGS(Parrot_thaw_pbc)
-    PMC *info = Parrot_pmc_new(interp, enum_class_ImageIO);
-
-    VTABLE_set_pointer(interp, info, pf);
-
+    PackFile * const pf = ct->base.pf;
+    STRING *image       = PF_fetch_buf(interp, pf, cursor);
+    PMC *info           = Parrot_pmc_new(interp, enum_class_ImageIO);
+    VTABLE_set_pointer(interp, info, ct);
     VTABLE_set_string_native(interp, info, image);
     return VTABLE_get_pmc(interp, info);
 }


More information about the parrot-commits mailing list