[svn:parrot] r46112 - in branches/pbc_frozen_strings1: compilers/imcc include/parrot src src/pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Wed Apr 28 17:08:12 UTC 2010


Author: plobsing
Date: Wed Apr 28 17:08:11 2010
New Revision: 46112
URL: https://trac.parrot.org/parrot/changeset/46112

Log:
add consttable support to imagio and imageiosize
add Parrot_freeze_pbc, Parrot_freeze_pbc_size, and Parrot_thaw_pbc to make use of this
use added functions in packfile routines
also a workaroud to keep the ParrotInterpreter PBC hack happy

Modified:
   branches/pbc_frozen_strings1/compilers/imcc/pbc.c
   branches/pbc_frozen_strings1/include/parrot/pmc_freeze.h
   branches/pbc_frozen_strings1/src/packfile.c
   branches/pbc_frozen_strings1/src/packout.c
   branches/pbc_frozen_strings1/src/pmc/imageio.pmc
   branches/pbc_frozen_strings1/src/pmc/imageiosize.pmc
   branches/pbc_frozen_strings1/src/pmc_freeze.c

Modified: branches/pbc_frozen_strings1/compilers/imcc/pbc.c
==============================================================================
--- branches/pbc_frozen_strings1/compilers/imcc/pbc.c	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/compilers/imcc/pbc.c	Wed Apr 28 17:08:11 2010	(r46112)
@@ -6,6 +6,7 @@
 #include "imc.h"
 #include "pbc.h"
 #include "parrot/packfile.h"
+#include "parrot/pmc_freeze.h"
 #include "pmc/pmc_sub.h"
 #include "pmc/pmc_callcontext.h"
 
@@ -1452,7 +1453,6 @@
         int n = VTABLE_elements(interp, strings);
         for (i = 0; i < n; i++) {
             int unused = add_const_str(interp, VTABLE_get_string_keyed_int(interp, strings, i));
-            UNUSED(unused);
         }
     }
 

Modified: branches/pbc_frozen_strings1/include/parrot/pmc_freeze.h
==============================================================================
--- branches/pbc_frozen_strings1/include/parrot/pmc_freeze.h	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/include/parrot/pmc_freeze.h	Wed Apr 28 17:08:11 2010	(r46112)
@@ -13,6 +13,8 @@
 #ifndef PARROT_PMC_FREEZE_H_GUARD
 #define PARROT_PMC_FREEZE_H_GUARD
 
+#include "parrot/packfile.h"
+
 typedef enum {
     VISIT_HOW_PMC_TO_VISITOR     = 0x00, /* push to visitor */
     VISIT_HOW_VISITOR_TO_PMC     = 0x01, /* shift from visitor */
@@ -120,6 +122,21 @@
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
+STRING * Parrot_freeze_pbc(PARROT_INTERP,
+    ARGIN(PMC *pmc),
+    ARGIN(const PackFile_ConstTable *pf))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP, ARGIN(PMC *pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 UINTVAL Parrot_freeze_size(PARROT_INTERP, ARGIN(PMC *pmc))
         __attribute__nonnull__(1)
@@ -127,6 +144,12 @@
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+PMC * Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 PMC* Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image))
         __attribute__nonnull__(1)
@@ -139,6 +162,16 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+PMC* Parrot_thaw_pbc(PARROT_INTERP,
+    ARGIN(STRING *image),
+    ARGIN(PackFile_ConstTable *pf))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
 void Parrot_visit_loop_thawfinish(PARROT_INTERP, ARGIN(PMC *info))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -153,15 +186,28 @@
 #define ASSERT_ARGS_Parrot_freeze __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_Parrot_freeze_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(pmc) \
+    , PARROT_ASSERT_ARG(pf))
+#define ASSERT_ARGS_Parrot_freeze_pbc_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(pmc))
 #define ASSERT_ARGS_Parrot_freeze_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_Parrot_freeze_strings __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_Parrot_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(image))
 #define ASSERT_ARGS_Parrot_thaw_constants __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , 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))
 #define ASSERT_ARGS_Parrot_visit_loop_thawfinish __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(info))

Modified: branches/pbc_frozen_strings1/src/packfile.c
==============================================================================
--- branches/pbc_frozen_strings1/src/packfile.c	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/src/packfile.c	Wed Apr 28 17:08:11 2010	(r46112)
@@ -2404,7 +2404,6 @@
     /* now pack all segments into new format */
     for (i = 0; i < dir->num_segments; i++) {
         PackFile_Segment * const seg = dir->segments[i];
-
         cursor = PackFile_Segment_pack(interp, seg, cursor);
     }
 
@@ -3866,7 +3865,7 @@
 
       case PFC_PMC:
         component = self->u.key; /* the pmc (Sub, ...) */
-        packed_size = PF_size_strlen(Parrot_freeze_size(interp, component));
+        packed_size = PF_size_strlen(Parrot_freeze_pbc_size(interp, component));
         break;
 
       default:
@@ -3969,7 +3968,7 @@
     interp->code                      = pf->cur_cs;
     image                             = PF_fetch_string(interp, pf, &cursor);
 
-    pmc         = Parrot_thaw_constants(interp, image);
+    pmc         = Parrot_thaw_pbc(interp, image, constt);
 
     /* place item in const_table */
     self->type  = PFC_PMC;

Modified: branches/pbc_frozen_strings1/src/packout.c
==============================================================================
--- branches/pbc_frozen_strings1/src/packout.c	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/src/packout.c	Wed Apr 28 17:08:11 2010	(r46112)
@@ -286,7 +286,7 @@
 
       case PFC_PMC:
         key = self->u.key;      /* the (Sub) PMC */
-        image = Parrot_freeze(interp, key);
+        image = Parrot_freeze_pbc(interp, key, const_table);
         cursor = PF_store_string(cursor, image);
         break;
 

Modified: branches/pbc_frozen_strings1/src/pmc/imageio.pmc
==============================================================================
--- branches/pbc_frozen_strings1/src/pmc/imageio.pmc	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/src/pmc/imageio.pmc	Wed Apr 28 17:08:11 2010	(r46112)
@@ -249,7 +249,7 @@
     const UINTVAL  n            = VTABLE_shift_integer(interp, info);
     const UINTVAL  id           = PackID_get_PMCID(n);
     const int      packid_flags = PackID_get_FLAGS(n);
-    PMC     *pmc          = PMCNULL;
+    PMC           *pmc          = PMCNULL;
 
     PARROT_ASSERT(PARROT_IMAGEIO(info)->what == VISIT_THAW_NORMAL);
 
@@ -261,9 +261,16 @@
       case enum_PackID_normal:
         {
             const INTVAL type = VTABLE_shift_integer(interp, info);
+
+            PARROT_ASSERT(id - 1 == VTABLE_elements(interp, PARROT_IMAGEIO(info)->todo));
+
             if (type <= 0 || type > interp->n_vtable_max)
                 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown PMC type to thaw %d", type);
 
+            /* workaround to keep ParrotInterpreter PBC hack working */
+            if (type == enum_class_ParrotInterpreter)
+                PObj_flag_CLEAR(private1, info);
+
             pmc = Parrot_pmc_new_noinit(interp, type);
             VTABLE_thaw(interp, pmc, info);
 
@@ -315,8 +322,14 @@
         Hash * const hash = (Hash *)VTABLE_get_pointer(interp, PARROT_IMAGEIO(info)->seen);
 
         PARROT_ASSERT(pmc);
+        
+        /* workaround to keep ParrotInterpreter PBC hack working */
+        if (pmc->vtable->base_type == enum_class_ParrotInterpreter)
+            PObj_flag_CLEAR(private1, info);
+
         VTABLE_push_integer(interp, info,
                 PObj_is_object_TEST(pmc) ? (INTVAL) enum_class_Object : pmc->vtable->base_type);
+                
         parrot_hash_put(interp, hash, pmc, (void *)id);
         VTABLE_push_pmc(interp, PARROT_IMAGEIO(info)->todo, pmc);
         VTABLE_freeze(interp, pmc, info);
@@ -324,14 +337,15 @@
 }
 
 pmclass ImageIO auto_attrs {
-    ATTR Buffer          *buffer;         /* buffer to store the image */
-    ATTR size_t           pos;            /* current read/write position in buffer */
-    ATTR size_t           input_length;
-    ATTR INTVAL           what;
-    ATTR PMC             *seen;           /* seen hash */
-    ATTR PMC             *todo;           /* todo list */
-    ATTR UINTVAL          id;             /* freze ID of PMC */
-    ATTR struct PackFile *pf;
+    ATTR Buffer              *buffer;      /* buffer to store the image */
+    ATTR size_t               pos;         /* current read/write position in buffer */
+    ATTR size_t               input_length;
+    ATTR INTVAL               what;
+    ATTR PMC                 *seen;        /* seen hash */
+    ATTR PMC                 *todo;        /* todo list */
+    ATTR UINTVAL              id;          /* freze ID of PMC */
+    ATTR struct PackFile     *pf;
+    ATTR PackFile_ConstTable *pf_ct;
 
 /*
 
@@ -359,6 +373,30 @@
         PARROT_IMAGEIO(SELF)->id     = 0;
         PARROT_IMAGEIO(SELF)->pf     = PackFile_new(INTERP, 0);
 
+        PObj_flag_CLEAR(private1, SELF);
+
+        PObj_custom_mark_destroy_SETALL(SELF);
+    }
+
+/*
+
+=item C<void init_pmc(PMC *pmc)>
+
+Initializes the PMC with a pre-existing C<PackFile_ConstTable>.
+
+=cut
+
+*/
+    VTABLE void init_pmc(PMC *pmc) {
+        PARROT_IMAGEIO(SELF)->buffer = NULL;
+        PARROT_IMAGEIO(SELF)->todo   = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+        PARROT_IMAGEIO(SELF)->seen   = PMCNULL;
+        PARROT_IMAGEIO(SELF)->id     = 0;
+        PARROT_IMAGEIO(SELF)->pf     = PackFile_new(INTERP, 0);
+
+        PARROT_IMAGEIO(SELF)->pf_ct  = (PackFile_ConstTable *)VTABLE_get_pointer(INTERP, pmc);
+        PObj_flag_SET(private1, SELF);
+
         PObj_custom_mark_destroy_SETALL(SELF);
     }
 
@@ -497,11 +535,33 @@
 
 */
 
-    VTABLE void push_string(STRING *v)
-    {
-        const size_t len = PF_size_string(v) * sizeof (opcode_t);
-        ensure_buffer_size(INTERP, SELF, len);
-        SET_VISIT_CURSOR(SELF, (char *)PF_store_string(GET_VISIT_CURSOR(SELF), v));
+    VTABLE void push_string(STRING *v) {
+        if (PObj_flag_TEST(private1, SELF)) {
+            /* store a reference to constant table entry of string */
+            int i;
+            PackFile_ConstTable *table = PARROT_IMAGEIO(SELF)->pf_ct;
+            for (i = 0; i < table->const_count; i++) {
+                PackFile_Constant *constant = table->constants[i];
+                if (constant->type == PFC_STRING) {
+                    STRING * const sc = constant->u.string;
+                    if (Parrot_charset_number_of_str(interp, v)
+                    ==  Parrot_charset_number_of_str(interp, sc)
+                    &&  Parrot_encoding_number_of_str(interp, v)
+                    ==  Parrot_encoding_number_of_str(interp, sc)
+                    &&  Parrot_str_equal(interp, v, sc)) {
+                        SET_VISIT_CURSOR(SELF,
+                                (char *)PF_store_integer(GET_VISIT_CURSOR(SELF), i));
+                        return;
+                    }
+                }
+            }
+            PANIC(INTERP, "string not previously in constant table when freezing to packfile");
+        }
+        else {
+            const size_t len = PF_size_string(v) * sizeof (opcode_t);
+            ensure_buffer_size(INTERP, SELF, len);
+            SET_VISIT_CURSOR(SELF, (char *)PF_store_string(GET_VISIT_CURSOR(SELF), v));
+        }
     }
 
 /*
@@ -531,8 +591,8 @@
 
     VTABLE INTVAL shift_integer()
     {
-        const opcode_t *pos = GET_VISIT_CURSOR(SELF);
-        const INTVAL i      = PF_fetch_integer(PARROT_IMAGEIO(SELF)->pf,
+        opcode_t *pos = GET_VISIT_CURSOR(SELF);
+        INTVAL    i   = PF_fetch_integer(PARROT_IMAGEIO(SELF)->pf,
                 (const opcode_t **)&pos);
         SET_VISIT_CURSOR(SELF, (char *)pos);
         BYTECODE_SHIFT_OK(SELF);
@@ -551,8 +611,8 @@
 */
 
     VTABLE FLOATVAL shift_float() {
-        const opcode_t *pos = GET_VISIT_CURSOR(SELF);
-        const FLOATVAL f    = PF_fetch_number(PARROT_IMAGEIO(SELF)->pf,
+        opcode_t *pos = GET_VISIT_CURSOR(SELF);
+        FLOATVAL  f   = PF_fetch_number(PARROT_IMAGEIO(SELF)->pf,
                 (const opcode_t **)&pos);
         SET_VISIT_CURSOR(SELF, (char *)pos);
         BYTECODE_SHIFT_OK(SELF);
@@ -570,14 +630,23 @@
 
 */
 
-    VTABLE STRING *shift_string()
-    {
-        const opcode_t *pos = GET_VISIT_CURSOR(SELF);
-        STRING * const s    = PF_fetch_string(interp, PARROT_IMAGEIO(SELF)->pf,
-                                           (const opcode_t **)&pos);
-        SET_VISIT_CURSOR(SELF, (char *)pos);
-        BYTECODE_SHIFT_OK(SELF);
-        return s;
+    VTABLE STRING *shift_string() {
+        if (PObj_flag_TEST(private1, SELF)) {
+            PackFile_ConstTable *table = PARROT_IMAGEIO(SELF)->pf_ct;
+            opcode_t *pos              = GET_VISIT_CURSOR(SELF);
+            INTVAL i                   = PF_fetch_integer(PARROT_IMAGEIO(SELF)->pf, (const opcode_t **)&pos);
+            SET_VISIT_CURSOR(SELF, (char *)pos);
+            BYTECODE_SHIFT_OK(SELF);
+            return table->constants[i]->u.string;
+        }
+        else {
+            opcode_t *pos = GET_VISIT_CURSOR(SELF);
+            STRING   *s   = PF_fetch_string(interp, PARROT_IMAGEIO(SELF)->pf,
+                                               (const opcode_t **)&pos);
+            SET_VISIT_CURSOR(SELF, (char *)pos);
+            BYTECODE_SHIFT_OK(SELF);
+            return s;
+        }
     }
 
 /*

Modified: branches/pbc_frozen_strings1/src/pmc/imageiosize.pmc
==============================================================================
--- branches/pbc_frozen_strings1/src/pmc/imageiosize.pmc	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/src/pmc/imageiosize.pmc	Wed Apr 28 17:08:11 2010	(r46112)
@@ -52,6 +52,11 @@
         Hash * const hash = (Hash *)VTABLE_get_pointer(interp, PARROT_IMAGEIOSIZE(info)->seen);
 
         parrot_hash_put(interp, hash, pmc, pmc);
+
+        /* workaround to keep ParrotInterpreter PBC hack working */
+        if (pmc->vtable->base_type == enum_class_ParrotInterpreter)
+            PObj_flag_CLEAR(private1, info);
+
         VTABLE_push_integer(interp, info, pmc->vtable->base_type);
         VTABLE_push_pmc(interp, PARROT_IMAGEIOSIZE(info)->todo, pmc);
         VTABLE_freeze(interp, pmc, info);
@@ -92,6 +97,33 @@
         VTABLE_set_pointer(INTERP, PARROT_IMAGEIOSIZE(SELF)->seen,
             parrot_new_intval_hash(INTERP));
 
+        PObj_flag_CLEAR(private1, SELF);
+
+        PObj_custom_mark_destroy_SETALL(SELF);
+    }
+
+/*
+
+=item C<void init_pmc()>
+
+Initializes the PMC with a pre-existing C<PackFile_ConstTable>.
+
+=cut
+
+*/
+    VTABLE void init_pmc(PMC *pmc) {
+        UNUSED(pmc);
+
+        PARROT_IMAGEIOSIZE(SELF)->todo = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+        PARROT_IMAGEIOSIZE(SELF)->pf   = PackFile_new(INTERP, 0);
+        PARROT_IMAGEIOSIZE(SELF)->size = 0;
+
+        PARROT_IMAGEIOSIZE(SELF)->seen = Parrot_pmc_new(INTERP, enum_class_Hash);
+        VTABLE_set_pointer(INTERP, PARROT_IMAGEIOSIZE(SELF)->seen,
+            parrot_new_intval_hash(INTERP));
+
+        PObj_flag_SET(private1, SELF);
+
         PObj_custom_mark_destroy_SETALL(SELF);
     }
 
@@ -210,10 +242,14 @@
 
 */
 
-    VTABLE void push_string(STRING *v)
-    {
-        const size_t len = PF_size_string(v) * sizeof (opcode_t);
-        PARROT_IMAGEIOSIZE(SELF)->size += len;
+    VTABLE void push_string(STRING *v) {
+        if (PObj_flag_TEST(private1, SELF)) {
+            STATICSELF.push_integer(0);
+        }
+        else {
+            const size_t len = PF_size_string(v) * sizeof (opcode_t);
+            PARROT_IMAGEIOSIZE(SELF)->size += len;
+        }
     }
 
 /*

Modified: branches/pbc_frozen_strings1/src/pmc_freeze.c
==============================================================================
--- branches/pbc_frozen_strings1/src/pmc_freeze.c	Wed Apr 28 17:03:42 2010	(r46111)
+++ branches/pbc_frozen_strings1/src/pmc_freeze.c	Wed Apr 28 17:08:11 2010	(r46112)
@@ -61,12 +61,38 @@
 
 /*
 
+=item C<STRING * Parrot_freeze_pbc(PARROT_INTERP, PMC *pmc, const
+PackFile_ConstTable *pf)>
+
+Freeze to a PackFile.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+STRING *
+Parrot_freeze_pbc(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(const PackFile_ConstTable *pf)) {
+    ASSERT_ARGS(Parrot_freeze_pbc)
+    PMC *pf_pmc, *visitor;
+
+    pf_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
+    VTABLE_set_pointer(interp, pf_pmc, (void *)pf);
+
+    visitor  = Parrot_pmc_new_init(interp, enum_class_ImageIO, pf_pmc);
+    VTABLE_set_pmc(interp, visitor, pmc);
+
+    return VTABLE_get_string(interp, visitor);
+}
+
+
+/*
+
 =item C<UINTVAL Parrot_freeze_size(PARROT_INTERP, PMC *pmc)>
 
 Get the size of an image to be frozen without allocating a large buffer.
 
-Used in C<Packfile_Constant_pack_size>.
-
 =cut
 
 */
@@ -87,10 +113,35 @@
     return int_result;
 }
 
+/*
+
+=item C<UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP, PMC *pmc)>
+
+Get the size of an image if it were created using C<Parrot_freeze_pbc>.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+UINTVAL
+Parrot_freeze_pbc_size(PARROT_INTERP, ARGIN(PMC *pmc))
+{
+    ASSERT_ARGS(Parrot_freeze_pbc_size)
+    UINTVAL  int_result;
+    PMC     *pmc_result;
+    PMC     *visitor = Parrot_pmc_new_init(interp, enum_class_ImageIOSize, PMCNULL);
+    VTABLE_set_pmc(interp, visitor, pmc);
+    pmc_result = VTABLE_get_pmc(interp, visitor);
+    int_result = VTABLE_get_integer(interp, pmc_result);
+    return int_result;
+}
+
 
 /*
 
-=item C<PMC *Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)>
+=item C<PMC * Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)>
 
 Get the strings of a PMC to be frozen.
 
@@ -104,7 +155,8 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC *
-Parrot_freeze_strings(PARROT_INTERP, PMC *pmc) {
+Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)
+{
     PMC *visitor = Parrot_pmc_new(interp, enum_class_ImageIOStrings);
     VTABLE_set_pmc(interp, visitor, pmc);
     return VTABLE_get_pmc(interp, visitor);
@@ -170,6 +222,45 @@
 
 /*
 
+=item C<PMC* Parrot_thaw_pbc(PARROT_INTERP, STRING *image, PackFile_ConstTable
+*pf)>
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+PMC*
+Parrot_thaw_pbc(PARROT_INTERP, ARGIN(STRING *image), ARGIN(PackFile_ConstTable *pf))
+{
+    ASSERT_ARGS(Parrot_thaw)
+    PMC *info, *pf_pmc, *result;
+
+    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;
+}
+
+/*
+
 =item C<PMC* Parrot_thaw_constants(PARROT_INTERP, STRING *image)>
 
 Thaws constants, used by PackFile for unpacking PMC constants.


More information about the parrot-commits mailing list