[svn:parrot] r48470 - branches/gc_threshold_tuning/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Aug 14 00:32:26 UTC 2010


Author: chromatic
Date: Sat Aug 14 00:32:26 2010
New Revision: 48470
URL: https://trac.parrot.org/parrot/changeset/48470

Log:
avoid creating useless packfile objects when performing freeze/thaw operations on packfiles

also avoids generating PBC headers for each constant in the const table

improves rakudo hello world by 0.586%

Modified:
   branches/gc_threshold_tuning/src/pmc/imageio.pmc
   branches/gc_threshold_tuning/src/pmc/imageiosize.pmc

Modified: branches/gc_threshold_tuning/src/pmc/imageio.pmc
==============================================================================
--- branches/gc_threshold_tuning/src/pmc/imageio.pmc	Sat Aug 14 00:32:23 2010	(r48469)
+++ branches/gc_threshold_tuning/src/pmc/imageio.pmc	Sat Aug 14 00:32:26 2010	(r48470)
@@ -380,11 +380,11 @@
 */
     VTABLE void init() {
         PARROT_IMAGEIO(SELF)->seen = PMCNULL;
-        PARROT_IMAGEIO(SELF)->pf   = PackFile_new(INTERP, 0);
         PARROT_IMAGEIO(SELF)->todo =
             Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
 
         PObj_flag_CLEAR(private1, SELF);
+        PObj_flag_CLEAR(private2, SELF);
 
         PObj_custom_mark_destroy_SETALL(SELF);
     }
@@ -423,7 +423,8 @@
 
 */
     VTABLE void destroy() {
-        PackFile_destroy(INTERP, PARROT_IMAGEIO(SELF)->pf);
+        if (!PObj_flag_TEST(private2, SELF))
+            PackFile_destroy(INTERP, PARROT_IMAGEIO(SELF)->pf);
         PARROT_IMAGEIO(SELF)->pf = NULL;
     }
 
@@ -723,10 +724,18 @@
         PARROT_IMAGEIO(SELF)->what  = VISIT_FREEZE_NORMAL;
 
         create_buffer(INTERP, p, SELF);
-        ensure_buffer_size(INTERP, SELF, header_length);
-        mem_sys_memcopy(GET_VISIT_CURSOR(SELF),
-            PARROT_IMAGEIO(SELF)->pf->header, PACKFILE_HEADER_BYTES);
-        INC_VISIT_CURSOR(SELF, header_length);
+        if (PObj_flag_TEST(private1, SELF)) {
+            PObj_flag_SET(private2, SELF);
+            PARROT_IMAGEIO(SELF)->pf = PARROT_IMAGEIO(SELF)->pf_ct->base.pf;
+        }
+        else {
+            PARROT_IMAGEIO(SELF)->pf   = PackFile_new(INTERP, 0);
+
+            ensure_buffer_size(INTERP, SELF, header_length);
+            mem_sys_memcopy(GET_VISIT_CURSOR(SELF),
+                PARROT_IMAGEIO(SELF)->pf->header, PACKFILE_HEADER_BYTES);
+            INC_VISIT_CURSOR(SELF, header_length);
+        }
 
         PARROT_IMAGEIO(SELF)->seen = Parrot_pmc_new(INTERP, enum_class_Hash);
         VTABLE_set_pointer(INTERP, PARROT_IMAGEIO(SELF)->seen,
@@ -738,7 +747,6 @@
 
     VTABLE void set_string_native(STRING *image) {
         PMC          *unused;
-        int           unpacked_length;
         const UINTVAL header_length =
              GROW_TO_16_BYTE_BOUNDARY(PACKFILE_HEADER_BYTES);
 
@@ -751,16 +759,26 @@
             (const char *)Buffer_bufstart(PARROT_IMAGEIO(SELF)->buffer));
         PARROT_IMAGEIO(SELF)->input_length = image->strlen;
 
-        PARROT_IMAGEIO(SELF)->pf->options |= PFOPT_PMC_FREEZE_ONLY;
-        unpacked_length = PackFile_unpack(INTERP, PARROT_IMAGEIO(SELF)->pf,
-            GET_VISIT_CURSOR(SELF), PARROT_IMAGEIO(SELF)->input_length);
+        if (PObj_flag_TEST(private1, SELF)) {
+            PObj_flag_SET(private2, SELF);
+            PARROT_IMAGEIO(SELF)->pf = PARROT_IMAGEIO(SELF)->pf_ct->base.pf;
+        }
+        else {
+            int unpacked_length;
 
-        if (unpacked_length)
-            INC_VISIT_CURSOR(SELF, header_length);
-        else
-            Parrot_ex_throw_from_c_args(INTERP, NULL,
-                    EXCEPTION_INVALID_STRING_REPRESENTATION,
-                    "PackFile header failed during unpack");
+            PARROT_IMAGEIO(SELF)->pf   = PackFile_new(INTERP, 0);
+
+            PARROT_IMAGEIO(SELF)->pf->options |= PFOPT_PMC_FREEZE_ONLY;
+            unpacked_length = PackFile_unpack(INTERP, PARROT_IMAGEIO(SELF)->pf,
+                GET_VISIT_CURSOR(SELF), PARROT_IMAGEIO(SELF)->input_length);
+
+            if (unpacked_length)
+                INC_VISIT_CURSOR(SELF, header_length);
+            else
+                Parrot_ex_throw_from_c_args(INTERP, NULL,
+                        EXCEPTION_INVALID_STRING_REPRESENTATION,
+                        "PackFile header failed during unpack");
+        }
 
         unused = STATICSELF.shift_pmc();
         Parrot_visit_loop_visit(INTERP, SELF);

Modified: branches/gc_threshold_tuning/src/pmc/imageiosize.pmc
==============================================================================
--- branches/gc_threshold_tuning/src/pmc/imageiosize.pmc	Sat Aug 14 00:32:23 2010	(r48469)
+++ branches/gc_threshold_tuning/src/pmc/imageiosize.pmc	Sat Aug 14 00:32:26 2010	(r48470)
@@ -303,8 +303,10 @@
 
     VTABLE void set_pmc(PMC *p)
     {
-        UINTVAL header_length = GROW_TO_16_BYTE_BOUNDARY(PACKFILE_HEADER_BYTES);
-        PARROT_IMAGEIOSIZE(SELF)->size += header_length;
+        if (!PObj_flag_TEST(private1, SELF)) {
+            UINTVAL header_length = GROW_TO_16_BYTE_BOUNDARY(PACKFILE_HEADER_BYTES);
+            PARROT_IMAGEIOSIZE(SELF)->size += header_length;
+        }
 
         visit_todo_list_freeze(INTERP, p, SELF);
         Parrot_visit_loop_visit(INTERP, SELF);


More information about the parrot-commits mailing list