2 * garbage collection - shared definitions for modules "inside" the GC system
6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
16 #ifndef _GC_INTERNAL_H_
17 #define _GC_INTERNAL_H_
19 #include <genesis/simple-fun.h>
21 /* disabling gc assertions made no discernable difference to GC speed,
22 * last I tried it - dan 2003.12.21 */
24 # define gc_assert(ex) \
26 if (!(ex)) gc_abort(); \
28 # define gc_assert_verbose(ex, fmt, ...) \
31 fprintf(stderr, fmt, ## __VA_ARGS__); \
36 # define gc_assert(ex)
37 # define gc_assert_verbose(ex, fmt, ...)
41 lose("GC invariant lost, file \"%s\", line %d\n", __FILE__, __LINE__)
43 #define CEILING(x,y) (((x) + ((y) - 1)) & (~((y) - 1)))
45 static inline unsigned long
46 NWORDS(unsigned long x, unsigned long n_bits)
48 /* A good compiler should be able to constant-fold this whole thing,
49 even with the conditional. */
50 if(n_bits <= N_WORD_BITS) {
51 unsigned long elements_per_word = N_WORD_BITS/n_bits;
53 return CEILING(x, elements_per_word)/elements_per_word;
56 /* FIXME: should have some sort of assertion that N_WORD_BITS
57 evenly divides n_bits */
58 return x * (n_bits/N_WORD_BITS);
62 /* FIXME: Shouldn't this be defined in sbcl.h? */
64 #if defined(LISP_FEATURE_SPARC)
65 #define FUN_RAW_ADDR_OFFSET 0
67 #define FUN_RAW_ADDR_OFFSET (offsetof(struct simple_fun, code) - FUN_POINTER_LOWTAG)
70 /* values for the *_alloc_* parameters */
71 #define FREE_PAGE_FLAG 0
72 #define BOXED_PAGE_FLAG 1
73 #define UNBOXED_PAGE_FLAG 2
74 #define OPEN_REGION_PAGE_FLAG 4
77 #define ALLOC_UNBOXED 1
80 void *gc_general_alloc(long nbytes,int unboxed_p,int quick_p);
82 extern long (*scavtab[256])(lispobj *where, lispobj object);
83 extern lispobj (*transother[256])(lispobj object);
84 extern long (*sizetab[256])(lispobj *where);
86 extern struct weak_pointer *weak_pointers; /* in gc-common.c */
87 extern struct hash_table *weak_hash_tables; /* in gc-common.c */
89 extern void scavenge(lispobj *start, long n_words);
90 extern void scavenge_interrupt_contexts(void);
91 extern void scav_weak_hash_tables(void);
92 extern void scan_weak_hash_tables(void);
93 extern void scan_weak_pointers(void);
95 lispobj copy_large_unboxed_object(lispobj object, long nwords);
96 lispobj copy_unboxed_object(lispobj object, long nwords);
97 lispobj copy_large_object(lispobj object, long nwords);
98 lispobj copy_object(lispobj object, long nwords);
100 lispobj *search_read_only_space(void *pointer);
101 lispobj *search_static_space(void *pointer);
102 lispobj *search_dynamic_space(void *pointer);
104 lispobj *gc_search_space(lispobj *start, size_t words, lispobj *pointer);
108 #ifdef LISP_FEATURE_GENCGC
109 #include "gencgc-internal.h"
111 #include "cheneygc-internal.h"
114 #if N_WORD_BITS == 32
115 # define SIMPLE_ARRAY_WORD_WIDETAG SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG
116 #elif N_WORD_BITS == 64
117 # define SIMPLE_ARRAY_WORD_WIDETAG SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
120 #endif /* _GC_INTERNAL_H_ */