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 #include "gencgc-alloc-region.h"
23 #include "genesis/code.h"
25 void gc_free_heap(void);
26 inline int find_page_index(void *);
27 inline void *page_address(int);
28 int gencgc_handle_wp_violation(void *);
29 lispobj *search_dynamic_space(lispobj *);
34 /* This is set when the page is write-protected. This should
35 * always reflect the actual write_protect status of a page.
36 * (If the page is written into, we catch the exception, make
37 * the page writable, and clear this flag.) */
39 /* This flag is set when the above write_protected flag is
40 * cleared by the SIGBUS handler (or SIGSEGV handler, for some
41 * OSes). This is useful for re-scavenging pages that are
42 * written during a GC. */
43 write_protected_cleared :1,
44 /* the region the page is allocated to: 0 for a free page; 1
45 * for boxed objects; 2 for unboxed objects. If the page is
46 * free the following slots are invalid (well the bytes_used
49 /* If this page should not be moved during a GC then this flag
50 * is set. It's only valid during a GC for allocated pages. */
52 /* If the page is part of a large object then this flag is
53 * set. No other objects should be allocated to these pages.
54 * This is only valid when the page is allocated. */
57 /* the generation that this page belongs to. This should be valid
58 * for all pages that may have objects allocated, even current
59 * allocation region pages - this allows the space of an object to
60 * be easily determined. */
63 /* the number of bytes of this page that are used. This may be less
64 * than the actual bytes used for pages within the current
65 * allocation regions. It should be 0 for all unallocated pages (not
66 * hard to achieve). */
69 /* It is important to know the offset to the first object in the
70 * page. Currently it's only important to know if an object starts
71 * at the beginning of the page in which case the offset would be 0. */
72 int first_object_offset;
75 /* values for the page.allocated field */
78 /* the number of pages needed for the dynamic space - rounding up */
79 #define NUM_PAGES ((DYNAMIC_SPACE_SIZE+4095)/4096)
80 extern struct page page_table[NUM_PAGES];
83 void gencgc_pickup_dynamic(void);
85 void sniff_code_object(struct code *code, unsigned displacement);
86 void gencgc_apply_code_fixups(struct code *old_code, struct code *new_code);
88 int update_x86_dynamic_space_free_pointer(void);
89 void gc_alloc_update_page_tables(int unboxed,
90 struct alloc_region *alloc_region);
95 space_matches_p(lispobj obj, int space)
97 int page_index=(void*)obj - (void *)DYNAMIC_SPACE_START;
98 return ((page_index >= 0)
99 && ((page_index = ((unsigned int)page_index)/4096) < NUM_PAGES)
100 && (page_table[page_index].gen == space));
103 static inline boolean
104 from_space_p(lispobj obj)
106 return space_matches_p(obj,from_space);
109 static inline boolean
110 new_space_p(lispobj obj)
112 return space_matches_p(obj,new_space);