source: trunk/source/lisp-kernel/gc.h @ 14261

Last change on this file since 14261 was 14119, checked in by gb, 9 years ago

Changes from ARM branch. Need testing ...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/*
2   Copyright (C) 2009 Clozure Associates
3   Copyright (C) 1994-2001 Digitool, Inc
4   This file is part of Clozure CL. 
5
6   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7   License , known as the LLGPL and distributed with Clozure CL as the
8   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9   which is distributed with Clozure CL as the file "LGPL".  Where these
10   conflict, the preamble takes precedence. 
11
12   Clozure CL is referenced in the preamble as the "LIBRARY."
13
14   The LLGPL is also available online at
15   http://opensource.franz.com/preamble.html
16*/
17
18#ifndef __GC_H__
19#define __GC_H__ 1
20
21#include "lisp.h"
22#include "bits.h"
23#include "lisp-exceptions.h"
24#include "memprotect.h"
25
26
27
28#ifdef PPC
29#define is_node_fulltag(f)  ((1<<(f))&((1<<fulltag_cons)|(1<<fulltag_misc)))
30#ifdef PPC64
31#define PPC64_CODE_VECTOR_PREFIX (('C'<< 24) | ('O' << 16) | ('D' << 8) | 'E')
32#else
33/*
34  A code-vector's header can't look like a valid instruction or UUO:
35  the low 8 bits must be subtag_code_vector, and the top 6 bits
36  must be 0.  That means that the maximum length of a code vector
37  is 18 bits worth of elements (~1MB.)
38*/
39
40#define code_header_mask ((0x3f<<26) | subtag_code_vector)
41#endif
42#endif
43
44#ifdef X86
45#ifdef X8664
46#define is_node_fulltag(f)  ((1<<(f))&((1<<fulltag_cons)    | \
47                                       (1<<fulltag_tra_0)   | \
48                                       (1<<fulltag_tra_1)   | \
49                                       (1<<fulltag_misc)    | \
50                                       (1<<fulltag_symbol)  | \
51                                       (1<<fulltag_function)))
52#else
53#define is_node_fulltag(f)  ((1<<(f))&((1<<fulltag_cons) | \
54                                       (1<<fulltag_misc) | \
55                                       (1<<fulltag_tra)))
56#endif
57#endif
58
59#ifdef ARM
60#define is_node_fulltag(f)  ((1<<(f))&((1<<fulltag_cons)|(1<<fulltag_misc)))
61#endif
62
63extern void zero_memory_range(BytePtr,BytePtr);
64extern LispObj GCarealow, GCareadynamiclow;
65extern natural GCndnodes_in_area, GCndynamic_dnodes_in_area;
66extern bitvector GCmarkbits, GCdynamic_markbits;
67LispObj *global_reloctab, *GCrelocptr;
68LispObj GCfirstunmarked;
69
70extern natural lisp_heap_gc_threshold;
71extern natural lisp_heap_notify_threshold;
72void mark_root(LispObj);
73void mark_pc_root(LispObj);
74void mark_locative_root(LispObj);
75void rmark(LispObj);
76void postGCfree(void *);
77LispObj *skip_over_ivector(LispObj, LispObj);
78void mark_simple_area_range(LispObj *,LispObj *);
79LispObj calculate_relocation();
80LispObj locative_forwarding_address(LispObj);
81LispObj node_forwarding_address(LispObj);
82void forward_range(LispObj *, LispObj *);
83void note_memoized_references(ExceptionInformation *,LogicalAddress, LogicalAddress, BytePtr *, BytePtr *);
84void gc(TCR *, signed_natural);
85int change_hons_area_size(TCR *, signed_natural);
86void delete_protected_area(protected_area_ptr);
87Boolean egc_control(Boolean, BytePtr);
88Boolean free_segments_zero_filled_by_OS;
89
90/* an type representing 1/4 of a natural word */
91#if WORD_SIZE == 64
92typedef unsigned short qnode;
93#else
94typedef unsigned char qnode;
95#endif
96
97
98#ifdef fulltag_symbol
99#define is_symbol_fulltag(x) (fulltag_of(x) == fulltag_symbol)
100#else
101#define is_symbol_fulltag(x) (fulltag_of(x) == fulltag_misc)
102#endif
103
104#define area_dnode(w,low) ((natural)(((ptr_to_lispobj(w)) - ptr_to_lispobj(low))>>dnode_shift))
105#define gc_area_dnode(w)  area_dnode(w,GCarealow)
106#define gc_dynamic_area_dnode(w) area_dnode(w,GCareadynamiclow)
107
108#if defined(PPC64) || defined(X8632)
109#define forward_marker subtag_forward_marker
110#else
111#ifdef ARM
112#define forward_marker (0xe7fffff0|uuo_format_unary)
113#else
114#define forward_marker fulltag_nil
115#endif
116#endif
117
118#ifdef PPC64
119#define VOID_ALLOCPTR ((LispObj)(0x8000000000000000-dnode_size))
120#else
121#define VOID_ALLOCPTR ((LispObj)(-dnode_size))
122#endif
123
124#ifdef DARWIN
125#include <mach/task_info.h>
126typedef struct task_events_info paging_info;
127#else
128#ifndef WINDOWS
129#include <sys/resource.h>
130typedef struct rusage paging_info;
131#else
132typedef natural paging_info;
133#endif
134#endif
135
136#undef __argv
137#include <stdio.h>
138
139void sample_paging_info(paging_info *);
140void report_paging_info_delta(FILE*, paging_info *, paging_info *);
141
142
143#define GC_TRAP_FUNCTION_IMMEDIATE_GC (-1)
144#define GC_TRAP_FUNCTION_GC 0
145#define GC_TRAP_FUNCTION_PURIFY 1
146#define GC_TRAP_FUNCTION_IMPURIFY 2
147#define GC_TRAP_FUNCTION_FLASH_FREEZE 4
148#define GC_TRAP_FUNCTION_SAVE_APPLICATION 8
149
150#define GC_TRAP_FUNCTION_GET_LISP_HEAP_THRESHOLD 16
151#define GC_TRAP_FUNCTION_SET_LISP_HEAP_THRESHOLD 17
152#define GC_TRAP_FUNCTION_USE_LISP_HEAP_THRESHOLD 18
153#define GC_TRAP_FUNCTION_ENSURE_STATIC_CONSES 19
154#define GC_TRAP_FUNCTION_GET_GC_NOTIFICATION_THRESHOLD 20
155#define GC_TRAP_FUNCTION_SET_GC_NOTIFICATION_THRESHOLD 21
156#define GC_TRAP_FUNCTION_EGC_CONTROL 32
157#define GC_TRAP_FUNCTION_CONFIGURE_EGC 64
158#define GC_TRAP_FUNCTION_FREEZE 129
159#define GC_TRAP_FUNCTION_THAW 130
160
161Boolean GCDebug, GCverbose, just_purified_p;
162bitvector GCmarkbits, GCdynamic_markbits;
163LispObj GCarealow, GCareadynamiclow;
164natural GCndnodes_in_area, GCndynamic_dnodes_in_area;
165LispObj GCweakvll,GCdwsweakvll;
166LispObj GCephemeral_low;
167natural GCn_ephemeral_dnodes;
168natural GCstack_limit;
169
170#if WORD_SIZE == 64
171unsigned short *_one_bits;
172#else
173const unsigned char _one_bits[256];
174#endif
175
176#define one_bits(x) _one_bits[x]
177
178natural static_dnodes_for_area(area *a);
179void reapweakv(LispObj weakv);
180void reaphashv(LispObj hashv);
181Boolean mark_weak_hash_vector(hash_table_vector_header *hashp, natural elements);
182Boolean mark_weak_alist(LispObj weak_alist, int weak_type);
183void mark_tcr_tlb(TCR *);
184void mark_tcr_xframes(TCR *);
185void freeGCptrs(void);
186void reap_gcable_ptrs(void);
187unsigned short logcount16(unsigned short);
188void gc_init(void);
189LispObj node_forwarding_address(LispObj);
190Boolean update_noderef(LispObj *);
191void update_locref(LispObj *);
192void forward_gcable_ptrs(void);
193void forward_memoized_area(area *, natural);
194void forward_tcr_tlb(TCR *);
195void reclaim_static_dnodes(void);
196Boolean youngest_non_null_area_p(area *);
197void gc(TCR *, signed_natural);
198
199/* backend-interface */
200
201typedef void (*weak_mark_fun) (LispObj);
202weak_mark_fun mark_weak_htabv, dws_mark_weak_htabv;
203
204typedef void (*weak_process_fun)(void);
205
206weak_process_fun markhtabvs;
207
208
209#define hash_table_vector_header_count (sizeof(hash_table_vector_header)/sizeof(LispObj))
210
211void mark_root(LispObj);
212void rmark(LispObj);
213#ifdef X8632
214void mark_xp(ExceptionInformation *, natural);
215#else
216void mark_xp(ExceptionInformation *);
217#endif
218LispObj dnode_forwarding_address(natural, int);
219LispObj locative_forwarding_address(LispObj);
220void check_refmap_consistency(LispObj *, LispObj *, bitvector);
221void check_all_areas(TCR *);
222void mark_tstack_area(area *);
223void mark_vstack_area(area *);
224void mark_cstack_area(area *);
225void mark_simple_area_range(LispObj *, LispObj *);
226void mark_memoized_area(area *, natural);
227LispObj calculate_relocation(void);
228void forward_range(LispObj *, LispObj *);
229void forward_tstack_area(area *);
230void forward_vstack_area(area *);
231void forward_cstack_area(area *);
232LispObj compact_dynamic_heap(void);
233signed_natural purify(TCR *, signed_natural);
234signed_natural impurify(TCR *, signed_natural);
235signed_natural gc_like_from_xp(ExceptionInformation *, signed_natural(*fun)(TCR *, signed_natural), signed_natural);
236
237
238typedef enum {
239  xmacptr_flag_none = 0,        /* Maybe already disposed by Lisp */
240  xmacptr_flag_recursive_lock,  /* recursive-lock */
241  xmacptr_flag_ptr,             /* malloc/free */
242  xmacptr_flag_rwlock,          /* read/write lock */
243  xmacptr_flag_semaphore,        /* semaphore */
244  xmacptr_flag_user_first = 8,  /* first user-defined dispose fn */
245  xmacptr_flag_user_last = 16   /* exclusive upper bound */
246} xmacptr_flag;
247
248
249typedef void (*xmacptr_dispose_fn)(void *);
250
251extern xmacptr_dispose_fn xmacptr_dispose_functions[];
252
253extern bitvector global_mark_ref_bits, dynamic_mark_ref_bits, relocatable_mark_ref_bits;
254
255extern Boolean
256did_gc_notification_since_last_full_gc;
257
258#endif                          /* __GC_H__ */
Note: See TracBrowser for help on using the repository browser.