~ubuntu-branches/ubuntu/raring/boost-build/raring

« back to all changes in this revision

Viewing changes to jam_src/boehm_gc/obj_map.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-08-06 00:38:31 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080806003831-zr65893244swds0b
Tags: 2.0-m12-2
* debian/rules: Do not install /etc/user-config.jam.
* debian/site-config.jam: New.  Install into /etc instead of empty
  example.  Closes: #493323.

* debian/control: Update homepage.  Update description.  Closes:
  #493510.  Update Standards-Version to 3.8.0; no changes.

* debian/compat: New.  Set compat level to 7.
* debian/rules: Remove DH_COMPAT setting.
* debian/control: Change debhelper build-dep to version >= 7.

* debian/control: Remove docbook-to-man, bison from build-deps.

* debian/rules: Clean up upstream source by removing debian/conffiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
 
3
 * Copyright (c) 1991, 1992 by Xerox Corporation.  All rights reserved.
 
4
 * Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved.
 
5
 *
 
6
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 
7
 * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
 
8
 *
 
9
 * Permission is hereby granted to use or copy this program
 
10
 * for any purpose,  provided the above notices are retained on all copies.
 
11
 * Permission to modify the code and to distribute modified code is granted,
 
12
 * provided the above notices are retained, and a notice that the code was
 
13
 * modified is included with the above copyright notice.
 
14
 */
 
15
  
 
16
/* Routines for maintaining maps describing heap block
 
17
 * layouts for various object sizes.  Allows fast pointer validity checks
 
18
 * and fast location of object start locations on machines (such as SPARC)
 
19
 * with slow division.
 
20
 */
 
21
 
 
22
# include "private/gc_priv.h"
 
23
 
 
24
/* Consider pointers that are offset bytes displaced from the beginning */
 
25
/* of an object to be valid.                                            */
 
26
 
 
27
void GC_register_displacement(size_t offset)
 
28
{
 
29
    DCL_LOCK_STATE;
 
30
    
 
31
    LOCK();
 
32
    GC_register_displacement_inner(offset);
 
33
    UNLOCK();
 
34
}
 
35
 
 
36
void GC_register_displacement_inner(size_t offset) 
 
37
{
 
38
    if (offset >= VALID_OFFSET_SZ) {
 
39
        ABORT("Bad argument to GC_register_displacement");
 
40
    }
 
41
    if (!GC_valid_offsets[offset]) {
 
42
      GC_valid_offsets[offset] = TRUE;
 
43
      GC_modws_valid_offsets[offset % sizeof(word)] = TRUE;
 
44
    }
 
45
}
 
46
 
 
47
#ifdef MARK_BIT_PER_GRANULE
 
48
/* Add a heap block map for objects of size granules to obj_map.        */
 
49
/* Return FALSE on failure.                                             */
 
50
/* A size of 0 granules is used for large objects.                      */
 
51
GC_bool GC_add_map_entry(size_t granules)
 
52
{
 
53
    unsigned displ;
 
54
    short * new_map;
 
55
    
 
56
    if (granules > BYTES_TO_GRANULES(MAXOBJBYTES)) granules = 0;
 
57
    if (GC_obj_map[granules] != 0) {
 
58
        return(TRUE);
 
59
    }
 
60
    new_map = (short *)GC_scratch_alloc(MAP_LEN * sizeof(short));
 
61
    if (new_map == 0) return(FALSE);
 
62
    if (GC_print_stats)
 
63
        GC_printf("Adding block map for size of %u granules (%u bytes)\n",
 
64
                  (unsigned)granules, (unsigned)(GRANULES_TO_BYTES(granules)));
 
65
    if (granules == 0) {
 
66
      for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) {
 
67
        new_map[displ] = 1;  /* Nonzero to get us out of marker fast path. */
 
68
      }
 
69
    } else {
 
70
      for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) {
 
71
        new_map[displ] = (short)(displ % granules);
 
72
      }
 
73
    }
 
74
    GC_obj_map[granules] = new_map;
 
75
    return(TRUE);
 
76
}
 
77
#endif
 
78
 
 
79
static GC_bool offsets_initialized = FALSE;
 
80
 
 
81
void GC_initialize_offsets(void)
 
82
{
 
83
    if (!offsets_initialized) {
 
84
      int i;
 
85
      if (GC_all_interior_pointers) {
 
86
        for (i = 0; i < VALID_OFFSET_SZ; ++i) GC_valid_offsets[i] = TRUE;
 
87
      }
 
88
      offsets_initialized = TRUE;
 
89
    }
 
90
}