[svn:parrot] r41583 - in trunk: . include/parrot src src/gc src/interp src/string t/codingstd

darbelo at svn.parrot.org darbelo at svn.parrot.org
Wed Sep 30 22:41:03 UTC 2009


Author: darbelo
Date: Wed Sep 30 22:41:01 2009
New Revision: 41583
URL: https://trac.parrot.org/parrot/changeset/41583

Log:
Remove the old and unused 'malloc' gc.

Deleted:
   trunk/src/gc/gc_malloc.c
Modified:
   trunk/MANIFEST
   trunk/include/parrot/pobj.h
   trunk/src/gc/api.c
   trunk/src/gc/gc_private.h
   trunk/src/gc/mark_sweep.c
   trunk/src/interp/inter_misc.c
   trunk/src/list.c
   trunk/src/string/api.c
   trunk/t/codingstd/c_function_docs.t

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/MANIFEST	Wed Sep 30 22:41:01 2009	(r41583)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Sep 29 20:27:37 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 30 22:16:16 2009 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -1272,7 +1272,6 @@
 src/gc/alloc_resources.c                                    []
 src/gc/api.c                                                []
 src/gc/gc_inf.c                                             []
-src/gc/gc_malloc.c                                          []
 src/gc/gc_ms.c                                              []
 src/gc/gc_private.h                                         []
 src/gc/malloc.c                                             []

Modified: trunk/include/parrot/pobj.h
==============================================================================
--- trunk/include/parrot/pobj.h	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/include/parrot/pobj.h	Wed Sep 30 22:41:01 2009	(r41583)
@@ -60,17 +60,11 @@
 /* Given a pointer to the buffer, find the ref_count and the actual start of
    the allocated space. Setting ref_count is clunky because we avoid lvalue
    casts. */
-#ifdef GC_IS_MALLOC       /* see src/gc/res_lea.c */
-#  define Buffer_alloc_offset    (offsetof(Buffer_alloc_unit, buffer))
-#  define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset)
-#  define Buffer_bufrefcount(b)    (((Buffer_alloc_unit *)Buffer_bufallocstart(b))->ref_count)
-#  define Buffer_bufrefcountptr(b) (&Buffer_bufrefcount(b))
-#else                     /* see src/gc/alloc_resources.c */
-#  define Buffer_alloc_offset sizeof (INTVAL)
-#  define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset)
-#  define Buffer_bufrefcount(b)    (*(INTVAL *)Buffer_bufallocstart(b))
-#  define Buffer_bufrefcountptr(b) ((INTVAL *)Buffer_bufallocstart(b))
-#endif
+#define Buffer_alloc_offset sizeof (INTVAL)
+#define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset)
+#define Buffer_bufrefcount(b)    (*(INTVAL *)Buffer_bufallocstart(b))
+#define Buffer_bufrefcountptr(b) ((INTVAL *)Buffer_bufallocstart(b))
+
 
 typedef enum {
     enum_stringrep_unknown = 0,

Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/gc/api.c	Wed Sep 30 22:41:01 2009	(r41583)
@@ -1051,11 +1051,7 @@
      * COW refcount is done, in 2. refcounting
      * in 3rd freeing
      */
-#ifdef GC_IS_MALLOC
-    const INTVAL start = 0;
-#else
     const INTVAL start = 2;
-#endif
 
     header_pools_iterate_callback(interp, POOL_PMC, NULL, sweep_cb_pmc);
     header_pools_iterate_callback(interp, POOL_PMC | POOL_CONST, NULL,
@@ -1135,21 +1131,9 @@
         ARGIN(void *arg))
 {
     ASSERT_ARGS(sweep_cb_buf)
-#ifdef GC_IS_MALLOC
-    const int pass = (int)(INTVAL)arg;
-
-    if (pass == 0)
-        clear_cow(interp, pool, 1);
-    else if (pass == 1)
-        used_cow(interp, pool, 1);
-    else
-#endif
-
-    {
-        UNUSED(arg);
-        Parrot_gc_sweep_pool(interp, pool);
-        free_pool(pool);
-    }
+    UNUSED(arg);
+    Parrot_gc_sweep_pool(interp, pool);
+    free_pool(pool);
 
     return 0;
 }

Deleted: trunk/src/gc/gc_malloc.c
==============================================================================
--- trunk/src/gc/gc_malloc.c	Wed Sep 30 22:41:01 2009	(r41582)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,185 +0,0 @@
-/*
-Copyright (C) 2001-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/gc/gc_malloc.c - a malloc()/free()-based garbage collector.
-
-=head1 DESCRIPTION
-
-Handles garbage collection with malloc()/free().  Note that this doesn't
-currently work; this file just collects all of the #GC_MALLOC functions in one
-convenient place.
-
-=head2 Functions
-
-=over 4
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-
-/* HEADERIZER HFILE: include/parrot/gc_api.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-static void clear_cow(PARROT_INTERP,
-    ARGMOD(Fixed_Size_Pool *pool),
-    int cleanup)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
-static int sweep_cb(PARROT_INTERP,
-    ARGMOD(Fixed_Size_Pool *pool),
-    int flag,
-    ARGMOD(void *arg))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(4)
-        FUNC_MODIFIES(*pool)
-        FUNC_MODIFIES(*arg);
-
-static void used_cow(PARROT_INTERP,
-    ARGMOD(Fixed_Size_Pool *pool),
-    int cleanup)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-/* HEADERIZER END: static */
-
-#ifdef GC_IS_MALLOC
-
-/*
-
-=item C<static int sweep_cb(PARROT_INTERP, Fixed_Size_Pool *pool, int flag, void *arg)>
-
-Sweeps the given pool for the MS collector. This function also ends
-the profiling timer, if profiling is enabled. Returns the total number
-of objects freed.
-
-=cut
-
-*/
-
-static int
-sweep_cb(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int flag,
-    ARGMOD(void *arg))
-{
-    int * const total_free = (int *) arg;
-
-    if (flag & POOL_BUFFER)
-        used_cow(interp, pool, 0);
-
-    Parrot_gc_sweep_pool(interp, pool);
-
-    if (flag & POOL_BUFFER)
-        clear_cow(interp, pool, 0);
-
-    *total_free += pool->num_free_objects;
-
-    return 0;
-}
-
-
-/*
-
-=item C<static void clear_cow(PARROT_INTERP, Fixed_Size_Pool *pool, int cleanup)>
-
-Clears the COW ref count.
-
-=cut
-
-*/
-
-static void
-clear_cow(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int cleanup)
-{
-    const UINTVAL object_size = pool->object_size;
-    Fixed_Size_Arena *cur_arena;
-
-    /* clear refcount for COWable objects. */
-    for (cur_arena = pool->last_Arena;
-            NULL != cur_arena; cur_arena = cur_arena->prev) {
-        UINTVAL i;
-        Buffer *b = cur_arena->start_objects;
-
-        for (i = 0; i < cur_arena->used; i++) {
-            if (!PObj_on_free_list_TEST(b)) {
-                if (cleanup) {
-                    /* clear COWed external FLAG */
-                    PObj_external_CLEAR(b);
-
-                    /* if cleanup (Parrot_destroy) constants are dead too */
-                    PObj_constant_CLEAR(b);
-                    PObj_live_CLEAR(b);
-                }
-
-                if (PObj_COW_TEST(b) && PObj_bufstart(b) &&
-                        !PObj_external_TEST(b)) {
-                    INTVAL * const refcount = PObj_bufrefcountptr(b);
-                    *refcount               = 0;
-                }
-            }
-
-            b = (Buffer *)((char *)b + object_size);
-        }
-    }
-}
-
-
-/*
-
-=item C<static void used_cow(PARROT_INTERP, Fixed_Size_Pool *pool, int cleanup)>
-
-Finds other users of COW's C<bufstart>.
-
-=cut
-
-*/
-
-static void
-used_cow(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool), int cleanup)
-{
-    const UINTVAL object_size = pool->object_size;
-    Fixed_Size_Arena *cur_arena;
-
-    for (cur_arena = pool->last_Arena;
-            NULL != cur_arena; cur_arena = cur_arena->prev) {
-        const Buffer *b = cur_arena->start_objects;
-        UINTVAL i;
-
-        for (i = 0; i < cur_arena->used; i++) {
-            if (!PObj_on_free_list_TEST(b) &&
-                    PObj_COW_TEST(b) &&
-                    PObj_bufstart(b) &&
-                   !PObj_external_TEST(b)) {
-
-                INTVAL * const refcount = PObj_bufrefcountptr(b);
-
-                /* mark users of this bufstart by incrementing refcount */
-                if (PObj_live_TEST(b))
-                    *refcount = 1 << 29;        /* ~infinite usage */
-                else
-                    (*refcount)++;      /* dead usage */
-            }
-
-            b = (Buffer *)((char *)b + object_size);
-        }
-    }
-}
-
-#endif /* GC_IS_MALLOC */
-
-/*
- * Local variables:
- *   c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/gc/gc_private.h	Wed Sep 30 22:41:01 2009	(r41583)
@@ -46,15 +46,9 @@
 
 #define POOL_MAX_BYTES                         65536 * 128
 
-#ifndef GC_IS_MALLOC
-#  define PMC_HEADERS_PER_ALLOC     4096 * 10 / sizeof (PMC)
-#  define BUFFER_HEADERS_PER_ALLOC  4096      / sizeof (Buffer)
-#  define STRING_HEADERS_PER_ALLOC  4096 * 20 / sizeof (STRING)
-#else /* GC_IS_MALLOC */
-#  define PMC_HEADERS_PER_ALLOC    10240 / sizeof (PMC)
-#  define BUFFER_HEADERS_PER_ALLOC 10240 / sizeof (Buffer)
-#  define STRING_HEADERS_PER_ALLOC 10240 / sizeof (STRING)
-#endif /* GC_IS_MALLOC */
+#define PMC_HEADERS_PER_ALLOC     4096 * 10 / sizeof (PMC)
+#define BUFFER_HEADERS_PER_ALLOC  4096      / sizeof (Buffer)
+#define STRING_HEADERS_PER_ALLOC  4096 * 20 / sizeof (STRING)
 
 #define CONSTANT_PMC_HEADERS_PER_ALLOC 4096 / sizeof (PMC)
 #define GET_SIZED_POOL_IDX(x) ((x) / sizeof (void *))

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/gc/mark_sweep.c	Wed Sep 30 22:41:01 2009	(r41583)
@@ -253,8 +253,7 @@
 =item C<void Parrot_gc_sweep_pool(PARROT_INTERP, Fixed_Size_Pool *pool)>
 
 Puts any buffers/PMCs that are marked as "dead" or "black" onto the pool
-free list. If C<GC_IS_MALLOC>, bufstart gets freed too, if possible. Avoids
-buffers that are immune from collection (i.e. constant).
+free list.
 
 =cut
 
@@ -628,11 +627,7 @@
     Fixed_Size_Pool * const pool =
             new_fixed_size_obj_pool(buffer_size, num_headers);
 
-#ifdef GC_IS_MALLOC
-    pool->gc_object = free_buffer_malloc;
-#else
     pool->gc_object = (gc_object_fn_type)free_buffer;
-#endif
 
     pool->mem_pool  = interp->mem_pools->memory_pool;
     (interp->gc_sys->init_pool)(interp, pool);

Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/interp/inter_misc.c	Wed Sep 30 22:41:01 2009	(r41583)
@@ -173,25 +173,6 @@
     return IMCC_compile_file_s(interp, fullname, error);
 }
 
-#ifdef GC_IS_MALLOC
-#  if 0
-struct mallinfo {
-    int arena;                  /* non-mmapped space allocated from system */
-    int ordblks;                /* number of free chunks */
-    int smblks;                 /* number of fastbin blocks */
-    int hblks;                  /* number of mmapped regions */
-    int hblkhd;                 /* space in mmapped regions */
-    int usmblks;                /* maximum total allocated space */
-    int fsmblks;                /* space available in freed fastbin blocks */
-    int uordblks;               /* total allocated space */
-    int fordblks;               /* total free space */
-    int keepcost;               /* top-most, releasable (via malloc_trim)
-                                 * space */
-};
-#  endif
-extern struct mallinfo mallinfo(void);
-#endif /* GC_IS_MALLOC */
-
 /*
 
 =item C<INTVAL interpinfo(PARROT_INTERP, INTVAL what)>
@@ -212,11 +193,6 @@
 
     switch (what) {
         case TOTAL_MEM_ALLOC:
-#ifdef GC_IS_MALLOC
-#  if 0
-            interp->memory_allocated = mallinfo().uordblks;
-#  endif
-#endif
             ret = Parrot_gc_total_memory_allocated(interp);
             break;
         case GC_MARK_RUNS:

Modified: trunk/src/list.c
==============================================================================
--- trunk/src/list.c	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/list.c	Wed Sep 30 22:41:01 2009	(r41583)
@@ -995,10 +995,8 @@
     List_chunk *chunk;
     UINTVAL i;
 
-#ifndef GC_IS_MALLOC
     if (list->collect_runs != Parrot_gc_count_collect_runs(interp))
         rebuild_chunk_list(interp, list);
-#endif
 #ifdef SLOW_AND_BORING
     /* in SLOW_AND_BORING mode, we loop through each chunk, and determine if
        idx is in the chunk using basic bounds checking. If the loop completes

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/src/string/api.c	Wed Sep 30 22:41:01 2009	(r41583)
@@ -230,11 +230,6 @@
         return dest;
     if (dest) { /* && dest != src */
         /* they are different, dest is not an external string */
-#ifdef GC_IS_MALLOC
-        if (!PObj_is_cowed_TESTALL(dest) && Buffer_bufstart(dest)) {
-            mem_sys_free(Buffer_bufallocstart(dest));
-        }
-#endif
         dest = Parrot_str_reuse_COW(interp, src, dest);
     }
     else

Modified: trunk/t/codingstd/c_function_docs.t
==============================================================================
--- trunk/t/codingstd/c_function_docs.t	Wed Sep 30 19:53:17 2009	(r41582)
+++ trunk/t/codingstd/c_function_docs.t	Wed Sep 30 22:41:01 2009	(r41583)
@@ -123,7 +123,6 @@
 examples/compilers/japhc.c
 src/atomic/gcc_x86.c
 src/debug.c
-src/gc/gc_malloc.c
 src/gc/generational_ms.c
 src/gc/res_lea.c
 src/io/io_string.c


More information about the parrot-commits mailing list