[svn:parrot] r46226 - in trunk: . compilers/data_json compilers/imcc compilers/pct compilers/pge compilers/tge config/auto/sizes config/auto/zlib docs/book/draft docs/book/pct docs/dev docs/pdds examples/embed examples/languages/abc examples/languages/squaak examples/pge ext/nqp-rx ext/nqp-rx/src/stage0 include/parrot lib/Parrot lib/Parrot/Configure/Step ports/cygwin ports/debian ports/fedora/2.3.0 ports/suse/2.2.0 runtime/parrot/languages runtime/parrot/library runtime/parrot/library/Math src src/call src/gc src/interp src/pmc src/runcore t/compilers/tge t/native_pbc t/oo t/pmc t/src t/steps/init/hints tools/build tools/dev tools/util

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon May 3 04:54:28 UTC 2010


Author: plobsing
Date: Mon May  3 04:54:26 2010
New Revision: 46226
URL: https://trac.parrot.org/parrot/changeset/46226

Log:
merge pbc_frozen_strings1 branch

Added:
   trunk/src/pmc/imageiostrings.pmc
      - copied unchanged from r46225, branches/pbc_frozen_strings1/src/pmc/imageiostrings.pmc
   trunk/t/pmc/imageiostrings.t
      - copied unchanged from r46225, branches/pbc_frozen_strings1/t/pmc/imageiostrings.t
Modified:
   trunk/   (props changed)
   trunk/MANIFEST
   trunk/PBC_COMPAT
   trunk/compilers/data_json/Rules.mak   (props changed)
   trunk/compilers/imcc/Rules.in   (props changed)
   trunk/compilers/imcc/pbc.c
   trunk/compilers/pct/Rules.mak   (props changed)
   trunk/compilers/pge/Rules.mak   (props changed)
   trunk/compilers/tge/Rules.mak   (props changed)
   trunk/config/auto/sizes/intval_maxmin_c.in   (props changed)
   trunk/config/auto/zlib/   (props changed)
   trunk/docs/book/draft/README   (props changed)
   trunk/docs/book/draft/appa_glossary.pod   (props changed)
   trunk/docs/book/draft/appb_patch_submission.pod   (props changed)
   trunk/docs/book/draft/appc_command_line_options.pod   (props changed)
   trunk/docs/book/draft/appd_build_options.pod   (props changed)
   trunk/docs/book/draft/appe_source_code.pod   (props changed)
   trunk/docs/book/draft/ch01_introduction.pod   (props changed)
   trunk/docs/book/draft/ch02_getting_started.pod   (props changed)
   trunk/docs/book/draft/ch07_dynpmcs.pod   (props changed)
   trunk/docs/book/draft/ch08_dynops.pod   (props changed)
   trunk/docs/book/draft/ch10_opcode_reference.pod   (props changed)
   trunk/docs/book/draft/ch11_directive_reference.pod   (props changed)
   trunk/docs/book/draft/ch12_operator_reference.pod   (props changed)
   trunk/docs/book/draft/chXX_hlls.pod   (props changed)
   trunk/docs/book/draft/chXX_library.pod   (props changed)
   trunk/docs/book/draft/chXX_testing_and_debugging.pod   (props changed)
   trunk/docs/book/pct/ch01_introduction.pod   (props changed)
   trunk/docs/book/pct/ch02_getting_started.pod   (props changed)
   trunk/docs/book/pct/ch03_compiler_tools.pod   (props changed)
   trunk/docs/book/pct/ch04_pge.pod   (props changed)
   trunk/docs/book/pct/ch05_nqp.pod   (props changed)
   trunk/docs/dev/c_functions.pod   (props changed)
   trunk/docs/pdds/pdd30_install.pod   (props changed)
   trunk/examples/embed/cotorra.c   (props changed)
   trunk/examples/languages/abc/   (props changed)
   trunk/examples/languages/squaak/   (props changed)
   trunk/examples/pge/demo.pir   (props changed)
   trunk/ext/nqp-rx/Rules.mak   (props changed)
   trunk/ext/nqp-rx/src/stage0/Regex-s0.pir
   trunk/include/parrot/call.h   (props changed)
   trunk/include/parrot/gc_api.h   (props changed)
   trunk/include/parrot/packfile.h
   trunk/include/parrot/pmc_freeze.h
   trunk/include/parrot/runcore_api.h   (props changed)
   trunk/include/parrot/runcore_profiling.h   (props changed)
   trunk/include/parrot/runcore_trace.h   (props changed)
   trunk/lib/Parrot/Configure/Step/Test.pm   (props changed)
   trunk/lib/Parrot/H2inc.pm   (props changed)
   trunk/ports/cygwin/parrot-1.0.0-1.cygport   (props changed)
   trunk/ports/debian/libparrot-dev.install.in   (props changed)
   trunk/ports/debian/libparrot.install.in   (props changed)
   trunk/ports/debian/parrot-doc.install.in   (props changed)
   trunk/ports/debian/parrot.install.in   (props changed)
   trunk/ports/fedora/2.3.0/   (props changed)
   trunk/ports/suse/2.2.0/   (props changed)
   trunk/runtime/parrot/languages/   (props changed)
   trunk/runtime/parrot/library/Math/Rand.pir   (props changed)
   trunk/runtime/parrot/library/Rules.mak   (props changed)
   trunk/src/call/ops.c   (props changed)
   trunk/src/call/pcc.c   (props changed)
   trunk/src/gc/alloc_memory.c   (props changed)
   trunk/src/gc/alloc_resources.c   (props changed)
   trunk/src/gc/api.c   (props changed)
   trunk/src/gc/malloc.c   (props changed)
   trunk/src/gc/malloc_trace.c   (props changed)
   trunk/src/gc/mark_sweep.c   (props changed)
   trunk/src/gc/system.c   (props changed)
   trunk/src/interp/inter_cb.c   (props changed)
   trunk/src/interp/inter_create.c   (props changed)
   trunk/src/interp/inter_misc.c   (props changed)
   trunk/src/packfile.c
   trunk/src/packout.c
   trunk/src/pmc/imageio.pmc
   trunk/src/pmc/imageiosize.pmc
   trunk/src/pmc_freeze.c
   trunk/src/runcore/cores.c   (props changed)
   trunk/src/runcore/main.c   (props changed)
   trunk/src/runcore/profiling.c   (props changed)
   trunk/src/runcore/trace.c   (props changed)
   trunk/t/compilers/tge/NoneGrammar.tg   (props changed)
   trunk/t/native_pbc/annotations.pbc
   trunk/t/native_pbc/integer_1.pbc
   trunk/t/native_pbc/number_1.pbc
   trunk/t/native_pbc/string_1.pbc
   trunk/t/oo/root_new.t   (props changed)
   trunk/t/pmc/namespace-old.t   (props changed)
   trunk/t/src/embed.t   (props changed)
   trunk/t/steps/init/hints/linux-01.t   (props changed)
   trunk/tools/build/h2inc.pl   (props changed)
   trunk/tools/dev/fetch_languages.pl   (props changed)
   trunk/tools/dev/mk_gitignore.pl   (props changed)
   trunk/tools/util/perlcritic-cage.conf   (props changed)

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/MANIFEST	Mon May  3 04:54:26 2010	(r46226)
@@ -1,12 +1,12 @@
 # ex: set ro:
 # $Id$
 #
-# generated by ./tools/dev/mk_manifest_and_skip.pl Sun May  2 04:09:12 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon May  3 04:04:08 2010 UT
 #
 # See below for documentation on the format of this file.
 #
 # See docs/submissions.pod and the documentation in
-# ./tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
+# tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
 # has been told about new or deleted files.
 .gitignore                                                  []
 CREDITS                                                     [main]doc
@@ -245,6 +245,7 @@
 config/gen/core_pmcs.pm                                     []
 config/gen/makefiles.pm                                     []
 config/gen/makefiles/docs.in                                []
+config/gen/makefiles/dynpmc.in                              []
 config/gen/makefiles/editor.in                              []
 config/gen/makefiles/ext.in                                 []
 config/gen/makefiles/parrot_embed_pl.in                     []
@@ -1117,6 +1118,7 @@
 lib/Pod/Simple/TranscodeSmart.pm                            []
 lib/Pod/Simple/XHTML.pm                                     []
 lib/Pod/Simple/XMLOutStream.pm                              []
+merge                                                       []
 parrotbug                                                   []
 runtime/parrot/dynext/README                                []doc
 runtime/parrot/include/README                               []doc
@@ -1352,6 +1354,7 @@
 src/pmc/hashiteratorkey.pmc                                 []
 src/pmc/imageio.pmc                                         []
 src/pmc/imageiosize.pmc                                     []
+src/pmc/imageiostrings.pmc                                  []
 src/pmc/integer.pmc                                         []
 src/pmc/iterator.pmc                                        []
 src/pmc/key.pmc                                             []
@@ -1380,6 +1383,7 @@
 src/pmc/packfilesegment.pmc                                 []
 src/pmc/parrotinterpreter.pmc                               []
 src/pmc/parrotlibrary.pmc                                   []
+src/pmc/parrotrunningthread.pmc                             []
 src/pmc/parrotthread.pmc                                    []
 src/pmc/pmc.num                                             []
 src/pmc/pmcproxy.pmc                                        []
@@ -1824,6 +1828,7 @@
 t/pmc/hashiteratorkey.t                                     [test]
 t/pmc/imageio.t                                             [test]
 t/pmc/imageiosize.t                                         [test]
+t/pmc/imageiostrings.t                                      [test]
 t/pmc/integer.t                                             [test]
 t/pmc/io.t                                                  [test]
 t/pmc/io_iterator.t                                         [test]
@@ -1863,6 +1868,7 @@
 t/pmc/parrotio.t                                            [test]
 t/pmc/parrotlibrary.t                                       [test]
 t/pmc/parrotobject.t                                        [test]
+t/pmc/parrotrunningthread.t                                 [test]
 t/pmc/parrotthread.t                                        [test]
 t/pmc/pmc.t                                                 [test]
 t/pmc/pmcproxy.t                                            [test]
@@ -2119,6 +2125,7 @@
 tools/dev/vgp_darwin                                        []
 tools/dev/vms-patch                                         []
 tools/dev/vtablize.pl                                       []
+tools/docs/book-to-latex.pl                                 []
 tools/docs/filename_and_chapter.pl                          []
 tools/docs/mk_chm.pl                                        []
 tools/docs/ops_summary.pl                                   []

Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/PBC_COMPAT	Mon May  3 04:54:26 2010	(r46226)
@@ -27,6 +27,7 @@
 
 # please insert tab separated entries at the top of the list
 
+6.12	2010.05.02	plobsing	store constant PMC strings as top level constant strings    
 6.11	2010.04.29	tewk	remove ParrotRunningThread
 6.10	2010.04.29	NotFound	packfiledebug.pmc
 6.9	2010.04.27	bacek	remove deprecated in-place string ops (bitwise, charset, case change)

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/compilers/imcc/pbc.c	Mon May  3 04:54:26 2010	(r46226)
@@ -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"
 
@@ -78,7 +79,7 @@
         FUNC_MODIFIES(*r);
 
 PARROT_WARN_UNUSED_RESULT
-static int add_const_str(PARROT_INTERP, ARGIN(const SymReg *r))
+static int add_const_str(PARROT_INTERP, ARGIN(STRING *s))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -222,7 +223,7 @@
     , PARROT_ASSERT_ARG(r))
 #define ASSERT_ARGS_add_const_str __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(r))
+    , PARROT_ASSERT_ARG(s))
 #define ASSERT_ARGS_add_const_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_add_const_table_key __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -832,7 +833,7 @@
                     interp->code->base.data[addr] = op;
 
                     if (nam->color < 0)
-                        nam->color = add_const_str(interp, nam);
+                        nam->color = add_const_str(interp, IMCC_string_from_reg(interp, nam));
 
                     interp->code->base.data[addr+2] = nam->color;
 
@@ -968,7 +969,7 @@
 
 /*
 
-=item C<static int add_const_str(PARROT_INTERP, const SymReg *r)>
+=item C<static int add_const_str(PARROT_INTERP, STRING *s)>
 
 Adds a constant string to constant_table.
 
@@ -978,12 +979,11 @@
 
 PARROT_WARN_UNUSED_RESULT
 static int
-add_const_str(PARROT_INTERP, ARGIN(const SymReg *r))
+add_const_str(PARROT_INTERP, ARGIN(STRING *s))
 {
     ASSERT_ARGS(add_const_str)
 
     PackFile_ConstTable *table = interp->code->const_table;
-    STRING * const       s     = IMCC_string_from_reg(interp, r);
     int i;
 
     for (i = 0; i < table->const_count; ++i) {
@@ -1264,9 +1264,7 @@
     PMC                   *sub_pmc;
     Parrot_Sub_attributes *sub, *outer_sub;
 
-    const int            k            = add_const_table(interp);
     PackFile_ConstTable * const ct    = interp->code->const_table;
-    PackFile_Constant   * const pfc   = ct->constants[k];
     IMC_Unit            * const unit  =
         IMCC_INFO(interp)->globals->cs->subs->unit;
 
@@ -1277,8 +1275,6 @@
     int                  i;
     int                  ns_const = -1;
 
-    IMCC_INFO(interp)->globals->cs->subs->pmc_const = k;
-
     if (unit->_namespace) {
         /* strip namespace off from front */
         const char *real_name = strrchr(r->name, '@');
@@ -1328,7 +1324,7 @@
     PMC_get_sub(interp, sub_pmc, sub);
     Sub_comp_get_FLAGS(sub) |= (r->pcc_sub->pragma & SUB_COMP_FLAG_MASK);
 
-    r->color  = add_const_str(interp, r);
+    r->color  = add_const_str(interp, IMCC_string_from_reg(interp, r));
     sub->name = ct->constants[r->color]->u.string;
 
     /* If the unit has no subid, set the subid to match the name. */
@@ -1342,7 +1338,7 @@
         mem_sys_free(oldname);
 
         /* create string constant for it. */
-        unit->subid->color = add_const_str(interp, unit->subid);
+        unit->subid->color = add_const_str(interp, IMCC_string_from_reg(interp, unit->subid));
     }
 
     sub->subid = ct->constants[unit->subid->color]->u.string;
@@ -1444,29 +1440,49 @@
 
     Parrot_store_sub_in_namespace(interp, sub_pmc);
 
-    pfc->type     = PFC_PMC;
-    pfc->u.key    = sub_pmc;
-    unit->sub_pmc = sub_pmc;
-
     if (sub->outer_sub)
         PMC_get_sub(interp, sub->outer_sub, outer_sub);
 
-    IMCC_debug(interp, DEBUG_PBC_CONST,
-            "add_const_pmc_sub '%s' flags %x color %d (%Ss) "
-            "lex_info %s :outer(%Ss)\n",
-            r->name, r->pcc_sub->pragma, k,
-            sub_pmc->vtable->whoami,
-            sub->lex_info ? "yes" : "no",
-            sub->outer_sub? outer_sub->name :
-            Parrot_str_new(interp, "*none*", 0));
-
     /*
-     * create entry in our fixup (=symbol) table
-     * the offset is the index in the constant table of this Sub
+     * store the sub's strings
+     * XXX these need to occur before the sub to support thawing properly
      */
-    PackFile_FixupTable_new_entry(interp, r->name, enum_fixup_sub, k);
+    {
+        PMC *strings = Parrot_freeze_strings(interp, sub_pmc);
+        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));
+        }
+    }
 
-    return k;
+    /* store the sub */
+    {
+        const int            k            = add_const_table(interp);
+        PackFile_Constant   * const pfc   = ct->constants[k];
+
+        pfc->type     = PFC_PMC;
+        pfc->u.key    = sub_pmc;
+        unit->sub_pmc = sub_pmc;
+
+        IMCC_INFO(interp)->globals->cs->subs->pmc_const = k;
+
+        IMCC_debug(interp, DEBUG_PBC_CONST,
+                "add_const_pmc_sub '%s' flags %x color %d (%Ss) "
+                "lex_info %s :outer(%Ss)\n",
+                r->name, r->pcc_sub->pragma, k,
+                sub_pmc->vtable->whoami,
+                sub->lex_info ? "yes" : "no",
+                sub->outer_sub? outer_sub->name :
+                Parrot_str_new(interp, "*none*", 0));
+
+        /*
+         * create entry in our fixup (=symbol) table
+         * the offset is the index in the constant table of this Sub
+         */
+        PackFile_FixupTable_new_entry(interp, r->name, enum_fixup_sub, k);
+
+        return k;
+    }
 }
 
 
@@ -1874,7 +1890,7 @@
       case 'S':
         if (r->type & VT_CONSTP)
             r = r->reg;
-        r->color = add_const_str(interp, r);
+        r->color = add_const_str(interp, IMCC_string_from_reg(interp, r));
         break;
       case 'N':
         r->color = add_const_num(interp, r->name);

Modified: trunk/ext/nqp-rx/src/stage0/Regex-s0.pir
==============================================================================
--- trunk/ext/nqp-rx/src/stage0/Regex-s0.pir	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/ext/nqp-rx/src/stage0/Regex-s0.pir	Mon May  3 04:54:26 2010	(r46226)
@@ -1921,7 +1921,7 @@
 # vim: expandtab shiftwidth=4 ft=pir:
 
 ### .include 'src/PAST/Regex.pir'
-# $Id: Regex.pir 41578 2009-09-30 14:45:23Z pmichaud $
+# $Id$
 
 =head1 NAME
 

Modified: trunk/include/parrot/packfile.h
==============================================================================
--- trunk/include/parrot/packfile.h	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/include/parrot/packfile.h	Mon May  3 04:54:26 2010	(r46226)
@@ -501,9 +501,11 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 size_t PackFile_Constant_pack_size(PARROT_INTERP,
-    ARGIN(const PackFile_Constant *self))
+    ARGIN(const PackFile_Constant *self),
+    ARGIN(const PackFile_ConstTable *ct))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
@@ -856,7 +858,8 @@
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_PackFile_Constant_pack_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(self))
+    , PARROT_ASSERT_ARG(self) \
+    , PARROT_ASSERT_ARG(ct))
 #define ASSERT_ARGS_PackFile_Constant_unpack __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(constt) \

Modified: trunk/include/parrot/pmc_freeze.h
==============================================================================
--- trunk/include/parrot/pmc_freeze.h	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/include/parrot/pmc_freeze.h	Mon May  3 04:54:26 2010	(r46226)
@@ -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,24 @@
 
 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),
+    ARGIN(const PackFile_ConstTable *pf))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 UINTVAL Parrot_freeze_size(PARROT_INTERP, ARGIN(PMC *pmc))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -127,6 +147,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_CANNOT_RETURN_NULL
 PMC* Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -138,6 +164,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);
@@ -152,15 +188,29 @@
 #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) \
+    , PARROT_ASSERT_ARG(pf))
 #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: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/src/packfile.c	Mon May  3 04:54:26 2010	(r46226)
@@ -2415,7 +2415,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);
     }
 
@@ -3840,7 +3839,7 @@
 /*
 
 =item C<size_t PackFile_Constant_pack_size(PARROT_INTERP, const
-PackFile_Constant *self)>
+PackFile_Constant *self, const PackFile_ConstTable *ct)>
 
 Determines the size of the buffer needed in order to pack the PackFile Constant
 into a contiguous region of memory.
@@ -3852,7 +3851,8 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 size_t
-PackFile_Constant_pack_size(PARROT_INTERP, ARGIN(const PackFile_Constant *self))
+PackFile_Constant_pack_size(PARROT_INTERP, ARGIN(const PackFile_Constant *self), ARGIN(const
+    PackFile_ConstTable *ct))
 {
     ASSERT_ARGS(PackFile_Constant_pack_size)
     PMC    *component;
@@ -3878,7 +3878,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, ct));
         break;
 
       default:
@@ -3981,7 +3981,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: trunk/src/packout.c
==============================================================================
--- trunk/src/packout.c	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/src/packout.c	Mon May  3 04:54:26 2010	(r46226)
@@ -163,7 +163,7 @@
     size_t size = 1;    /* const_count */
 
     for (i = 0; i < self->const_count; ++i)
-        size += PackFile_Constant_pack_size(interp, self->constants[i]);
+        size += PackFile_Constant_pack_size(interp, self->constants[i], self);
     return size;
 }
 
@@ -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: trunk/src/pmc/imageio.pmc
==============================================================================
--- trunk/src/pmc/imageio.pmc	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/src/pmc/imageio.pmc	Mon May  3 04:54:26 2010	(r46226)
@@ -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);
 
@@ -260,17 +260,22 @@
         break;
       case enum_PackID_normal:
         {
+            PMC * const todo    = PARROT_IMAGEIO(info)->todo;
             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);
 
-            {
-                PMC * const todo    = PARROT_IMAGEIO(info)->todo;
-                VTABLE_set_pmc_keyed_int(interp, todo, id - 1, pmc);
-            }
+            VTABLE_set_pmc_keyed_int(interp, todo, id - 1, pmc);
         }
         break;
       default:
@@ -315,8 +320,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 +335,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 +371,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 +533,41 @@
 
 */
 
-    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)) {
+                        STATICSELF.push_integer(i);
+                        return;
+                    }
+                }
+            }
+            /* XXX
+             * handle cases where the PMC has changed after Parrot_freeze_strings was called
+             * eg: :immediate subs
+             */
+            STATICSELF.push_integer(-1);
+            /* TODO
+             * should really be:
+             * PANIC(INTERP, "string not previously in constant table when freezing to packfile");
+             */
+        }
+
+        {
+            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 +597,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 +617,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 +636,28 @@
 
 */
 
-    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;
+            INTVAL i                   = STATICSELF.shift_integer();
+
+            if (i >= 0)
+                return table->constants[i]->u.string;
+
+            /* XXX
+             * only got here because constant table doesn't contain the string
+             * fallback on inline strings
+             */
+        }
+
+        {
+            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: trunk/src/pmc/imageiosize.pmc
==============================================================================
--- trunk/src/pmc/imageiosize.pmc	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/src/pmc/imageiosize.pmc	Mon May  3 04:54:26 2010	(r46226)
@@ -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);
@@ -59,10 +64,11 @@
 }
 
 pmclass ImageIOSize auto_attrs {
-    ATTR PMC             *seen;           /* seen hash */
-    ATTR PMC             *todo;           /* todo list */
-    ATTR struct PackFile *pf;
-    ATTR INTVAL           size;
+    ATTR PMC                        *seen; /* seen hash */
+    ATTR PMC                        *todo; /* todo list */
+    ATTR struct PackFile            *pf;
+    ATTR struct PackFile_ConstTable *pf_ct;
+    ATTR INTVAL                      size;
 
 /*
 
@@ -84,14 +90,41 @@
 
 */
     VTABLE void init() {
-        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)->todo  = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+        PARROT_IMAGEIOSIZE(SELF)->pf    = PackFile_new(INTERP, 0);
+        PARROT_IMAGEIOSIZE(SELF)->pf_ct = NULL;
+        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_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 *pf_ct) {
+        PARROT_IMAGEIOSIZE(SELF)->todo  = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+        PARROT_IMAGEIOSIZE(SELF)->pf    = PackFile_new(INTERP, 0);
+        PARROT_IMAGEIOSIZE(SELF)->pf_ct = VTABLE_get_pointer(interp, pf_ct);
+        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 +243,40 @@
 
 */
 
-    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)) {
+            /* look for a reference to constant table entry of string */
+            int i;
+            PackFile_ConstTable *table = PARROT_IMAGEIOSIZE(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)) {
+                        STATICSELF.push_integer(i);
+                        return;
+                    }
+                }
+            }
+            /* XXX
+             * handle cases where the PMC has changed after Parrot_freeze_strings was called
+             * eg: :immediate subs
+             */
+            STATICSELF.push_integer(-1);
+            /* TODO
+             * should really be:
+             * PANIC(INTERP, "string not previously in constant table when freezing to packfile");
+             */
+        }
+
+        {
+            const size_t len = PF_size_string(v) * sizeof (opcode_t);
+            PARROT_IMAGEIOSIZE(SELF)->size += len;
+        }
     }
 
 /*

Copied: trunk/src/pmc/imageiostrings.pmc (from r46225, branches/pbc_frozen_strings1/src/pmc/imageiostrings.pmc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/src/pmc/imageiostrings.pmc	Mon May  3 04:54:26 2010	(r46226, copy of r46225, branches/pbc_frozen_strings1/src/pmc/imageiostrings.pmc)
@@ -0,0 +1,199 @@
+/*
+Copyright (C) 2010, Parrot Foundation.
+$Id$
+
+=head1 NAME
+
+src/pmc/imageiosize.pmc - ImageIOStrings PMC
+
+=head1 DESCRIPTION
+
+Get a list of strings in an object graph. Used in packfile creation.
+
+=cut
+
+*/
+
+/* HEADERIZER HFILE: none */
+/* HEADERIZER BEGIN: static */
+/* HEADERIZER END: static */
+
+pmclass ImageIOStrings auto_attrs {
+    ATTR PMC *seen; /* seen hash */
+    ATTR PMC *todo; /* todo list */
+    ATTR PMC *list; /* list of strings seen */
+
+/*
+
+=head1 VTABLES
+
+=over 4
+
+=cut
+
+*/
+
+/*
+
+=item C<void init()>
+
+Initializes the PMC.
+
+=cut
+
+*/
+    VTABLE void init() {
+        PARROT_IMAGEIOSTRINGS(SELF)->todo = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+
+        PARROT_IMAGEIOSTRINGS(SELF)->seen = Parrot_pmc_new(INTERP, enum_class_Hash);
+        VTABLE_set_pointer(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen,
+            parrot_new_intval_hash(INTERP));
+
+        PARROT_IMAGEIOSTRINGS(SELF)->list = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
+    }
+
+/*
+
+=item C<void mark()>
+
+Marks the PMC as alive.
+
+=cut
+
+*/
+    VTABLE void mark() {
+        Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo);
+        Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->seen);
+        Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list);
+    }
+
+/*
+
+=item C<VTABLE PMC *get_pmc()>
+
+Gets the result PMC after a thaw.
+
+=cut
+
+*/
+
+    VTABLE PMC *get_pmc() {
+        return PARROT_IMAGEIOSTRINGS(SELF)->list;
+    }
+
+/*
+
+=item C<VTABLE PMC *get_iter()>
+
+Get the C<todo> list for this freeze/thaw for iterating over.
+
+=cut
+
+*/
+
+    VTABLE PMC *get_iter() {
+        return PARROT_IMAGEIOSTRINGS(SELF)->todo;
+    }
+
+/*
+
+=item C<VTABLE INTVAL get_integer()>
+
+Returns the flags describing the visit action
+
+=cut
+
+*/
+
+    VTABLE INTVAL get_integer() {
+        return VISIT_FREEZE_NORMAL;
+    }
+
+
+/*
+
+=item C<VTABLE void push_integer(INTVAL v)>
+
+Do nothing.
+
+=cut
+
+*/
+
+    VTABLE void push_integer(INTVAL v) { }
+
+
+/*
+
+=item C<VTABLE void push_float(FLOATVAL v)>
+
+Do nothing.
+
+=cut
+
+*/
+
+    VTABLE void push_float(FLOATVAL v) { }
+
+
+/*
+
+=item C<VTABLE void push_string(STRING *v)>
+
+Adds the string to the list of strings.
+
+=cut
+
+*/
+
+    VTABLE void push_string(STRING *v)
+    {
+        VTABLE_push_string(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->list, v);
+    }
+
+/*
+
+=item C<VTABLE void push_pmc(PMC *v)>
+
+Checks new pmcs for strings.
+
+=cut
+
+*/
+
+    VTABLE void push_pmc(PMC *v) {
+        if (!PMC_IS_NULL(v)) {
+            Hash * const hash    = (Hash *)VTABLE_get_pointer(INTERP,
+                                                PARROT_IMAGEIOSTRINGS(SELF)->seen);
+            HashBucket * const b = parrot_hash_get_bucket(INTERP, hash, v);
+            if (!b) {
+                /* not yet seen */
+                parrot_hash_put(INTERP, hash, v, v);
+                VTABLE_push_pmc(INTERP, PARROT_IMAGEIOSTRINGS(SELF)->todo, v);
+                VTABLE_freeze(INTERP, v, SELF);
+            }
+        }
+    }
+
+    VTABLE void set_pmc(PMC *p)
+    {
+        STATICSELF.push_pmc(p);
+        Parrot_visit_loop_visit(INTERP, SELF);
+    }
+
+/*
+
+=back
+
+=cut
+
+*/
+
+}
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Mon May  3 01:04:10 2010	(r46225)
+++ trunk/src/pmc_freeze.c	Mon May  3 04:54:26 2010	(r46226)
@@ -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
 
 */
@@ -86,6 +112,58 @@
     return int_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>.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+UINTVAL
+Parrot_freeze_pbc_size(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(const PackFile_ConstTable *pf))
+{
+    ASSERT_ARGS(Parrot_freeze_pbc_size)
+    PMC     *pf_pmc, *visitor, *pmc_result;
+
+    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_ImageIOSize, pf_pmc);
+    VTABLE_set_pmc(interp, visitor, pmc);
+
+    pmc_result = VTABLE_get_pmc(interp, visitor);
+    return VTABLE_get_integer(interp, pmc_result);
+}
+
+
+/*
+
+=item C<PMC * Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)>
+
+Get the strings of a PMC to be frozen.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+PMC *
+Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)
+{
+    ASSERT_ARGS(Parrot_freeze_strings)
+    PMC *visitor = Parrot_pmc_new(interp, enum_class_ImageIOStrings);
+    VTABLE_set_pmc(interp, visitor, pmc);
+    return VTABLE_get_pmc(interp, visitor);
+}
+
 
 /*
 
@@ -146,6 +224,47 @@
 
 /*
 
+=item C<PMC* Parrot_thaw_pbc(PARROT_INTERP, STRING *image, PackFile_ConstTable
+*pf)>
+
+Thaw a pmc frozen by Parrot_freeze_pbc.
+
+=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_pbc)
+    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.

Modified: trunk/t/native_pbc/annotations.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Copied: trunk/t/pmc/imageiostrings.t (from r46225, branches/pbc_frozen_strings1/t/pmc/imageiostrings.t)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/t/pmc/imageiostrings.t	Mon May  3 04:54:26 2010	(r46226, copy of r46225, branches/pbc_frozen_strings1/t/pmc/imageiostrings.t)
@@ -0,0 +1,47 @@
+#!./parrot
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+t/pmc/imageiostrings.t - test ImageIOStrings PMC
+
+=head1 SYNOPSIS
+
+    % prove t/pmc/imageiostrings.t
+
+=head1 DESCRIPTION
+
+Tests the ImageIOStringsPMC.
+
+=cut
+
+.sub main :main
+    .include 'test_more.pir'
+
+    plan(3)
+
+    .local pmc iios
+    iios = new ['ImageIOStrings']
+    ok(1, 'instantiated ImageIOStrings')
+
+    .local pmc test_pmc
+    test_pmc = null
+    iios = new ['ImageIOStrings']
+    setref iios, test_pmc
+    $P0 = deref iios
+    $I0 = $P0
+    nok( $I0, 'no strings in null pmc' )
+
+    test_pmc = split ' ', 'spam sausage spam spam bacon spam tomato and spam'
+    iios = new ['ImageIOStrings']
+    setref iios, test_pmc
+    $P0 = deref iios
+    is_deeply( $P0, test_pmc, 'correctly manages RSA' )
+.end
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:


More information about the parrot-commits mailing list