Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/gc/arena-id.h
ViewVC logotype

Annotation of /sml/trunk/src/runtime/gc/arena-id.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download) (as text)

1 : monnier 2 /* arena-id.h
2 :     *
3 :     * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.
4 :     *
5 :     * Definitions for the arena IDs and for mapping from addresses to arena IDs.
6 :     *
7 :     * An arena ID (aid_t) is an unsigned 16-bit value, with the following layout:
8 :     *
9 :     * bits 0-7: heap block ID (0xFF for unmapped objects)
10 :     * bits 8-11: object class:
11 :     * 0000 = new-space objects
12 :     * 1111 = unmapped objects
13 :     * bits 12-15: generation number (0 for new space, 1-14 for older generations,
14 :     * and 15 for non-heap memory)
15 :     *
16 :     * Heap pages in allocation space have the arena ID 0x0000, and unmapped heap
17 :     * pages have the arena ID 0xffff. The ID format is designed so that a
18 :     * from-space page can be detected by having a generation field less than or
19 :     * equal to the maximum generation being collected.
20 :     */
21 :    
22 :     #ifndef _ARENA_ID_
23 :     #define _ARENA_ID_
24 :    
25 :     #ifndef _ML_BASE_
26 :     #include "ml-base.h"
27 :     #endif
28 :    
29 :     #ifndef _BIBOP_
30 :     #include "bibop.h"
31 :     #endif
32 :    
33 :     /* The indices of the different object arenas. WIth four bits for the
34 :     * object class, we have up to 7 regular objects and up to 7 big-object
35 :     * arenas.
36 :     */
37 :     /* The different classes of objects; each class lives in a different arena */
38 :     #define RECORD_INDX 0
39 :     #define PAIR_INDX 1
40 :     #define STRING_INDX 2
41 :     #define ARRAY_INDX 3
42 :     #define NUM_ARENAS 4
43 :    
44 :     /* the different classes of big-objects, which live in big-object regions */
45 :     #define CODE_INDX 0
46 :     #define NUM_BIGOBJ_KINDS 1
47 :    
48 :     #define NUM_OBJ_KINDS (NUM_ARENAS+NUM_BIGOBJ_KINDS)
49 :    
50 :     /* arena IDs */
51 :     typedef page_id_t aid_t;
52 :    
53 :     /* The number of bits in the arena ID fields. The number of bits should add
54 :     * up to sizeof(aid_t)*8.
55 :     */
56 :     #define HBLK_BITS 8
57 :     #define OBJC_BITS 4
58 :     #define GEN_BITS 4
59 :    
60 :     #define HBLK_new 0
61 :     #define MAX_HBLK 0xff
62 :     #define HBLK_MASK ((1<<HBLK_BITS)-1)
63 :     #define HBLK_bigobj 0 /* non-header bigobj pages */
64 :     #define HBLK_bigobjhdr 1 /* header bigobj pages */
65 :    
66 :     /* The different classes of objects. */
67 :     #define MAKE_OBJC(INDX) (INDX+1)
68 :     #define MAKE_BIGOBJC(INDX) (0x8|((INDX)<<1))
69 :     #define OBJC_new 0x0
70 :     #define OBJC_record MAKE_OBJC(RECORD_INDX)
71 :     #define OBJC_pair MAKE_OBJC(PAIR_INDX)
72 :     #define OBJC_string MAKE_OBJC(STRING_INDX)
73 :     #define OBJC_array MAKE_OBJC(ARRAY_INDX)
74 :     #define OBJC_bigobj MAKE_BIGOBJC(CODE_INDX)
75 :     #define OBJC_MAX 0xf
76 :     #define OBJC_MASK ((1<<OBJC_BITS)-1)
77 :    
78 :     #define OBJC_SHIFT HBLK_BITS
79 :     #define GEN_SHIFT (HBLK_BITS+OBJC_BITS)
80 :    
81 :     #define MAX_NUM_GENS ((1 << GEN_BITS) - 2)
82 :     #define ALLOC_GEN 0 /* the generation # of the */
83 :     /* allocation arena */
84 :    
85 :     /* Macros on arena IDs */
86 :     #define MAKE_AID(GEN,OBJC,BLK) \
87 :     ((aid_t)(((GEN)<<GEN_SHIFT) | ((OBJC)<<OBJC_SHIFT) | (BLK)))
88 :     #define MAKE_MAX_AID(GEN) MAKE_AID((GEN), OBJC_MAX, MAX_HBLK)
89 :     #define EXTRACT_HBLK(AID) ((AID)&HBLK_MASK)
90 :     #define EXTRACT_OBJC(AID) (((AID) >> OBJC_SHIFT)&OBJC_MASK)
91 :     #define EXTRACT_GEN(AID) ((AID) >> GEN_SHIFT)
92 :     #define IS_FROM_SPACE(AID,MAX_AID) \
93 :     ((AID) <= (MAX_AID))
94 :    
95 :     /* the arena IDs for new-space and unmapped heap pages, and for free big-objects */
96 :     #define AID_NEW MAKE_AID(ALLOC_GEN,OBJC_new,HBLK_new)
97 :     #define AID_UNMAPPED PAGEID_unmapped
98 :     #define AID_MAX MAKE_MAX_AID(MAX_NUM_GENS)
99 :    
100 :     #ifdef TOSPACE_ID /* for debugging */
101 :     #define TOSPACE_AID(OBJC,BLK) MAKE_AID(0xf,(OBJC),BLK)
102 :     #define TOSPACE_GEN(AID) EXTRACT_OBJC(AID)
103 :     #define IS_TOSPACE_AID(AID) (((AID) != AID_UNMAPPED) && (EXTRACT_GEN(AID) == 0xf))
104 :     #endif
105 :    
106 :     /* AIds for big-object regions. These are always marked as from-space, since
107 :     * both from-space and two-space objects of different generations can occupy
108 :     * the same big-object region.
109 :     */
110 :     #define AID_BIGOBJ(GEN) MAKE_AID(GEN,OBJC_bigobj,HBLK_bigobj)
111 :     #define AID_BIGOBJ_HDR(GEN) MAKE_AID(GEN,OBJC_bigobj,HBLK_bigobjhdr)
112 :    
113 :     /* return true if the AID is a AID_BIGOBJ_HDR (we assume that it is
114 :     * either an AID_BIGOBJ or an AID_BIGOBJ_HDR id).
115 :     */
116 :     #define BO_IS_HDR(AID) (EXTRACT_HBLK(AID) == HBLK_bigobjhdr)
117 :    
118 :     /* return true, if AID is a big-object AID */
119 :     #define IS_BIGOBJ_AID(ID) (EXTRACT_OBJC(ID) == OBJC_bigobj)
120 :    
121 :     #endif /* !_ARENA_ID_ */
122 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0