initial
[prop.git] / include / AD / gc / gcintern.h
blob3ae85f914a4e35f631691dae223715423fe0eb6d
1 //////////////////////////////////////////////////////////////////////////////
2 // NOTICE:
3 //
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are welcomed to incorporate any part of ADLib and Prop into
9 // your programs.
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
16 // code.
18 // This software is still under development and we welcome(read crave for)
19 // any suggestions and help from the users.
21 // Allen Leung (leunga@cs.nyu.edu)
22 // 1994
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef garbage_collector_internals_h
26 #define garbage_collector_internals_h
28 #include <new.h>
30 //////////////////////////////////////////////////////////////////////////////
31 // Some opaque forward definitions
32 //////////////////////////////////////////////////////////////////////////////
33 class GCObject; // garbage collectable objects
34 class GC; // garbage collectors
35 class BGC; // Barlett's mostly copying garbage collector
37 //////////////////////////////////////////////////////////////////////////////
38 // Object headers definitions.
39 // The object header has the following format:
40 // For copying collectors:
41 // Bit 0 -- the forward bit.
42 // Bit 1-31 -- If this is 1 then bit 1 - 31 is the forwarding address.
43 // Otherwise, bit 1 - 31 is the length of the object in bytes,
44 // *including* the length of the header and any other
45 // alignment needs.
46 // For marksweep collectors:
47 // Bit 0 -- the freelist bit; object in the free list has this
48 // bit set.
49 // Bit 1-31 -- the length of the object with header info.
50 //////////////////////////////////////////////////////////////////////////////
51 typedef unsigned long GCHeader;
53 //////////////////////////////////////////////////////////////////////////////
54 // Macros for manipulating headers.
55 // GC_OBJ_HEADER_ADDR(obj) --- return the address of the header given an object
56 // GC_OBJ_HEADER(obj) --- return the header given an object address
57 // GC_OBJ_OBJECT_ADDR(ptr) --- return the object address given a header address
58 // GC_OBJ_HEADER_LEN(h) --- return the object length given a header
59 // GC_OBJ_IS_FORWARDED(h) --- test if a header is forwarded
60 // GC_OBJ_FORWARD_ADDR(h) --- return the forwarded address of a header
61 // GC_OBJ_SET_FORWARD(obj,ptr) --- set the header to a forwarded address
62 // GC_OBJ_SET_HEADER(obj,len) --- set a normal header with an object length
63 //////////////////////////////////////////////////////////////////////////////
64 #define GC_OBJ_HEADER_ADDR(obj) (((GCHeader*)(obj))-1)
65 #define GC_OBJ_HEADER(obj) (*GC_OBJ_HEADER_ADDR(obj))
66 #define GC_OBJ_OBJECT_ADDR(ptr) ((GCObject*)(((GCHeader*)(ptr))+1))
67 #define GC_OBJ_HEADER_LEN(h) (h)
68 #define GC_OBJ_IS_FORWARDED(h) ((h) & 0x1)
69 #define GC_OBJ_FORWARD_ADDR(h) ((GCObject*)((h) & 0xfffffffe))
70 #define GC_OBJ_SET_FORWARD(obj,ptr) \
71 (GC_OBJ_HEADER(obj) = ((GCHeader)(ptr) | 0x1))
72 #define GC_OBJ_SET_HEADER(obj,len) (GC_OBJ_HEADER(obj) = len)
73 #define GC_OBJ_FREELIST_LEN(h) ((h) & 0xfffffffe)
74 #define GC_OBJ_SET_FREELIST(obj,len) (GC_OBJ_HEADER(obj) = ((len) & 0x1))
75 #define GC_OBJ_IS_ON_FREELIST(h) ((h) & 0x1)
77 #endif