/[dotgnu-pnet]/pnet/libgc/backgraph.c
ViewVC logotype

Diff of /pnet/libgc/backgraph.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by rweather, Thu Feb 6 01:35:45 2003 UTC revision 1.3 by ktreichel, Sat Jul 23 12:52:58 2005 UTC
# Line 85  static back_edges * new_back_edges(void) Line 85  static back_edges * new_back_edges(void)
85  {  {
86    if (0 == back_edge_space) {    if (0 == back_edge_space) {
87      back_edge_space = (back_edges *)      back_edge_space = (back_edges *)
88                          sbrk(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));                          GET_MEM(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
89    }    }
90    if (0 != avail_back_edges) {    if (0 != avail_back_edges) {
91      back_edges * result = avail_back_edges;      back_edges * result = avail_back_edges;
# Line 113  static void deallocate_back_edges(back_e Line 113  static void deallocate_back_edges(back_e
113  /* Table of objects that are currently on the depth-first search        */  /* Table of objects that are currently on the depth-first search        */
114  /* stack.  Only objects with in-degree one are in this table.           */  /* stack.  Only objects with in-degree one are in this table.           */
115  /* Other objects are identified using HEIGHT_IN_PROGRESS.               */  /* Other objects are identified using HEIGHT_IN_PROGRESS.               */
116  /* This data structure NEEDS IMPROVEMENT.                               */  /* FIXME: This data structure NEEDS IMPROVEMENT.                        */
117  #define MAX_IN_PROGRESS 10000  #define INITIAL_IN_PROGRESS 10000
118  static ptr_t * in_progress_space = 0;  static ptr_t * in_progress_space = 0;
119  static int n_in_progress = 0;  static size_t in_progress_size = 0;
120    static size_t n_in_progress = 0;
121    
122  static void push_in_progress(ptr_t p)  static void push_in_progress(ptr_t p)
123  {  {
124      if (n_in_progress >= in_progress_size)
125        if (in_progress_size == 0) {
126          in_progress_size = INITIAL_IN_PROGRESS;
127          in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
128        } else {
129          ptr_t * new_in_progress_space;
130          in_progress_size *= 2;
131          new_in_progress_space = (ptr_t *)
132                                    GET_MEM(in_progress_size * sizeof(ptr_t));
133          BCOPY(in_progress_space, new_in_progress_space,
134                n_in_progress * sizeof(ptr_t));
135          in_progress_space = new_in_progress_space;
136          /* FIXME: This just drops the old space.  */
137        }
138    if (in_progress_space == 0)    if (in_progress_space == 0)
139        in_progress_space = sbrk(MAX_IN_PROGRESS * sizeof(ptr_t));        ABORT("MAKE_BACK_GRAPH: Out of in-progress space: "
140    if (n_in_progress == MAX_IN_PROGRESS)              "Huge linear data structure?");
       ABORT("Exceeded MAX_IN_PROGRESS");  
141    in_progress_space[n_in_progress++] = p;    in_progress_space[n_in_progress++] = p;
142  }  }
143    
# Line 318  static void add_back_edges(ptr_t p, word Line 332  static void add_back_edges(ptr_t p, word
332    }    }
333  }  }
334    
335  /* Rebuild the reprentation of the backward reachability graph. */  /* Rebuild the representation of the backward reachability graph.       */
336  /* Does not examine mark bits.  Can be called before GC.        */  /* Does not examine mark bits.  Can be called before GC.                */
337  void GC_build_back_graph(void)  void GC_build_back_graph(void)
338  {  {
339    GC_apply_to_each_object(add_back_edges);    GC_apply_to_each_object(add_back_edges);
# Line 424  static void update_max_height(ptr_t p, w Line 438  static void update_max_height(ptr_t p, w
438    }    }
439  }  }
440    
441    word GC_max_max_height = 0;
442    
443  void GC_traverse_back_graph(void)  void GC_traverse_back_graph(void)
444  {  {
   static word max_max_height = 0;  
445    GC_max_height = 0;    GC_max_height = 0;
446    GC_apply_to_each_object(update_max_height);    GC_apply_to_each_object(update_max_height);
447    }
448    
449    void GC_print_back_graph_stats(void)
450    {
451    GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n",    GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n",
452               (unsigned long) GC_gc_no, GC_max_height);               (unsigned long) GC_gc_no, GC_max_height);
453    if (GC_max_height > max_max_height) {    if (GC_max_height > GC_max_max_height) {
454      max_max_height = GC_max_height;      GC_max_max_height = GC_max_height;
455      GC_printf0("The following unreachable object is last in a longest chain "      GC_printf0("The following unreachable object is last in a longest chain "
456                 "of unreachable objects:\n");                 "of unreachable objects:\n");
457      GC_print_heap_obj(GC_deepest_obj);      GC_print_heap_obj(GC_deepest_obj);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26