[svn:parrot] r49559 - trunk/src/gc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Oct 16 23:15:43 UTC 2010


Author: chromatic
Date: Sat Oct 16 23:15:43 2010
New Revision: 49559
URL: https://trac.parrot.org/parrot/changeset/49559

Log:
[GC] Tidied code; no functional changes.

Modified:
   trunk/src/gc/gc_ms2.c

Modified: trunk/src/gc/gc_ms2.c
==============================================================================
--- trunk/src/gc/gc_ms2.c	Sat Oct 16 23:15:38 2010	(r49558)
+++ trunk/src/gc/gc_ms2.c	Sat Oct 16 23:15:43 2010	(r49559)
@@ -373,10 +373,8 @@
 
 =item C<static void gc_ms2_mark_and_sweep(PARROT_INTERP, UINTVAL flags)>
 
-This function would perform a GC run, if we needed to. Luckily we have
-infinite memory!
-
-This function is called from the GC API function C<Parrot_gc_mark_and_sweep>.
+Performs a GC run.  This function is called from the GC API function
+C<Parrot_gc_mark_and_sweep>.
 
 Flags can be a combination of these values:
 
@@ -388,6 +386,7 @@
 
 */
 
+
 /*
 
 =item C<static void gc_ms2_compact_memory_pool(PARROT_INTERP)>
@@ -397,6 +396,7 @@
 =cut
 
 */
+
 static void
 gc_ms2_compact_memory_pool(PARROT_INTERP)
 {
@@ -405,6 +405,7 @@
     Parrot_gc_str_compact_pool(interp, &self->string_gc);
 }
 
+
 /*
 
 =item C<static PMC* gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)>
@@ -449,21 +450,24 @@
 gc_ms2_allocate_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
     ASSERT_ARGS(gc_ms2_allocate_pmc_attributes)
-    MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+    MarkSweep_GC *self      = (MarkSweep_GC *)interp->gc_sys->gc_private;
     const size_t  attr_size = pmc->vtable->attr_size;
-    PMC_data(pmc) = Parrot_gc_fixed_allocator_allocate(interp,
-                        self->fixed_size_allocator, attr_size);
-    memset(PMC_data(pmc), 0, attr_size);
 
+    PMC_data(pmc)           = Parrot_gc_fixed_allocator_allocate(interp,
+                                self->fixed_size_allocator, attr_size);
+
+    memset(PMC_data(pmc), 0, attr_size);
     interp->gc_sys->stats.mem_used_last_collect += attr_size;
 
     return PMC_data(pmc);
 }
 
+
 static void
 gc_ms2_free_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
     ASSERT_ARGS(gc_ms2_free_pmc_attributes)
+
     if (PMC_data(pmc)) {
         MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
         Parrot_gc_fixed_allocator_free(interp, self->fixed_size_allocator,
@@ -473,6 +477,7 @@
     }
 }
 
+
 PARROT_CAN_RETURN_NULL
 static void*
 gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
@@ -483,9 +488,11 @@
     interp->gc_sys->stats.memory_allocated      += size;
     interp->gc_sys->stats.mem_used_last_collect += size;
 
-    return Parrot_gc_fixed_allocator_allocate(interp, self->fixed_size_allocator, size);
+    return Parrot_gc_fixed_allocator_allocate(interp,
+                self->fixed_size_allocator, size);
 }
 
+
 static void
 gc_ms2_free_fixed_size_storage(PARROT_INTERP, size_t size, ARGMOD(void *data))
 {
@@ -496,10 +503,12 @@
         interp->gc_sys->stats.memory_allocated      -= size;
         interp->gc_sys->stats.mem_used_last_collect -= size;
 
-        Parrot_gc_fixed_allocator_free(interp, self->fixed_size_allocator, data, size);
+        Parrot_gc_fixed_allocator_free(interp, self->fixed_size_allocator,
+                                         data, size);
     }
 }
 
+
 /*
 
 =item C<static size_t gc_ms2_get_gc_info(PARROT_INTERP, Interpinfo_enum which)>
@@ -523,8 +532,6 @@
 }
 
 
-
-
 /*
 
 =item C<void Parrot_gc_ms2_init(PARROT_INTERP)>
@@ -546,41 +553,42 @@
     ASSERT_ARGS(Parrot_gc_ms2_init)
     struct MarkSweep_GC *self;
 
-    /* We have to transfer ownership of memory to parent interp in threaded parrot */
-    interp->gc_sys->finalize_gc_system = gc_ms2_finalize;
+    /* We have to transfer ownership of memory to parent interp
+     * in threaded parrot */
+    interp->gc_sys->finalize_gc_system          = gc_ms2_finalize;
 
-    interp->gc_sys->do_gc_mark              = gc_ms2_mark_and_sweep;
-    interp->gc_sys->compact_string_pool     = gc_ms2_compact_memory_pool;
+    interp->gc_sys->do_gc_mark                  = gc_ms2_mark_and_sweep;
+    interp->gc_sys->compact_string_pool         = gc_ms2_compact_memory_pool;
 
     /*
     interp->gc_sys->mark_special                = gc_ms2_mark_special;
     */
     interp->gc_sys->pmc_needs_early_collection  = gc_ms2_pmc_needs_early_collection;
 
-    interp->gc_sys->allocate_pmc_header     = gc_ms2_allocate_pmc_header;
-    interp->gc_sys->free_pmc_header         = gc_ms2_free_pmc_header;
+    interp->gc_sys->allocate_pmc_header         = gc_ms2_allocate_pmc_header;
+    interp->gc_sys->free_pmc_header             = gc_ms2_free_pmc_header;
 
-    interp->gc_sys->allocate_string_header  = gc_ms2_allocate_string_header;
-    interp->gc_sys->free_string_header      = gc_ms2_free_string_header;
+    interp->gc_sys->allocate_string_header      = gc_ms2_allocate_string_header;
+    interp->gc_sys->free_string_header          = gc_ms2_free_string_header;
 
     interp->gc_sys->allocate_bufferlike_header  = gc_ms2_allocate_buffer_header;
     interp->gc_sys->free_bufferlike_header      = gc_ms2_free_buffer_header;
 
-    interp->gc_sys->allocate_pmc_attributes = gc_ms2_allocate_pmc_attributes;
-    interp->gc_sys->free_pmc_attributes     = gc_ms2_free_pmc_attributes;
+    interp->gc_sys->allocate_pmc_attributes     = gc_ms2_allocate_pmc_attributes;
+    interp->gc_sys->free_pmc_attributes         = gc_ms2_free_pmc_attributes;
 
-    interp->gc_sys->is_pmc_ptr              = gc_ms2_is_pmc_ptr;
-    interp->gc_sys->is_string_ptr           = gc_ms2_is_string_ptr;
-    interp->gc_sys->mark_pmc_header         = gc_ms2_mark_pmc_header;
-    interp->gc_sys->mark_pobj_header        = gc_ms2_mark_pobj_header;
-
-    interp->gc_sys->block_mark      = gc_ms2_block_GC_mark;
-    interp->gc_sys->unblock_mark    = gc_ms2_unblock_GC_mark;
-    interp->gc_sys->is_blocked_mark = gc_ms2_is_blocked_GC_mark;
-
-    interp->gc_sys->block_sweep      = gc_ms2_block_GC_sweep;
-    interp->gc_sys->unblock_sweep    = gc_ms2_unblock_GC_sweep;
-    interp->gc_sys->is_blocked_sweep = gc_ms2_is_blocked_GC_sweep;
+    interp->gc_sys->is_pmc_ptr                  = gc_ms2_is_pmc_ptr;
+    interp->gc_sys->is_string_ptr               = gc_ms2_is_string_ptr;
+    interp->gc_sys->mark_pmc_header             = gc_ms2_mark_pmc_header;
+    interp->gc_sys->mark_pobj_header            = gc_ms2_mark_pobj_header;
+
+    interp->gc_sys->block_mark                  = gc_ms2_block_GC_mark;
+    interp->gc_sys->unblock_mark                = gc_ms2_unblock_GC_mark;
+    interp->gc_sys->is_blocked_mark             = gc_ms2_is_blocked_GC_mark;
+
+    interp->gc_sys->block_sweep                 = gc_ms2_block_GC_sweep;
+    interp->gc_sys->unblock_sweep               = gc_ms2_unblock_GC_sweep;
+    interp->gc_sys->is_blocked_sweep            = gc_ms2_is_blocked_GC_sweep;
 
     interp->gc_sys->allocate_string_storage     = gc_ms2_allocate_string_storage;
     interp->gc_sys->reallocate_string_storage   = gc_ms2_reallocate_string_storage;
@@ -594,15 +602,16 @@
     /* We don't distinguish between chunk and chunk_with_pointers */
     interp->gc_sys->allocate_memory_chunk   = gc_ms2_allocate_memory_chunk;
     interp->gc_sys->reallocate_memory_chunk = gc_ms2_reallocate_memory_chunk;
+
     interp->gc_sys->allocate_memory_chunk_with_interior_pointers
                 = gc_ms2_allocate_memory_chunk_zeroed;
     interp->gc_sys->reallocate_memory_chunk_with_interior_pointers
                 = gc_ms2_reallocate_memory_chunk_zeroed;
     interp->gc_sys->free_memory_chunk       = gc_ms2_free_memory_chunk;
 
-    interp->gc_sys->iterate_live_strings = gc_ms2_iterate_live_strings;
+    interp->gc_sys->iterate_live_strings    = gc_ms2_iterate_live_strings;
 
-    interp->gc_sys->get_gc_info      = gc_ms2_get_gc_info;
+    interp->gc_sys->get_gc_info             = gc_ms2_get_gc_info;
 
     if (interp->parent_interpreter && interp->parent_interpreter->gc_sys) {
         /* This is a "child" interpreter. Just reuse parent one */
@@ -625,8 +634,8 @@
         /* Hardcode for now. Will be configured via CLI */
         self->gc_threshold = 16 * 1024 * 1024;
     }
-    interp->gc_sys->gc_private = self;
 
+    interp->gc_sys->gc_private = self;
     Parrot_gc_str_initialize(interp, &self->string_gc);
 }
 
@@ -659,20 +668,21 @@
     }
 }
 
+
 PARROT_MALLOC
 PARROT_CAN_RETURN_NULL
 static PMC*
 gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
 {
     ASSERT_ARGS(gc_ms2_allocate_pmc_header)
-    MarkSweep_GC      *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+    MarkSweep_GC     *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
     List_Item_Header *ptr;
-    PMC              *ret;
 
     gc_ms2_maybe_mark_and_sweep(interp);
 
     /* Increase used memory. Not precisely accurate due Pool_Allocator paging */
     ++interp->gc_sys->stats.header_allocs_since_last_collect;
+
     interp->gc_sys->stats.memory_allocated      += sizeof (PMC);
     interp->gc_sys->stats.mem_used_last_collect += sizeof (PMC);
 
@@ -680,16 +690,16 @@
             self->pmc_allocator);
     LIST_APPEND(self->objects, ptr);
 
-    ret = LLH2Obj_typed(ptr, PMC);
-
-    return ret;
+    return LLH2Obj_typed(ptr, PMC);
 }
 
+
 static void
 gc_ms2_free_pmc_header(PARROT_INTERP, ARGFREE(PMC *pmc))
 {
     ASSERT_ARGS(gc_ms2_free_pmc_header)
     MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+
     if (pmc) {
         if (PObj_on_free_list_TEST(pmc))
             return;
@@ -706,6 +716,7 @@
     }
 }
 
+
 /*
 
 =item C<static void gc_ms2_mark_pmc_header(PARROT_INTERP, PMC *pmc)>
@@ -735,11 +746,12 @@
 
 }
 
+
 /*
 
 =item C<static int gc_ms2_is_pmc_ptr(PARROT_INTERP, void *ptr)>
 
-establish if *ptr is.owned
+Establish if *ptr is.owned.
 
 =cut
 
@@ -753,11 +765,12 @@
     return gc_ms2_is_ptr_owned(interp, ptr, self->pmc_allocator, self->objects);
 }
 
+
 /*
 
 =item C<static void gc_ms2_sweep_pmc_cb(PARROT_INTERP, PObj *obj)>
 
-destroy pmc *obj
+Destroys PMC *obj.
 
 =cut
 
@@ -767,11 +780,12 @@
 gc_ms2_sweep_pmc_cb(PARROT_INTERP, ARGIN(PObj *obj))
 {
     ASSERT_ARGS(gc_ms2_sweep_pmc_cb)
-    PMC *pmc = (PMC *)obj;
-    Parrot_pmc_destroy(interp, pmc);
+    Parrot_pmc_destroy(interp, (PMC *)obj);
 }
 
+
 /*
+
 =item C<gc_ms2_allocate_string_header()>
 
 =item C<gc_ms2_free_string_header()>
@@ -812,18 +826,21 @@
     return ret;
 }
 
+
 static void
 gc_ms2_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
 {
     ASSERT_ARGS(gc_ms2_free_string_header)
-    MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
-    if (s) {
-        if (PObj_on_free_list_TEST(s))
-            return;
+
+    if (s
+    && !PObj_on_free_list_TEST(s)) {
+        MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+
         Parrot_list_remove(interp, self->strings, Obj2LLH(s));
 
         if (Buffer_bufstart(s) && !PObj_external_TEST(s))
-            Parrot_gc_str_free_buffer_storage(interp, &self->string_gc, (Buffer *)s);
+            Parrot_gc_str_free_buffer_storage(interp,
+                &self->string_gc, (Buffer *)s);
 
         PObj_on_free_list_SET(s);
 
@@ -835,15 +852,17 @@
     }
 }
 
+
 PARROT_MALLOC
 PARROT_CAN_RETURN_NULL
 static Buffer*
 gc_ms2_allocate_buffer_header(PARROT_INTERP, SHIM(size_t size))
 {
     ASSERT_ARGS(gc_ms2_allocate_buffer_header)
-    return (Buffer*)gc_ms2_allocate_string_header(interp, 0);
+    return (Buffer *)gc_ms2_allocate_string_header(interp, 0);
 }
 
+
 static void
 gc_ms2_free_buffer_header(PARROT_INTERP, ARGFREE(Buffer *s), SHIM(size_t size))
 {
@@ -851,11 +870,12 @@
     gc_ms2_free_string_header(interp, (STRING*)s);
 }
 
+
 /*
 
 =item C<static int gc_ms2_is_string_ptr(PARROT_INTERP, void *ptr)>
 
-establish if string *ptr is owned
+Establish if STRING *ptr is owned.
 
 =cut
 
@@ -866,9 +886,11 @@
 {
     ASSERT_ARGS(gc_ms2_is_string_ptr)
     MarkSweep_GC      *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
-    return gc_ms2_is_ptr_owned(interp, ptr, self->string_allocator, self->strings);
+    return gc_ms2_is_ptr_owned(interp, ptr, self->string_allocator,
+            self->strings);
 }
 
+
 /*
 
 item C<void gc_ms_allocate_string_storage(PARROT_INTERP, STRING *str, size_t
@@ -886,6 +908,7 @@
 Functions for allocating strings/buffers storage.
 
 =cut
+
 */
 
 static void
@@ -897,6 +920,7 @@
     interp->gc_sys->stats.mem_used_last_collect += size;
 }
 
+
 static void
 gc_ms2_reallocate_string_storage(PARROT_INTERP, ARGIN(STRING *str), size_t size)
 {
@@ -906,6 +930,7 @@
     interp->gc_sys->stats.mem_used_last_collect += size;
 }
 
+
 static void
 gc_ms2_allocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
 {
@@ -915,6 +940,7 @@
     interp->gc_sys->stats.mem_used_last_collect += size;
 }
 
+
 static void
 gc_ms2_reallocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
 {
@@ -924,11 +950,12 @@
     interp->gc_sys->stats.mem_used_last_collect += size;
 }
 
+
 /*
 
 =item C<static void gc_ms2_mark_pobj_header(PARROT_INTERP, PObj * obj)>
 
-Mark PObj as live.
+Marks PObj as live.
 
 =cut
 
@@ -946,11 +973,12 @@
     }
 }
 
+
 /*
 
 =item C<static void gc_ms2_sweep_string_cb(PARROT_INTERP, PObj *obj)>
 
-destroy string *obj
+Destroys STRING *obj.
 
 =cut
 
@@ -962,7 +990,8 @@
     ASSERT_ARGS(gc_ms2_sweep_string_cb)
     MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
     Buffer       *str  = (Buffer *)obj;
-    /* Compact string pool here. Or get rid of "shared buffers" and just free storage */
+    /* Compact string pool here.
+     * (or get rid of "shared buffers" and just free storage) */
     if (Buffer_bufstart(str) && !PObj_external_TEST(str))
         Parrot_gc_str_free_buffer_storage(interp, &self->string_gc, str);
 }
@@ -973,11 +1002,13 @@
 =item C<static void gc_ms2_iterate_live_strings(PARROT_INTERP,
 string_iterator_callback callback, void *data)>
 
-Iterate over live string invoking callback for each of them. Used during
+Iterates over live strings invoking callback for each of them. Used during
 compacting of string pool.
 
 =cut
+
 */
+
 static void
 gc_ms2_iterate_live_strings(PARROT_INTERP,
         string_iterator_callback callback,
@@ -1000,11 +1031,10 @@
 gc_ms2_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
 {
     ASSERT_ARGS(gc_ms2_mark_and_sweep)
-    MarkSweep_GC      *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+    MarkSweep_GC     *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
     List_Item_Header *tmp;
     Linked_List      *list;
     size_t            counter;
-    UNUSED(flags);
 
     /* GC is blocked */
     if (self->gc_mark_block_level)
@@ -1030,13 +1060,15 @@
 
     Parrot_gc_trace_root(interp, NULL, GC_TRACE_FULL);
     if (interp->pdb && interp->pdb->debugger) {
-        Parrot_gc_trace_root(interp->pdb->debugger, NULL, (Parrot_gc_trace_type)0);
+        Parrot_gc_trace_root(interp->pdb->debugger, NULL,
+            (Parrot_gc_trace_type)0);
     }
 
-    /* new_objects are "gray" untill fully marked */
-    /* Additional gray objects will appened to new_objects list */
+    /* new_objects are "gray" until fully marked */
+    /* Additional gray objects will append to new_objects list */
     /* So, iterate over them in one go */
     tmp = self->new_objects->first;
+
     while (tmp) {
         PMC *pmc = LLH2Obj_typed(tmp, PMC);
         /* if object is a PMC and contains buffers or PMCs, then attach the PMC
@@ -1056,35 +1088,40 @@
     /* objects contains "dead" or "constant" PMCs */
     /* sweep of new_objects will repaint them white */
     /* sweep of objects will destroy dead objects leaving only "constant" */
-    gc_ms2_sweep_pool(interp, self->pmc_allocator, self->new_objects, gc_ms2_sweep_pmc_cb);
-    gc_ms2_sweep_pool(interp, self->pmc_allocator, self->objects, gc_ms2_sweep_pmc_cb);
-    gc_ms2_sweep_pool(interp, self->string_allocator, self->strings, gc_ms2_sweep_string_cb);
+    gc_ms2_sweep_pool(interp, self->pmc_allocator, self->new_objects,
+                            gc_ms2_sweep_pmc_cb);
+    gc_ms2_sweep_pool(interp, self->pmc_allocator, self->objects,
+                            gc_ms2_sweep_pmc_cb);
+    gc_ms2_sweep_pool(interp, self->string_allocator, self->strings,
+                            gc_ms2_sweep_string_cb);
 
     /* Replace objects with new_objects. Ignoring "constant" one */
-    list = self->objects;
+    list          = self->objects;
     self->objects = self->new_objects;
     Parrot_list_destroy(interp, list);
 
-    interp->gc_sys->stats.header_allocs_since_last_collect = 0;
+    /* We swept all dead objects */
+    self->num_early_gc_PMCs                                = 0;
     interp->gc_sys->stats.mem_used_last_collect            = 0;
-    interp->gc_sys->stats.gc_mark_runs++;
+    interp->gc_sys->stats.header_allocs_since_last_collect = 0;
     self->gc_mark_block_level--;
-    /* We swept all dead objects */
-    self->num_early_gc_PMCs                      = 0;
+    interp->gc_sys->stats.gc_mark_runs++;
 
     gc_ms2_compact_memory_pool(interp);
 }
 
 
-
 /*
+
 =item C<static void gc_ms2_sweep_pool(PARROT_INTERP, Pool_Allocator *pool,
 Linked_List *list, sweep_cb callback)>
 
 Helper function to sweep pool.
 
 =cut
+
 */
+
 static void
 gc_ms2_sweep_pool(PARROT_INTERP,
         ARGIN(Pool_Allocator *pool),
@@ -1093,13 +1130,15 @@
 {
     ASSERT_ARGS(gc_ms2_sweep_pool)
     List_Item_Header *tmp = list->first;
+
     while (tmp) {
         List_Item_Header *next = tmp->next;
         PObj             *obj  = LLH2Obj_typed(tmp, PObj);
-        if (PObj_live_TEST(obj)) {
-            /* Paint live objects white */
+
+        /* Paint live objects white */
+        if (PObj_live_TEST(obj))
             PObj_live_CLEAR(obj);
-        }
+
         else if (!PObj_constant_TEST(obj)) {
             LIST_REMOVE(list, tmp);
 
@@ -1109,19 +1148,21 @@
 
             Parrot_gc_pool_free(interp, pool, tmp);
         }
+
         tmp = next;
     }
 }
 
 
-
 /*
+
 =item C<static int gc_ms2_is_ptr_owned(PARROT_INTERP, void *ptr, Pool_Allocator
 *pool, Linked_List *list)>
 
 Helper function to check that we own PObj
 
 =cut
+
 */
 
 static int
@@ -1190,6 +1231,7 @@
     Parrot_shared_gc_block(interp);
 }
 
+
 static void
 gc_ms2_unblock_GC_mark(PARROT_INTERP)
 {
@@ -1201,6 +1243,7 @@
     }
 }
 
+
 static void
 gc_ms2_block_GC_sweep(PARROT_INTERP)
 {
@@ -1209,6 +1252,7 @@
     ++self->gc_sweep_block_level;
 }
 
+
 static void
 gc_ms2_unblock_GC_sweep(PARROT_INTERP)
 {
@@ -1218,6 +1262,7 @@
         --self->gc_sweep_block_level;
 }
 
+
 static unsigned int
 gc_ms2_is_blocked_GC_mark(PARROT_INTERP)
 {
@@ -1226,6 +1271,7 @@
     return self->gc_mark_block_level;
 }
 
+
 static unsigned int
 gc_ms2_is_blocked_GC_sweep(PARROT_INTERP)
 {
@@ -1235,7 +1281,6 @@
 }
 
 
-
 /*
 
 =item C<static void * gc_ms2_allocate_memory_chunk(PARROT_INTERP, size_t size)>
@@ -1272,6 +1317,7 @@
     return ptr;
 }
 
+
 PARROT_MALLOC
 PARROT_CAN_RETURN_NULL
 static void *
@@ -1294,6 +1340,7 @@
     return ptr;
 }
 
+
 PARROT_MALLOC
 PARROT_CAN_RETURN_NULL
 static void *
@@ -1309,6 +1356,7 @@
     return ptr;
 }
 
+
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
@@ -1322,6 +1370,7 @@
     return ptr;
 }
 
+
 static void
 gc_ms2_free_memory_chunk(SHIM_INTERP, ARGFREE(void *data))
 {
@@ -1333,6 +1382,7 @@
         free(data);
 }
 
+
 PARROT_DOES_NOT_RETURN
 static void
 failed_allocation(unsigned int line, unsigned long size)
@@ -1347,7 +1397,7 @@
 
 =item C<static void gc_ms2_pmc_needs_early_collection(PARROT_INTERP, PMC *pmc)>
 
-Mark a PMC as needing timely destruction
+Marks a PMC as needing timely destruction.
 
 =cut
 
@@ -1361,16 +1411,18 @@
     ++self->num_early_gc_PMCs;
 }
 
+
 /*
 
 =item C<static void gc_ms2_maybe_mark_and_sweep(PARROT_INTERP)>
 
-Maybe M&S. Depends on total allocated memory, memory allocated since last alloc
-and phase of the Moon.
+Maybe M&S. Depends on total allocated memory, memory allocated since last
+alloc, and phase of the Moon.
 
 =cut
 
 */
+
 static void
 gc_ms2_maybe_mark_and_sweep(PARROT_INTERP)
 {
@@ -1378,18 +1430,19 @@
 
     MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
 
-    /* Collect every 256M. Hardcode for now. Will be configured via CLI */
+    /* Collect every ~n bytes */
     if (interp->gc_sys->stats.mem_used_last_collect > self->gc_threshold) {
         gc_ms2_mark_and_sweep(interp, 0);
     }
 }
 
+
 /*
 
 =item C<static size_t gc_ms2_count_used_string_memory(PARROT_INTERP, Linked_List
 *list)>
 
-find amount of used string memory
+Finds the amount of used STRING memory.
 
 =cut
 
@@ -1400,17 +1453,16 @@
 {
     ASSERT_ARGS(gc_ms2_count_used_string_memory)
 
-    size_t total_amount = 0;
+    List_Item_Header *tmp          = list->first;
+    size_t            total_amount = 0;
 
-    List_Item_Header *tmp = list->first;
     while (tmp) {
         List_Item_Header *next = tmp->next;
         PObj             *obj  = LLH2Obj_typed(tmp, PObj);
         STRING           *str  = (STRING*)obj;
 
         /* Header size */
-        total_amount += sizeof (List_Item_Header)
-                        + sizeof (STRING*);
+        total_amount += sizeof (List_Item_Header) + sizeof (STRING *);
         total_amount += str->bufused;
 
         tmp = next;
@@ -1419,12 +1471,13 @@
     return total_amount;
 }
 
+
 /*
 
 =item C<static size_t gc_ms2_count_used_pmc_memory(PARROT_INTERP, Linked_List
 *list)>
 
-find amount of used pmc memory
+Finds the amount of used PMC memory.
 
 =cut
 
@@ -1435,16 +1488,15 @@
 {
     ASSERT_ARGS(gc_ms2_count_used_pmc_memory)
 
-    size_t total_amount = 0;
+    List_Item_Header *tmp          = list->first;
+    size_t            total_amount = 0;
 
-    List_Item_Header *tmp = list->first;
     while (tmp) {
         List_Item_Header *next = tmp->next;
         PMC              *obj  = LLH2Obj_typed(tmp, PMC);
 
         /* Header size */
-        total_amount += sizeof (List_Item_Header)
-                        + sizeof (PMC*);
+        total_amount += sizeof (List_Item_Header) + sizeof (PMC *);
         total_amount += obj->vtable->attr_size;
 
         tmp = next;
@@ -1453,6 +1505,7 @@
     return total_amount;
 }
 
+
 /*
 
 =back


More information about the parrot-commits mailing list