2 * Generational Conservative Garbage Collector for SBCL x86
4 * inline functions that gc-common.c needs sight of
9 * This software is part of the SBCL system. See the README file for
12 * This software is derived from the CMU CL system, which was
13 * written at Carnegie Mellon University and released into the
14 * public domain. The software is in the public domain and is
15 * provided with absolutely no warranty. See the COPYING and CREDITS
16 * files for more information.
19 #ifndef _GENCGC_INTERNAL_H_
20 #define _GENCGC_INTERNAL_H_
22 void gc_free_heap(void);
23 inline int find_page_index(void *);
24 inline void *page_address(int);
25 int gencgc_handle_wp_violation(void *);
26 lispobj *search_dynamic_space(lispobj *);
31 /* This is set when the page is write-protected. This should
32 * always reflect the actual write_protect status of a page.
33 * (If the page is written into, we catch the exception, make
34 * the page writable, and clear this flag.) */
36 /* This flag is set when the above write_protected flag is
37 * cleared by the SIGBUS handler (or SIGSEGV handler, for some
38 * OSes). This is useful for re-scavenging pages that are
39 * written during a GC. */
40 write_protected_cleared :1,
41 /* the region the page is allocated to: 0 for a free page; 1
42 * for boxed objects; 2 for unboxed objects. If the page is
43 * free the following slots are invalid (well the bytes_used
46 /* If this page should not be moved during a GC then this flag
47 * is set. It's only valid during a GC for allocated pages. */
49 /* If the page is part of a large object then this flag is
50 * set. No other objects should be allocated to these pages.
51 * This is only valid when the page is allocated. */
54 /* the generation that this page belongs to. This should be valid
55 * for all pages that may have objects allocated, even current
56 * allocation region pages - this allows the space of an object to
57 * be easily determined. */
60 /* the number of bytes of this page that are used. This may be less
61 * than the actual bytes used for pages within the current
62 * allocation regions. It should be 0 for all unallocated pages (not
63 * hard to achieve). */
66 /* It is important to know the offset to the first object in the
67 * page. Currently it's only important to know if an object starts
68 * at the beginning of the page in which case the offset would be 0. */
69 int first_object_offset;
72 /* values for the page.allocated field */
75 /* the number of pages needed for the dynamic space - rounding up */
76 #define NUM_PAGES ((DYNAMIC_SPACE_SIZE+4095)/4096)
77 extern struct page page_table[NUM_PAGES];
79 /* Abstract out the data for an allocation region allowing a single
80 * routine to be used for allocation and closing. */
83 /* These two are needed for quick allocation. */
85 void *end_addr; /* pointer to the byte after the last usable byte */
87 /* These are needed when closing the region. */
93 extern struct alloc_region boxed_region;
94 extern struct alloc_region unboxed_region;
95 extern int from_space, new_space;
96 extern struct weak_pointer *weak_pointers;
98 extern void *current_region_free_pointer;
99 extern void *current_region_end_addr;
102 void gencgc_pickup_dynamic(void);
104 void sniff_code_object(struct code *code, unsigned displacement);
105 void gencgc_apply_code_fixups(struct code *old_code, struct code *new_code);
107 int update_x86_dynamic_space_free_pointer(void);
108 void gc_alloc_update_page_tables(int unboxed,
109 struct alloc_region *alloc_region);
114 space_matches_p(lispobj obj, int space)
116 int page_index=(void*)obj - (void *)DYNAMIC_SPACE_START;
117 return ((page_index >= 0)
118 && ((page_index = ((unsigned int)page_index)/4096) < NUM_PAGES)
119 && (page_table[page_index].gen == space));
122 static inline boolean
123 from_space_p(lispobj obj)
125 return space_matches_p(obj,from_space);
128 static inline boolean
129 new_space_p(lispobj obj)
131 return space_matches_p(obj,new_space);