source: branches/libc-0.6/src/gcc/boehm-gc/blacklst.c@ 2813

Last change on this file since 2813 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 9.0 KB
Line 
1/*
2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 *
5 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 *
8 * Permission is hereby granted to use or copy this program
9 * for any purpose, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 */
14/* Boehm, August 9, 1995 6:09 pm PDT */
15# include "private/gc_priv.h"
16
17/*
18 * We maintain several hash tables of hblks that have had false hits.
19 * Each contains one bit per hash bucket; If any page in the bucket
20 * has had a false hit, we assume that all of them have.
21 * See the definition of page_hash_table in gc_private.h.
22 * False hits from the stack(s) are much more dangerous than false hits
23 * from elsewhere, since the former can pin a large object that spans the
24 * block, eventhough it does not start on the dangerous block.
25 */
26
27/*
28 * Externally callable routines are:
29
30 * GC_add_to_black_list_normal
31 * GC_add_to_black_list_stack
32 * GC_promote_black_lists
33 * GC_is_black_listed
34 *
35 * All require that the allocator lock is held.
36 */
37
38/* Pointers to individual tables. We replace one table by another by */
39/* switching these pointers. */
40word * GC_old_normal_bl;
41 /* Nonstack false references seen at last full */
42 /* collection. */
43word * GC_incomplete_normal_bl;
44 /* Nonstack false references seen since last */
45 /* full collection. */
46word * GC_old_stack_bl;
47word * GC_incomplete_stack_bl;
48
49word GC_total_stack_black_listed;
50
51word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */
52
53void GC_clear_bl();
54
55# if defined(__STDC__) || defined(__cplusplus)
56 void GC_default_print_heap_obj_proc(ptr_t p)
57# else
58 void GC_default_print_heap_obj_proc(p)
59 ptr_t p;
60# endif
61{
62 ptr_t base = GC_base(p);
63
64 GC_err_printf2("start: 0x%lx, appr. length: %ld", base, GC_size(base));
65}
66
67void (*GC_print_heap_obj) GC_PROTO((ptr_t p)) =
68 GC_default_print_heap_obj_proc;
69
70void GC_print_source_ptr(p)
71ptr_t p;
72{
73 ptr_t base = GC_base(p);
74 if (0 == base) {
75 if (0 == p) {
76 GC_err_printf0("in register");
77 } else {
78 GC_err_printf0("in root set");
79 }
80 } else {
81 GC_err_printf0("in object at ");
82 (*GC_print_heap_obj)(base);
83 }
84}
85
86void GC_bl_init()
87{
88 if (!GC_all_interior_pointers) {
89 GC_old_normal_bl = (word *)
90 GC_scratch_alloc((word)(sizeof (page_hash_table)));
91 GC_incomplete_normal_bl = (word *)GC_scratch_alloc
92 ((word)(sizeof(page_hash_table)));
93 if (GC_old_normal_bl == 0 || GC_incomplete_normal_bl == 0) {
94 GC_err_printf0("Insufficient memory for black list\n");
95 EXIT();
96 }
97 GC_clear_bl(GC_old_normal_bl);
98 GC_clear_bl(GC_incomplete_normal_bl);
99 }
100 GC_old_stack_bl = (word *)GC_scratch_alloc((word)(sizeof(page_hash_table)));
101 GC_incomplete_stack_bl = (word *)GC_scratch_alloc
102 ((word)(sizeof(page_hash_table)));