[svn:parrot] r44179 - in branches/sys_mem_reduce: include/parrot src src/gc src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Fri Feb 19 13:28:53 UTC 2010


Author: bacek
Date: Fri Feb 19 13:28:52 2010
New Revision: 44179
URL: https://trac.parrot.org/parrot/changeset/44179

Log:
Pass oldsize to realloc_zeroed

Modified:
   branches/sys_mem_reduce/include/parrot/gc_api.h
   branches/sys_mem_reduce/include/parrot/memory.h
   branches/sys_mem_reduce/src/gc/api.c
   branches/sys_mem_reduce/src/gc/gc_ms.c
   branches/sys_mem_reduce/src/gc/gc_private.h
   branches/sys_mem_reduce/src/packfile.c
   branches/sys_mem_reduce/src/pbc_merge.c
   branches/sys_mem_reduce/src/pmc/resizablestringarray.pmc

Modified: branches/sys_mem_reduce/include/parrot/gc_api.h
==============================================================================
--- branches/sys_mem_reduce/include/parrot/gc_api.h	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/include/parrot/gc_api.h	Fri Feb 19 13:28:52 2010	(r44179)
@@ -154,7 +154,8 @@
 PARROT_CANNOT_RETURN_NULL
 void * Parrot_gc_reallocate_memory_chunk_with_interior_pointers(PARROT_INTERP,
     ARGIN(void *data),
-    size_t newsize)
+    size_t newsize,
+    size_t oldsize)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 

Modified: branches/sys_mem_reduce/include/parrot/memory.h
==============================================================================
--- branches/sys_mem_reduce/include/parrot/memory.h	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/include/parrot/memory.h	Fri Feb 19 13:28:52 2010	(r44179)
@@ -45,13 +45,13 @@
 #define mem_gc_allocate_n_typed(i, n, type) \
         (type *)Parrot_gc_allocate_memory_chunk((i), (n) * sizeof(type))
 #define mem_gc_realloc_n_typed(i, p, n, type) \
-        (p) = (type *)Parrot_gc_reallocate_memory_chunk((i), (p), (n)*sizeof(type))
+        (type *)Parrot_gc_reallocate_memory_chunk((i), (p), (n)*sizeof(type))
 #define mem_gc_allocate_zeroed_typed(i, type) \
         (type *)Parrot_gc_allocate_memory_chunk_with_interior_pointers((i), sizeof (type))
 #define mem_gc_allocate_n_zeroed_typed(i, n, type) \
         (type *)Parrot_gc_allocate_memory_chunk_with_interior_pointers((i), (n) * sizeof(type))
-#define mem_gc_realloc_n_typed_zeroed(i, p, n, type) \
-        (p) = (type *)Parrot_gc_reallocate_memory_chunk_with_interior_pointers((i), (p), (n)*sizeof(type))
+#define mem_gc_realloc_n_typed_zeroed(i, p, n, o, type) \
+        (type *)Parrot_gc_reallocate_memory_chunk_with_interior_pointers((i), (p), (n)*sizeof(type), (o)*sizeof(type))
 #define mem_gc_free(i, p) \
         Parrot_gc_free_memory_chunk((i), (p))
 

Modified: branches/sys_mem_reduce/src/gc/api.c
==============================================================================
--- branches/sys_mem_reduce/src/gc/api.c	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/gc/api.c	Fri Feb 19 13:28:52 2010	(r44179)
@@ -665,7 +665,7 @@
 
 =item C<void *
 Parrot_gc_reallocate_memory_chunk_with_interior_pointers(PARROT_INTERP, void
-*data, size_t newsize)>
+*data, size_t newsize, size_t oldsize)>
 
 TODO Write docu.
 
@@ -711,10 +711,12 @@
 PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
 void *
-Parrot_gc_reallocate_memory_chunk_with_interior_pointers(PARROT_INTERP, ARGIN(void *data), size_t newsize)
+Parrot_gc_reallocate_memory_chunk_with_interior_pointers(PARROT_INTERP,
+        ARGIN(void *data), size_t newsize, size_t oldsize)
 {
     ASSERT_ARGS(Parrot_gc_allocate_memory_chunk)
-    return interp->gc_sys->reallocate_memory_chunk_with_interior_pointers(interp, data, newsize);
+    return interp->gc_sys->reallocate_memory_chunk_with_interior_pointers(interp,
+            data, newsize, oldsize);
 }
 
 

Modified: branches/sys_mem_reduce/src/gc/gc_ms.c
==============================================================================
--- branches/sys_mem_reduce/src/gc/gc_ms.c	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/gc/gc_ms.c	Fri Feb 19 13:28:52 2010	(r44179)
@@ -169,6 +169,13 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+static void * gc_ms_reallocate_memory_chunk_zeroed(PARROT_INTERP,
+    ARGIN(void *data),
+    size_t newsize,
+    size_t oldsize)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
 static void gc_ms_reallocate_string_storage(PARROT_INTERP,
     ARGMOD(STRING *str),
     size_t newsize)
@@ -283,6 +290,10 @@
 #define ASSERT_ARGS_gc_ms_reallocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(data))
+#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk_zeroed \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(data))
 #define ASSERT_ARGS_gc_ms_reallocate_string_storage \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -369,7 +380,7 @@
     interp->gc_sys->allocate_memory_chunk_with_interior_pointers
                 = gc_ms_allocate_memory_chunk;
     interp->gc_sys->reallocate_memory_chunk_with_interior_pointers
-                = gc_ms_reallocate_memory_chunk;
+                = gc_ms_reallocate_memory_chunk_zeroed;
     interp->gc_sys->free_memory_chunk       = gc_ms_free_memory_chunk;
 
     interp->gc_sys->block_mark      = gc_ms_block_GC_mark;
@@ -1109,6 +1120,14 @@
     return mem_internal_realloc(data, newsize);
 }
 
+static void *
+gc_ms_reallocate_memory_chunk_zeroed(PARROT_INTERP, ARGIN(void *data),
+        size_t newsize, size_t oldsize)
+{
+    ASSERT_ARGS(gc_ms_allocate_memory_chunk)
+    return mem_internal_realloc_zeroed(data, newsize, oldsize);
+}
+
 static void
 gc_ms_free_memory_chunk(PARROT_INTERP, ARGIN(void *data))
 {

Modified: branches/sys_mem_reduce/src/gc/gc_private.h
==============================================================================
--- branches/sys_mem_reduce/src/gc/gc_private.h	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/gc/gc_private.h	Fri Feb 19 13:28:52 2010	(r44179)
@@ -135,7 +135,8 @@
     void* (*allocate_memory_chunk)(PARROT_INTERP, size_t size);
     void* (*reallocate_memory_chunk)(PARROT_INTERP, void *data, size_t newsize);
     void* (*allocate_memory_chunk_with_interior_pointers)(PARROT_INTERP, size_t size);
-    void* (*reallocate_memory_chunk_with_interior_pointers)(PARROT_INTERP, void *data, size_t newsize);
+    void* (*reallocate_memory_chunk_with_interior_pointers)(PARROT_INTERP, void *data,
+            size_t oldsize, size_t newsize);
     void  (*free_memory_chunk)(PARROT_INTERP, void *data);
 
     void (*block_mark)(PARROT_INTERP);

Modified: branches/sys_mem_reduce/src/packfile.c
==============================================================================
--- branches/sys_mem_reduce/src/packfile.c	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/packfile.c	Fri Feb 19 13:28:52 2010	(r44179)
@@ -4454,7 +4454,7 @@
     if (self->groups)
         self->groups =
             self->groups = mem_gc_realloc_n_typed_zeroed(interp, self->groups,
-                1 + self->num_groups, PackFile_Annotations_Group *);
+                1 + self->num_groups, self->num_groups, PackFile_Annotations_Group *);
     else
         self->groups = mem_gc_allocate_n_typed(interp,
                 1 + self->num_groups, PackFile_Annotations_Group *);
@@ -4510,7 +4510,7 @@
         /* We do have it. Add key entry. */
         if (self->keys)
             self->keys = mem_gc_realloc_n_typed_zeroed(interp, self->keys,
-                    1 + self->num_keys, PackFile_Annotations_Key *);
+                    1 + self->num_keys, self->num_keys, PackFile_Annotations_Key *);
         else
             self->keys = mem_gc_allocate_n_typed(interp,
                     1 + self->num_keys, PackFile_Annotations_Key *);

Modified: branches/sys_mem_reduce/src/pbc_merge.c
==============================================================================
--- branches/sys_mem_reduce/src/pbc_merge.c	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/pbc_merge.c	Fri Feb 19 13:28:52 2010	(r44179)
@@ -414,7 +414,7 @@
 
         /* Allocate space for the constant list, provided we have some. */
         if (in_seg->const_count > 0)
-            contants = mem_gc_realloc_n_typed(interp, constants,
+            constants = mem_gc_realloc_n_typed(interp, constants,
                     cursor + in_seg->const_count, PackFile_Constant*);
 
         /* Loop over the constants and copy them to the output PBC. */

Modified: branches/sys_mem_reduce/src/pmc/resizablestringarray.pmc
==============================================================================
--- branches/sys_mem_reduce/src/pmc/resizablestringarray.pmc	Fri Feb 19 13:28:24 2010	(r44178)
+++ branches/sys_mem_reduce/src/pmc/resizablestringarray.pmc	Fri Feb 19 13:28:52 2010	(r44179)
@@ -241,7 +241,8 @@
             }
 
             SET_ATTR_str_array(INTERP, SELF,
-                    mem_gc_realloc_n_typed_zeroed(INTERP, str_array, cur, STRING*));
+                    mem_gc_realloc_n_typed_zeroed(INTERP, str_array,
+                            cur, resize_threshold, STRING*));
             GET_ATTR_str_array(INTERP, SELF, str_array);
 
             for (; i < cur; i++)


More information about the parrot-commits mailing list