develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34298 - in branches/pdd09gc_part1: config/gen/makefiles include/parrot src/gc

From:
Whiteknight
Date:
December 23, 2008 14:36
Subject:
[svn:parrot] r34298 - in branches/pdd09gc_part1: config/gen/makefiles include/parrot src/gc
Message ID:
20081223223630.6F6BCCBA12@x12.develooper.com
Author: Whiteknight
Date: Tue Dec 23 14:36:25 2008
New Revision: 34298

Modified:
   branches/pdd09gc_part1/config/gen/makefiles/root.in
   branches/pdd09gc_part1/include/parrot/dod.h
   branches/pdd09gc_part1/include/parrot/settings.h
   branches/pdd09gc_part1/include/parrot/smallobject.h
   branches/pdd09gc_part1/src/gc/dod.c
   branches/pdd09gc_part1/src/gc/incremental_ms.c
   branches/pdd09gc_part1/src/gc/marksweep.c

Log:
[pdd09gc_part1] fix makefile, make headerizer, add a few macros, and a few small changes to get this bad boy to compile

Modified: branches/pdd09gc_part1/config/gen/makefiles/root.in
==============================================================================
--- branches/pdd09gc_part1/config/gen/makefiles/root.in	(original)
+++ branches/pdd09gc_part1/config/gen/makefiles/root.in	Tue Dec 23 14:36:25 2008
@@ -386,7 +386,7 @@
     $(SRC_DIR)/gc/dod$(O) \
     $(SRC_DIR)/gc/gc_gms$(O) \
     $(SRC_DIR)/gc/gc_ims$(O) \
-    $(SRC_DIR)/gc/incremental_ms$(O)
+    $(SRC_DIR)/gc/incremental_ms$(O) \
     $(SRC_DIR)/gc/marksweep$(O) \
     $(SRC_DIR)/gc/memory$(O) \
     $(SRC_DIR)/gc/register$(O) \

Modified: branches/pdd09gc_part1/include/parrot/dod.h
==============================================================================
--- branches/pdd09gc_part1/include/parrot/dod.h	(original)
+++ branches/pdd09gc_part1/include/parrot/dod.h	Tue Dec 23 14:36:25 2008
@@ -64,9 +64,6 @@
 void Parrot_do_dod_run(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 
-void Parrot_dod_clear_live_bits(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
 void Parrot_dod_free_buffer(SHIM_INTERP,
     ARGMOD(Small_Object_Pool *pool),
     ARGMOD(PObj *b))
@@ -242,6 +239,153 @@
 
 #endif
 
+#if PARROT_GC_IT
+
+/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_EXPORT
+void gc_it_add_free_object(PARROT_INTERP,
+    ARGMOD(struct Small_Object_Pool *pool),
+    ARGMOD(void *to_add))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*pool)
+        FUNC_MODIFIES(*to_add);
+
+PARROT_EXPORT
+void gc_it_alloc_objects(PARROT_INTERP,
+    ARGMOD(struct Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+PARROT_EXPORT
+void * gc_it_get_free_object(PARROT_INTERP,
+    ARGMOD(struct Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_EXPORT
+void gc_it_more_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_EXPORT
+void Parrot_gc_it_deinit(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_gc_it_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_gc_it_pool_init(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_EXPORT
+void Parrot_gc_it_run(PARROT_INTERP, int flags)
+        __attribute__nonnull__(1);
+
+PARROT_INLINE
+void gc_it_add_free_header(SHIM_INTERP,
+    ARGMOD(struct Small_Object_Pool * pool),
+    ARGMOD(Gc_it_hdr * hdr))
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(* pool)
+        FUNC_MODIFIES(* hdr);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_INLINE
+UINTVAL gc_it_get_card_mark(ARGMOD(Gc_it_hdr *hdr))
+        __attribute__nonnull__(1)
+        FUNC_MODIFIES(*hdr);
+
+UINTVAL gc_it_pmc_dead(ARGIN(PMC * p))
+        __attribute__nonnull__(1);
+
+UINTVAL gc_it_ptr_get_aggregate(ARGIN(void * const ptr))
+        __attribute__nonnull__(1);
+
+void gc_it_ptr_set_aggregate(ARGMOD(void *ptr), unsigned char flag)
+        __attribute__nonnull__(1)
+        FUNC_MODIFIES(*ptr);
+
+PARROT_INLINE
+void gc_it_set_card_mark(ARGMOD(Gc_it_hdr *hdr), UINTVAL flag)
+        __attribute__nonnull__(1)
+        FUNC_MODIFIES(*hdr);
+
+void gc_it_trace_normal(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/incremental_ms.c */
+
+    /* The aggregate is obviously being used somewhere, so make sure it's
+       marked. pobject_lives will short circuit if it's already been marked.
+       mark the new item too. */
+#  define GC_WRITE_BARRIER(interp, agg, old, _new) do { \
+    if ((agg)) \
+        pobject_lives((interp), (PObj*)(agg)); \
+    if ((_new)) \
+        pobject_lives((interp), (PObj*)(_new)); \
+} while (0)
+    /* Mark the aggregate, the new object and the new_key, they are all
+       apparently being used and I want to make sure they don't get lost */
+#  define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do {\
+    if ((agg)) \
+        pobject_lives((interp), (PObj*)(agg)); \
+    if ((_new)) \
+        pobject_lives((interp), (PObj*)(_new)); \
+    if ((new_key)) \
+        pobject_lives((interp), (PObj*)(new_key)); \
+} while (0)
+#endif
+
+/* Macros for doing common things with the GC_IT */
+
+#define GC_IT_MARK_NODE_GREY(gc_data, hdr) do { \
+    (hdr)->next = (gc_data)->queue; \
+    (gc_data)->queue = (hdr); \
+} while (0)
+
+#define GC_IT_ADD_TO_QUEUE(gc_data, hdr) do {\
+    (hdr)->next = (gc_data)->queue; \
+    (gc_data)->queue = (hdr); \
+} while (0)
+
+#define GC_IT_ADD_TO_ROOT_QUEUE(gc_data, hdr) do {\
+    (hdr)->next = (gc_data)->root_queue; \
+    (gc_data)->root_queue = (hdr); \
+} while (0)
+
+#define GC_IT_ADD_TO_FREE_LIST(pool, hdr) do { \
+    (hdr)->next       = (Gc_it_hdr *)((pool)->free_list); \
+    (pool)->free_list = (void *)(hdr); \
+} while (0)
+
+#define GC_IT_POP_HDR_FROM_LIST(list, hdr, type) do {\
+    (hdr)       = (Gc_it_hdr *)(list); \
+    (list)      = (type)((hdr)->next); \
+    (hdr)->next = NULL; \
+} while (0)
+
+#define GC_IT_HDR_FROM_INDEX(p, a, i) \
+    (Gc_it_hdr*)(((char*)((a)->start_objects))+((p)->object_size*(i)))
+
+#define GC_IT_HDR_HAS_PARENT_POOL(hdr, pool) \
+    ((hdr)->parent_arena->parent_pool == (pool))
+
+
 #endif /* PARROT_DOD_H_GUARD */
 
 /*

Modified: branches/pdd09gc_part1/include/parrot/settings.h
==============================================================================
--- branches/pdd09gc_part1/include/parrot/settings.h	(original)
+++ branches/pdd09gc_part1/include/parrot/settings.h	Tue Dec 23 14:36:25 2008
@@ -44,7 +44,7 @@
  * Please note that only '0' is tested.
  */
 
-#define PARROT_GC_SUBSYSTEM 0
+#define PARROT_GC_SUBSYSTEM 3
 
 #if PARROT_GC_SUBSYSTEM == 0
 #  define PARROT_GC_MS      1

Modified: branches/pdd09gc_part1/include/parrot/smallobject.h
==============================================================================
--- branches/pdd09gc_part1/include/parrot/smallobject.h	(original)
+++ branches/pdd09gc_part1/include/parrot/smallobject.h	Tue Dec 23 14:36:25 2008
@@ -36,6 +36,100 @@
 typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
 typedef void (*dod_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *);
 
+#if PARROT_GC_IT /* Incremental Tricolor Garbage Collector, PDD09 */
+
+/* Switches and modes */
+
+#  define GC_IT_DEBUG             0
+
+#  define GC_IT_INCREMENT_MODE    0
+#  define GC_IT_BATCH_MODE        1
+#  define GC_IT_SERIAL_MODE       1
+#  define GC_IT_PARALLEL_MODE     0
+
+#  ifdef GC_IT_PARALLEL_MODE
+#    define GC_IT_THREAD_MAX 4
+#  endif
+
+/* minimum number of items to scan in a single increment. If we haven't reached
+   this minimum, go back and do another increment. */
+#  define GC_IT_ITEMS_MARKED_MIN  20
+
+/* behavior macros to determine where the incremental mode breaks. Each
+   increment runs from the current state until the next "break", or until
+   the end if there are no more breaks. Some states might require several
+   increments before completion and moving to the next state. */
+#  define GC_IT_BREAK_AFTER_0
+#  define GC_IT_BREAK_AFTER_1
+#  define GC_IT_BREAK_AFTER_2
+#  define GC_IT_BREAK_AFTER_3
+#  define GC_IT_BREAK_AFTER_4
+#  define GC_IT_BREAK_AFTER_5
+#  define GC_IT_BREAK_AFTER_6
+
+/* Macros that are useful outside src/gc/gc_it.c */
+
+#  define GC_IT_MAX_IN_ARENA 65535
+
+/*
+ * GC_IT Header, a linked list.
+ * Contains a link to the pool/arena (don't know which) that contains this item
+ * Contains a link to the next header, to form linked lists.
+ * Contains the number of the card and the flag that represents this item in
+ * the arena.
+ */
+
+typedef struct Gc_it_hdr {
+    struct Gc_it_hdr           *next;
+    struct {
+        unsigned short flag;
+        unsigned short agg;
+    }                           data;
+} Gc_it_hdr;
+
+#  define GC_IT_CARD_WHITE  0x00     /* Item is dead */
+#  define GC_IT_CARD_UNUSED 0x01
+#  define GC_IT_CARD_BLACK  0x03     /* Item is completely alive */
+#  define GC_IT_CARD_FREE   0x02     /* items which are newly created and should
+                                       not be scanned until the next mark */
+
+#  define PObj_to_IT_HDR(o) (((Gc_it_hdr*)(o))-1)
+#  define IT_HDR_to_PObj(p) ((PObj*)(((Gc_it_hdr*)(p))+1))
+#  define cPObj_to_IT_HDR(o) (((const Gc_it_hdr*)(o))-1)
+
+/*
+ * GC States
+ * Determines which phase of the run is currently being performed.
+ */
+
+typedef enum Gc_it_state {
+    GC_IT_READY = 0,
+    GC_IT_START_MARK,    /* starting a mark, initialize everything */
+    GC_IT_MARK_ROOTS,    /* finding root objects */
+    GC_IT_RESUME_MARK,   /* iterating over queue items, tree-at-a-time */
+    GC_IT_END_MARK,      /* The mark is over, do cleanup, if any */
+    GC_IT_SWEEP_PMCS,    /* sweep pmc pools */
+    GC_IT_SWEEP_BUFFERS, /* sweep through all buffers, after everything else */
+    GC_IT_FINAL_CLEANUP  /* do any necessary cleanup after the GC run is over */
+} Gc_it_state;
+
+/* A private datastructure for the GC. All the global data that we need to
+   operate will be stored here. */
+
+typedef struct Gc_it_data {
+    UINTVAL item_count;       /* number of items scanned in current run */
+    UINTVAL total_count;      /* number of items scanned since beginning of mark phase */
+    UINTVAL num_generations;  /* number of generations */
+    Gc_it_state state;        /* status of the current run */
+    UINTVAL num_threads;      /* number of currently active threads */
+    Gc_it_hdr *root_queue;    /* queue for temporary storage of root items */
+    Gc_it_hdr *queue;         /* list of grey items, to mark */
+    Gc_it_hdr *marked;        /* List of items already marked this phase. */
+} Gc_it_data;
+
+#endif /* PARROT_GC_IT */
+
+
 #if PARROT_GC_GMS
 /*
  * all objects have this header in front of the actual
@@ -140,6 +234,10 @@
 #  define GC_HEADER_SIZE (sizeof (Gc_gms_hdr))
 #  define PObj_to_ARENA(o) PObj_to_GMSH(o)
 #  define ARENA_to_PObj(p) GMSH_to_PObj((Gc_gms_hdr*)(p))
+#elif PARROT_GC_IT
+#  define GC_HEADER_SIZE (sizeof (Gc_it_hdr))
+#  define PObj_to_ARENA(o) PObj_to_IT_HDR(o)
+#  define ARENA_to_PObj(p) IT_HDR_to_PObj(p)
 #else
 #  define GC_HEADER_SIZE 0
 #  define PObj_to_ARENA(o) (o)
@@ -205,6 +303,9 @@
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*arena);
 
+void Parrot_dod_clear_live_bits(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
 void Parrot_dod_ms_run(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 

Modified: branches/pdd09gc_part1/src/gc/dod.c
==============================================================================
--- branches/pdd09gc_part1/src/gc/dod.c	(original)
+++ branches/pdd09gc_part1/src/gc/dod.c	Tue Dec 23 14:36:25 2008
@@ -35,7 +35,6 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-
 PARROT_CONST_FUNCTION
 static size_t find_common_mask(PARROT_INTERP, size_t val1, size_t val2)
         __attribute__nonnull__(1);

Modified: branches/pdd09gc_part1/src/gc/incremental_ms.c
==============================================================================
--- branches/pdd09gc_part1/src/gc/incremental_ms.c	(original)
+++ branches/pdd09gc_part1/src/gc/incremental_ms.c	Tue Dec 23 14:36:25 2008
@@ -1,10 +1,10 @@
 /*
 Copyright (C) 2001-2008, The Perl Foundation.
-$Id: gc_it.c 34092 2008-12-19 01:35:50Z Whiteknight $
+$Id: incremental_ms.c 34092 2008-12-19 01:35:50Z Whiteknight $
 
 =head1 NAME
 
-src/gc/gc_it.c - Incremental Tricolor Garbage Collector
+src/gc/incremental_ms.c - Incremental Tricolor Garbage Collector
 
 =head1 DESCRIPTION
 
@@ -41,10 +41,6 @@
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*new_arena);
 
-PARROT_INLINE
-static void gc_it_enqueue_all_roots(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
 static void gc_it_enqueue_next_root(PARROT_INTERP)
         __attribute__nonnull__(1);
 
@@ -700,7 +696,6 @@
     if (PObj_is_PMC_TEST(obj)) {
         if (pmc->pmc_ext) {
             const PMC * next_for_gc = PMC_next_for_GC(pmc);
-            object_lives(interp, (PObj *)(pmc->pmc_ext));
             if (PMC_metadata(pmc))
                 pobject_lives(interp, (PObj *)PMC_metadata(pmc));
             if (next_for_gc != pmc && next_for_gc != NULL)
@@ -1250,7 +1245,7 @@
 
 /*
 
-=item C<gc_it_pmc_dead>
+=item C<UINTVAL gc_it_pmc_dead>
 
 Determines whether a given PMC has been prematurely swept.
 
@@ -1270,8 +1265,6 @@
 
 #  endif
 
-#endif  /* PARROT_GC_IT */
-
 /*
 
 =back

Modified: branches/pdd09gc_part1/src/gc/marksweep.c
==============================================================================
--- branches/pdd09gc_part1/src/gc/marksweep.c	(original)
+++ branches/pdd09gc_part1/src/gc/marksweep.c	Tue Dec 23 14:36:25 2008
@@ -10,7 +10,6 @@
 static void clear_live_bits(ARGIN(const Small_Object_Pool *pool))
         __attribute__nonnull__(1);
 
-
 static void gc_ms_add_free_object(SHIM_INTERP,
     ARGMOD(Small_Object_Pool *pool),
     ARGIN(void *to_add))



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About