pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:87:    * GC_PASS_ZAP_WEAK    * Zap weak references to unmarked objects.    *    * GC_PASS_POSTTOUCH    * Debug.    *    * GC_PASS_FREE    * Free remaining unmarked objects.    *    * GC_PASS_KILL -  * Destruct remaining unmarked live (lfun::destroy()) objects. +  * Destruct remaining unmarked live (lfun::_destruct()) objects.    *    * GC_PASS_DESTRUCT    * Destruct objects to destruct.    *    * And the following simulated passes:    *    * GC_PASS_LOCATE    *    * GC_PASS_DISABLED    */
pike.git/src/gc.c:142:    * to save them by adding external references to them. However, it's    * not possible for live objects to save themselves or other live    * objects; all live objects that didn't have external references at    * the start of the gc pass will be destructed regardless of added    * references.    *    * Things that have only weak external references at the start of the    * gc pass will be freed. That's done before the live object destruct    * pass. Internal weak references are however still intact.    * -  * Note: Keep the doc for lfun::destroy up-to-date with the above. +  * Note: Keep the doc for lfun::_destruct up-to-date with the above.    */      /* #define GC_DEBUG */   /* #define GC_VERBOSE */   /* #define GC_CYCLE_DEBUG */   /* #define GC_STACK_DEBUG */   /* #define GC_INTERVAL_DEBUG */      #if defined(GC_VERBOSE) && !defined(PIKE_DEBUG)   #undef GC_VERBOSE
pike.git/src/gc.c:3497:   #endif   }      size_t do_gc(void *UNUSED(ignored), int explicit_call)   {    ALLOC_COUNT_TYPE start_allocs;    size_t start_num_objs, unreferenced;    cpu_time_t gc_start_time, gc_start_real_time;    ptrdiff_t objs, pre_kill_objs;   #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP) -  unsigned destroy_count; +  unsigned destruct_count;   #endif   #ifdef PIKE_DEBUG    unsigned obj_count;    ONERROR uwp;   #endif       if(Pike_in_gc) return 0;       if (gc_enabled <= 0 && (gc_enabled < 0 || !explicit_call)) {    /* If this happens then the gc has been disabled for a very long
pike.git/src/gc.c:3853:       /* Destruct the live objects in cycles, but first warn about any bad    * cycles. */    pre_kill_objs = num_objects;    if (Pike_interpreter.evaluator_stack && !gc_destruct_everything) {    objs -= num_objects;    warn_bad_cycles();    objs += num_objects;    }   #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP) -  destroy_count = 0; +  destruct_count = 0;   #endif       if (!SAFE_IS_ZERO(&gc_post_cb)) {    safe_apply_svalue(&gc_post_cb, 0, 1);    pop_stack();    }       {    enum object_destruct_reason reason =   #ifdef DO_PIKE_CLEANUP
pike.git/src/gc.c:3929:    push_int(reason);    push_int(o->refs - 1);    safe_apply_svalue(&gc_destruct_cb, 3, 1);    pop_stack();    }       destruct_object (o, reason);    free_object(o);    gc_free_extra_ref(o);   #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP) -  destroy_count++; +  destruct_count++;   #endif    really_free_gc_rec_frame (kill_list);    kill_list = next;    }    }      #ifdef PIKE_DEBUG    if (rec_frames)    Pike_fatal ("Leaked %u rec frames.\n", rec_frames);   #endif       GC_VERBOSE_DO(fprintf(stderr, "| kill: %u objects killed, "    "%"PRINTSIZET"u things really freed\n", -  destroy_count, pre_kill_objs - num_objects)); +  destruct_count, pre_kill_objs - num_objects));       Pike_in_gc=GC_PASS_DESTRUCT;    /* Destruct objects on the destruct queue. */    GC_VERBOSE_DO(obj_count = num_objects);    destruct_objects_to_destruct();    GC_VERBOSE_DO(fprintf(stderr, "| destruct: %d things really freed\n",    obj_count - num_objects));      #ifdef PIKE_DEBUG    if (gc_extra_refs) {
pike.git/src/gc.c:4049:    {    cpu_time_t gc_end_time = get_cpu_time();    if (gc_end_time > gc_start_time)    last_gc_time = gc_end_time - gc_start_time;    else    last_gc_time = (cpu_time_t) -1;    }       /* At this point, unreferenced contains the number of things that    * were without external references during the check and mark -  * passes. In the process of freeing them, destroy functions might +  * passes. In the process of freeing them, _destruct functions might    * have been called which means anything might have happened.    * Therefore we use that figure instead of the difference between    * the number of allocated things to measure the amount of    * garbage. */    last_garbage_ratio = (double) unreferenced / start_num_objs;       objects_alloced = objects_alloced * multiplier +    start_allocs * (1.0 - multiplier);    objects_freed = objects_freed * multiplier +    unreferenced * (1.0 - multiplier);
pike.git/src/gc.c:4168:    {    char timestr[40];    if (last_gc_time != (cpu_time_t) -1)    sprintf (timestr, ", %ld ms",    (long) (last_gc_time / (CPU_TIME_TICKS / 1000)));    else    timestr[0] = 0;   #ifdef DO_PIKE_CLEANUP    if (gc_destruct_everything)    fprintf(stderr, "done (%u %s destructed)%s\n", -  destroy_count, destroy_count == 1 ? "was" : "were", timestr); +  destruct_count, destruct_count == 1 ? "was" : "were", timestr);    else   #endif    fprintf(stderr, "done (%"PRINTSIZET"u of %"PRINTSIZET"u "    "%s unreferenced)%s\n",    unreferenced, start_num_objs,    unreferenced == 1 ? "was" : "were",    timestr);    }    }   
pike.git/src/gc.c:4200:    exit_gc();      #ifdef ALWAYS_GC    ADD_GC_CALLBACK();   #else    if(d_flag > 3) ADD_GC_CALLBACK();   #endif      #ifdef DO_PIKE_CLEANUP    if (gc_destruct_everything) -  return destroy_count; +  return destruct_count;   #endif       if (!SAFE_IS_ZERO(&gc_done_cb)) {    push_int(unreferenced);    safe_apply_svalue(&gc_done_cb, 1, 1);    pop_stack();    }       return unreferenced;   }