~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to erts/emulator/beam/ggc.h

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __GGC_H__
 
2
#define __GGC_H__
 
3
 
 
4
/*
 
5
 * GC macros, shared between ggc.c and hipe_${ARCH}_stack.c.
 
6
 */
 
7
 
 
8
#ifdef DEBUG
 
9
#define HARDDEBUG  1
 
10
/* See erl_debug.h for information about verbose levels */
 
11
/* GC_HEAP_TRACE is deprecated! Use different verbose levels instead */
 
12
/* GC_SWITCH_TRACE is deprecated! It was unused... */
 
13
/* OLD_HEAP_CREATION_TRACE is deprecated! Use different verbose levels instead */
 
14
#endif
 
15
 
 
16
#define MY_IS_MOVED(x)  (!is_header((x)))
 
17
 
 
18
#define MOVE_CONS(PTR,CAR,HTOP,ORIG)                                    \
 
19
do {                                                                    \
 
20
    Eterm gval;                                                         \
 
21
                                                                        \
 
22
    HTOP[0] = CAR;              /* copy car */                          \
 
23
    HTOP[1] = PTR[1];           /* copy cdr */                          \
 
24
    gval = make_list(HTOP);     /* new location */                      \
 
25
    *ORIG = gval;               /* redirect original reference */       \
 
26
    PTR[0] = THE_NON_VALUE;     /* store forwarding indicator */        \
 
27
    PTR[1] = gval;              /* store forwarding address */          \
 
28
    HTOP += 2;                  /* update tospace htop */               \
 
29
} while(0)
 
30
 
 
31
#define MOVE_BOXED(PTR,HDR,HTOP,ORIG)                                   \
 
32
do {                                                                    \
 
33
    Eterm gval;                                                         \
 
34
    Sint nelts;                                                         \
 
35
                                                                        \
 
36
    ASSERT(is_header(HDR));                                             \
 
37
    gval = make_boxed(HTOP);                                            \
 
38
    *ORIG = gval;                                                       \
 
39
    *HTOP++ = HDR;                                                      \
 
40
    *PTR++ = gval;                                                      \
 
41
    nelts = header_arity(HDR);                                          \
 
42
    switch ((HDR) & _HEADER_SUBTAG_MASK) {                              \
 
43
    case SUB_BINARY_SUBTAG: nelts++; break;                             \
 
44
    case FUN_SUBTAG: nelts+=((ErlFunThing*)(PTR-1))->num_free+1; break; \
 
45
    }                                                                   \
 
46
    while (nelts--)                                                     \
 
47
        *HTOP++ = *PTR++;                                               \
 
48
} while(0)
 
49
 
 
50
#define ptr_within(ptr, low, high) ((ptr) < (high) && (ptr) >= (low))
 
51
 
 
52
/* efficient range check */
 
53
#define in_area(ptr,start,nbytes) ((unsigned long)((char*)(ptr) - (char*)(start)) < (nbytes))
 
54
 
 
55
#ifdef HARDDEBUG
 
56
extern int within(Eterm*, Process*);
 
57
#else
 
58
# define within(x,y) 1
 
59
#endif /* HARDDEBUG */
 
60
 
 
61
/*
 
62
 * This structure describes the rootset for the GC.
 
63
 */
 
64
typedef struct {
 
65
    Eterm* v[11];               /* Pointers to vectors with terms to GC
 
66
                                 * (e.g. the stack).
 
67
                                 */
 
68
    Uint sz[11];                /* Size of each vector. */
 
69
    Eterm* v_msg;               /* Pointer to messages to GC. */
 
70
    Eterm def_msg[32];          /* Default storage for messages (to avoid malloc). */
 
71
#ifdef HYBRID
 
72
    Uint n;
 
73
#if defined(HIPE)
 
74
    Process *p;                 /* For scanning the nstack. */
 
75
#endif
 
76
#endif
 
77
} Rootset;
 
78
 
 
79
 
 
80
#ifdef HYBRID
 
81
extern char ma_gc_flags;
 
82
 
 
83
/* Tell the GC to look at all processes. This flag i s set in the
 
84
 * beginning of a major collection, and cleared at the end of minor
 
85
 * collections. This makes the GC look at all processes in the major
 
86
 * collection and the following minor, which is needed since there is
 
87
 * no old generation after a major collection.
 
88
 */
 
89
#define GC_INCLUDE_ALL  0x01
 
90
 
 
91
/* To let functions shared by local and global GC know this is a global GC */
 
92
#define GC_GLOBAL       0x02
 
93
 
 
94
/* In IncNMGC, to indicate that a GC-cycle is in progress */
 
95
#define GC_CYCLE        0x04
 
96
 
 
97
/* In IncNMGC, to indicate that the next GC cycle will be a major one */
 
98
#define GC_NEED_MAJOR   0x08
 
99
 
 
100
/* In IncNMGC, to indicate that the current GC cycle is a major one */
 
101
#define GC_MAJOR        0x10
 
102
 
 
103
/* In IncNMGC, to indicate that the last call to the collector
 
104
 * initiated a new collection cycle.
 
105
 * NOTE!!
 
106
 * This flag is only for communication with copy_stuct_lazy. copy_stuct_lazy
 
107
 * will clear this flag after a copy is done.
 
108
 */
 
109
#define GC_CYCLE_START  0x20
 
110
#endif
 
111
 
 
112
 
 
113
/* These functions are used by nmgc too. */
 
114
int setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset);
 
115
Uint collect_roots(Process* current, Eterm *objv, int nobj, Rootset rootset[]);
 
116
void restore_rootset(Process *p, Rootset *rootset);
 
117
#ifdef INCREMENTAL
 
118
void restore_one_rootset(Process *p, Rootset *rootset);
 
119
#endif
 
120
 
 
121
#endif /* __GGC_H__ */