Ejemplo n.º 1
0
/*
 * Perform GC_reclaim_block on the entire heap, after first clearing
 * small object free lists (if we are not just looking for leaks).
 */
GC_INNER void GC_start_reclaim(GC_bool report_if_found)
{
    unsigned kind;

#   if defined(PARALLEL_MARK)
    GC_ASSERT(0 == GC_fl_builder_count);
#   endif
    /* Reset in use counters.  GC_reclaim_block recomputes them. */
    GC_composite_in_use = 0;
    GC_atomic_in_use = 0;
    /* Clear reclaim- and free-lists */
    for (kind = 0; kind < GC_n_kinds; kind++) {
        void **fop;
        void **lim;
        struct hblk ** rlist = GC_obj_kinds[kind].ok_reclaim_list;
        GC_bool should_clobber = (GC_obj_kinds[kind].ok_descriptor != 0);

        if (rlist == 0) continue;       /* This kind not used.  */
        if (!report_if_found) {
            lim = &(GC_obj_kinds[kind].ok_freelist[MAXOBJGRANULES+1]);
            for( fop = GC_obj_kinds[kind].ok_freelist; fop < lim; fop++ ) {
                if (*fop != 0) {
                    if (should_clobber) {
                        GC_clear_fl_links(fop);
                    } else {
                        *fop = 0;
                    }
                }
            }
        } /* otherwise free list objects are marked,    */
        /* and its safe to leave them                 */
        BZERO(rlist, (MAXOBJGRANULES + 1) * sizeof(void *));
    }


    /* Go through all heap blocks (in hblklist) and reclaim unmarked objects */
    /* or enqueue the block for later processing.                            */
    if( g_reclaim_hinted ) {
        GC_apply_to_all_blocks(HINTGC_reclaim_block, (word)report_if_found);
    } else {
        GC_apply_to_all_blocks(GC_reclaim_block, (word)report_if_found);
    }
# ifdef EAGER_SWEEP
    /* This is a very stupid thing to do.  We make it possible anyway,  */
    /* so that you can convince yourself that it really is very stupid. */
    GC_reclaim_all((GC_stop_func)0, FALSE);
# endif
# if defined(PARALLEL_MARK)
    GC_ASSERT(0 == GC_fl_builder_count);
# endif

}
Ejemplo n.º 2
0
/* I hold the allocation lock.	Normally called by collector.		*/
void GC_check_heap_proc(void)
{
#   ifndef SMALL_CONFIG
      /* Ignore gcc no effect warning on the following.		*/
      GC_STATIC_ASSERT((sizeof(oh) & (GRANULE_BYTES - 1)) == 0);
      /* FIXME: Should we check for twice that alignment?	*/
#   endif
    GC_apply_to_all_blocks(GC_check_heap_block, (word)0);
}
Ejemplo n.º 3
0
void GC_print_block_list(void)
{
    struct Print_stats pstats;

    GC_printf("(kind(0=ptrfree,1=normal,2=unc.):size_in_bytes, #_marks_set)\n");
    pstats.number_of_blocks = 0;
    pstats.total_bytes = 0;
    GC_apply_to_all_blocks(GC_print_block_descr, (word)&pstats);
    GC_printf("\nblocks = %lu, bytes = %lu\n",
              (unsigned long)pstats.number_of_blocks,
              (unsigned long)pstats.total_bytes);
}
Ejemplo n.º 4
0
STATIC void GC_check_blocks(void)
{
    word bytes_in_free_blocks = GC_large_free_bytes;

    GC_bytes_in_used_blocks = 0;
    GC_apply_to_all_blocks(GC_add_block, (word)0);
    GC_printf("GC_bytes_in_used_blocks = %lu, bytes_in_free_blocks = %lu ",
              (unsigned long)GC_bytes_in_used_blocks,
              (unsigned long)bytes_in_free_blocks);
    GC_printf("GC_heapsize = %lu\n", (unsigned long)GC_heapsize);
    if (GC_bytes_in_used_blocks + bytes_in_free_blocks != GC_heapsize) {
        GC_printf("LOST SOME BLOCKS!!\n");
    }
}
Ejemplo n.º 5
0
PCR_ERes GC_EnumerateProc(
    PCR_Bool ptrFree,
    PCR_ERes (*proc)(void *p, size_t size, PCR_Any data),
    PCR_Any data
)
{
    enumerate_data ed;

    ed.ed_proc = proc;
    ed.ed_pointerfree = ptrFree;
    ed.ed_fail_code = PCR_ERes_okay;
    ed.ed_client_data = data;
    GC_apply_to_all_blocks(GC_enumerate_block, &ed);
    if (ed.ed_fail_code != PCR_ERes_okay) {
        return(ed.ed_fail_code);
    } else {
        /* Also enumerate objects allocated by my predecessors */
        return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data));
    }
}
Ejemplo n.º 6
0
/* I hold the allocation lock.  Normally called by collector.           */
STATIC void GC_check_heap_proc(void)
{
  GC_STATIC_ASSERT((sizeof(oh) & (GRANULE_BYTES - 1)) == 0);
  /* FIXME: Should we check for twice that alignment?   */
  GC_apply_to_all_blocks(GC_check_heap_block, 0);
}
Ejemplo n.º 7
0
GC_INLINE void GC_apply_to_each_object(per_object_func f)
{
  GC_apply_to_all_blocks(per_object_helper, (word)f);
}