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

Last change on this file since 11522 was 11522, checked in by gb, 12 years ago

PPC support for FLASH-FREEZE, which is like FREEZE without forcing
GC.

Incidentally, ensure that GC-related functions (things called via
the gc_like_from_xp() mechanism) return signed_natural results, not
just ints. (I think that in most cases the return values are currently
ignored, but they shouldn't be truncated to 32 bits, just in case something
uses them.)

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