Revision 29711

Date:
2008/07/24 00:18:39
Author:
Whiteknight
Revision Log:
[gsoc_pdd09] update header allocator to flag items differently in different GC states
Files:

Legend:

 
Added
 
Removed
 
Modified
  • branches/gsoc_pdd09/src/gc/gc_it.c

     
    1003 1003 void *
    1004 1004 gc_it_get_free_object(PARROT_INTERP, ARGMOD(struct Small_Object_Pool *pool))
    1005 1005 {
    1006 Gc_it_hdr *hdr;
    1006 Gc_it_hdr * hdr;
    1007 const Gc_it_data * const gc_priv_data = (Gc_it_data *)interp->arena_base->gc_private;
    1008 const Gc_it_state state = gc_priv_data->state;
    1007 1009
    1008 /* This is a bad hack. If we have an obviously absurd pointer on the
    1009 free list (which, apparently, is not uncommon right now), we just
    1010 set the free list to null. This has the potential to hemorrage
    1011 items that were on the free list past the bad pointer (if any). I
    1012 ultimately want to find the source of the error, and then remove
    1013 this hack. */
    1014
    1015 1010 /* If there are no objects, allocate a new arena */
    1016 1011 if (!pool->free_list)
    1017 1012 (pool->more_objects)(interp, pool);
    1018 1013 PARROT_ASSERT(pool->free_list);
    1014
    1019 1015 /* pull the first header off the free list */
    1020 1016 hdr = (Gc_it_hdr *)pool->free_list;
    1021 1017 pool->free_list = (void *)hdr->next;
     
    1026 1022 PARROT_ASSERT(hdr->parent_arena);
    1027 1023 PARROT_ASSERT(hdr->parent_arena->parent_pool == pool);
    1028 1024
    1029 /* mark the item as black, so it doesn't get collected prematurely. */
    1030 gc_it_set_card_mark(hdr, GC_IT_CARD_BLACK);
    1025 /* Depending where we are in the GC run, we can set the mark accordingly */
    1026 switch(state) {
    1027 case GC_IT_READY:
    1028 case GC_IT_START_MARK:
    1029 case GC_IT_MARK_ROOTS:
    1030 case GC_IT_FINAL_CLEANUP:
    1031 gc_it_set_card_mark(hdr, GC_IT_CARD_WHITE);
    1032 break;
    1033 case GC_IT_RESUME_MARK:
    1034 gc_it_set_card_mark(hdr, GC_IT_CARD_BLACK);
    1035 break;
    1036 case GC_IT_END_MARK:
    1037 case GC_IT_SWEEP_PMCS:
    1038 case GC_IT_SWEEP_BUFFERS:
    1039 gc_it_set_card_mark(hdr, GC_IT_CARD_BLACK);
    1040 break;
    1041 default:
    1042 /* we shouldn't ever be here, but the compiler spits out a
    1043 warning if we don't have a default, so I jam it in. */
    1044 break;
    1045 }
    1031 1046
    1032 1047 /* clear the aggregate flag, in case it hasn't been done yet */
    1033 1048 hdr->data.agg = 0;