~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to backgraph.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-03-02 13:43:18 UTC
  • mfrom: (1.2.5 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110302134318-82ful0us5ce82qe8
Tags: 1:7.1-7
* Add ppc64 symbol file (Closes: #615469)
* Add sh4 symbol file (Closes: #614744)
* Add armhf symbol file
* Add powerpcspe symbol file
* Handle sparc64 the same as sparc
* Clear non-arch symbol file to support building on not yet captured
  architectures
* add -pthread to fix build with --no-add-needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
  if (0 == back_edge_space) {
87
87
    back_edge_space = (back_edges *)
88
88
                        GET_MEM(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
 
89
    GC_add_to_our_memory((ptr_t)back_edge_space,
 
90
                         MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
89
91
  }
90
92
  if (0 != avail_back_edges) {
91
93
    back_edges * result = avail_back_edges;
125
127
    if (in_progress_size == 0) {
126
128
      in_progress_size = INITIAL_IN_PROGRESS;
127
129
      in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
 
130
      GC_add_to_our_memory((ptr_t)in_progress_space,
 
131
                           in_progress_size * sizeof(ptr_t));
128
132
    } else {
129
133
      ptr_t * new_in_progress_space;
130
134
      in_progress_size *= 2;
131
135
      new_in_progress_space = (ptr_t *)
132
136
                                GET_MEM(in_progress_size * sizeof(ptr_t));
 
137
      GC_add_to_our_memory((ptr_t)new_in_progress_space,
 
138
                           in_progress_size * sizeof(ptr_t));
133
139
      BCOPY(in_progress_space, new_in_progress_space,
134
140
            n_in_progress * sizeof(ptr_t));
135
141
      in_progress_space = new_in_progress_space;
247
253
    if (be -> n_edges == 100) {
248
254
#       if 0
249
255
          if (GC_print_stats) {
250
 
            GC_err_printf0("The following object has in-degree >= 100:\n");
 
256
            GC_err_printf("The following object has in-degree >= 100:\n");
251
257
            GC_print_heap_obj(q);
252
258
          }
253
259
#       endif
254
260
    }
255
261
}
256
262
 
257
 
typedef void (*per_object_func)(ptr_t p, word n_words, word gc_descr);
 
263
typedef void (*per_object_func)(ptr_t p, size_t n_bytes, word gc_descr);
258
264
 
259
265
static void per_object_helper(struct hblk *h, word fn)
260
266
{
261
267
  hdr * hhdr = HDR(h);
262
 
  word sz = hhdr -> hb_sz;
 
268
  size_t sz = hhdr -> hb_sz;
263
269
  word descr = hhdr -> hb_descr;
264
270
  per_object_func f = (per_object_func)fn;
265
271
  int i = 0;
275
281
  GC_apply_to_all_blocks(per_object_helper, (word)f);
276
282
}
277
283
 
278
 
static void reset_back_edge(ptr_t p, word n_words, word gc_descr)
 
284
static void reset_back_edge(ptr_t p, size_t n_bytes, word gc_descr)
279
285
{
280
286
  /* Skip any free list links, or dropped blocks */
281
287
  if (GC_HAS_DEBUG_INFO(p)) {
311
317
  }
312
318
}
313
319
 
314
 
static void add_back_edges(ptr_t p, word n_words, word gc_descr)
 
320
static void add_back_edges(ptr_t p, size_t n_bytes, word gc_descr)
315
321
{
316
322
  word *currentp = (word *)(p + sizeof(oh));
317
323
 
318
324
  /* For now, fix up non-length descriptors conservatively.     */
319
325
    if((gc_descr & GC_DS_TAGS) != GC_DS_LENGTH) {
320
 
      gc_descr = WORDS_TO_BYTES(n_words);
 
326
      gc_descr = n_bytes;
321
327
    }
322
328
  while (currentp < (word *)(p + gc_descr)) {
323
329
    word current = *currentp++;
324
330
    FIXUP_POINTER(current);
325
331
    if (current >= (word)GC_least_plausible_heap_addr && 
326
332
        current <= (word)GC_greatest_plausible_heap_addr) {
327
 
       ptr_t target = GC_base((GC_PTR)current);
 
333
       ptr_t target = GC_base((void *)current);
328
334
       if (0 != target) {
329
335
         add_edge(p, target);
330
336
       }
369
375
    word this_height;
370
376
    if (GC_is_marked(q) && !(FLAG_MANY & (word)GET_OH_BG_PTR(p))) {
371
377
      if (GC_print_stats)
372
 
          GC_printf2("Found bogus pointer from 0x%lx to 0x%lx\n", q, p);
 
378
          GC_log_printf("Found bogus pointer from 0x%lx to 0x%lx\n", q, p);
373
379
        /* Reachable object "points to" unreachable one.                */
374
380
        /* Could be caused by our lax treatment of GC descriptors.      */
375
381
      this_height = 1;
392
398
/* next GC.                                                             */
393
399
/* Set GC_max_height to be the maximum height we encounter, and         */
394
400
/* GC_deepest_obj to be the corresponding object.                       */
395
 
static void update_max_height(ptr_t p, word n_words, word gc_descr)
 
401
static void update_max_height(ptr_t p, size_t n_bytes, word gc_descr)
396
402
{
397
403
  if (GC_is_marked(p) && GC_HAS_DEBUG_INFO(p)) {
398
404
    int i;
444
450
{
445
451
  GC_max_height = 0;
446
452
  GC_apply_to_each_object(update_max_height);
 
453
  if (0 != GC_deepest_obj)
 
454
    GC_set_mark_bit(GC_deepest_obj);  /* Keep it until we can print it. */
447
455
}
448
456
 
449
457
void GC_print_back_graph_stats(void)
450
458
{
451
 
  GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n",
452
 
             (unsigned long) GC_gc_no, GC_max_height);
 
459
  GC_printf("Maximum backwards height of reachable objects at GC %lu is %ld\n",
 
460
            (unsigned long) GC_gc_no, (unsigned long)GC_max_height);
453
461
  if (GC_max_height > GC_max_max_height) {
454
462
    GC_max_max_height = GC_max_height;
455
 
    GC_printf0("The following unreachable object is last in a longest chain "
456
 
               "of unreachable objects:\n");
 
463
    GC_printf("The following unreachable object is last in a longest chain "
 
464
              "of unreachable objects:\n");
457
465
    GC_print_heap_obj(GC_deepest_obj);
458
466
  }
459
467
  if (GC_print_stats) {
460
 
    GC_printf1("Needed max total of %ld back-edge structs\n",
461
 
               GC_n_back_edge_structs);
 
468
    GC_log_printf("Needed max total of %ld back-edge structs\n",
 
469
                  GC_n_back_edge_structs);
462
470
  }
463
471
  GC_apply_to_each_object(reset_back_edge);
464
472
  GC_deepest_obj = 0;