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

Last change on this file since 8408 was 8408, checked in by gb, 13 years ago

Win64 changes; see if they break other platforms.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 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#endif
53#endif
54
55
56extern void zero_memory_range(BytePtr,BytePtr);
57extern LispObj GCarealow, GCareadynamiclow;
58extern natural GCndnodes_in_area, GCndynamic_dnodes_in_area;
59extern bitvector GCmarkbits, GCdynamic_markbits;
60LispObj *global_reloctab, *GCrelocptr;
61LispObj GCfirstunmarked;
62
63extern natural lisp_heap_gc_threshold;
64void mark_root(LispObj);
65void mark_pc_root(LispObj);
66void mark_locative_root(LispObj);
67void rmark(LispObj);
68void postGCfree(void *);
69LispObj *skip_over_ivector(LispObj, LispObj);
70void mark_simple_area_range(LispObj *,LispObj *);
71LispObj calculate_relocation();
72LispObj locative_forwarding_address(LispObj);
73LispObj node_forwarding_address(LispObj);
74void forward_range(LispObj *, LispObj *);
75void note_memoized_references(ExceptionInformation *,LogicalAddress, LogicalAddress, BytePtr *, BytePtr *);
76void gc(TCR *, signed_natural);
77int  purify(TCR *, signed_natural);
78int impurify(TCR *, signed_natural);
79int change_hons_area_size(TCR *, signed_natural);
80void delete_protected_area(protected_area_ptr);
81Boolean egc_control(Boolean, BytePtr);
82Boolean free_segments_zero_filled_by_OS;
83
84/* an type representing 1/4 of a natural word */
85#if WORD_SIZE == 64
86typedef unsigned short qnode;
87#else
88typedef unsigned char qnode;
89#endif
90
91
92#ifdef fulltag_symbol
93#define is_symbol_fulltag(x) (fulltag_of(x) == fulltag_symbol)
94#else
95#define is_symbol_fulltag(x) (fulltag_of(x) == fulltag_misc)
96#endif
97
98#define area_dnode(w,low) ((natural)(((ptr_to_lispobj(w)) - ptr_to_lispobj(low))>>dnode_shift))
99#define gc_area_dnode(w)  area_dnode(w,GCarealow)
100#define gc_dynamic_area_dnode(w) area_dnode(w,GCareadynamiclow)
101
102#ifdef PPC64
103#define forward_marker subtag_forward_marker
104#else
105#define forward_marker fulltag_nil
106#endif
107
108#ifdef PPC64
109#define VOID_ALLOCPTR ((LispObj)(0x8000000000000000-dnode_size))
110#else
111#define VOID_ALLOCPTR ((LispObj)(-dnode_size))
112#endif
113
114#ifdef DARWIN
115#include <mach/task_info.h>
116typedef struct task_events_info paging_info;
117#else
118#ifndef WINDOWS
119#include <sys/resource.h>
120typedef struct rusage paging_info;
121#else
122typedef natural paging_info;
123#endif
124#endif
125
126#include <stdio.h>
127
128void sample_paging_info(paging_info *);
129void report_paging_info_delta(FILE*, paging_info *, paging_info *);
130
131
132#define GC_TRAP_FUNCTION_IMMEDIATE_GC (-1)
133#define GC_TRAP_FUNCTION_GC 0
134#define GC_TRAP_FUNCTION_PURIFY 1
135#define GC_TRAP_FUNCTION_IMPURIFY 2
136#define GC_TRAP_FUNCTION_SAVE_APPLICATION 8
137
138#define GC_TRAP_FUNCTION_GET_LISP_HEAP_THRESHOLD 16
139#define GC_TRAP_FUNCTION_SET_LISP_HEAP_THRESHOLD 17
140#define GC_TRAP_FUNCTION_USE_LISP_HEAP_THRESHOLD 18
141#define GC_TRAP_FUNCTION_EGC_CONTROL 32
142#define GC_TRAP_FUNCTION_CONFIGURE_EGC 64
143#define GC_TRAP_FUNCTION_SET_HONS_AREA_SIZE 128 /* deprecated */
144#define GC_TRAP_FUNCTION_FREEZE 129
145#define GC_TRAP_FUNCTION_THAW 130
146
147Boolean GCDebug, GCverbose, just_purified_p;
148bitvector GCmarkbits, GCdynamic_markbits;
149LispObj GCarealow, GCareadynamiclow;
150natural GCndnodes_in_area, GCndynamic_dnodes_in_area;
151LispObj GCweakvll,GCdwsweakvll;
152LispObj GCephemeral_low;
153natural GCn_ephemeral_dnodes;
154natural GCstack_limit;
155
156#if WORD_SIZE == 64
157unsigned short *_one_bits;
158#else
159const unsigned char _one_bits[256];
160#endif
161
162#define one_bits(x) _one_bits[x]
163
164natural static_dnodes_for_area(area *a);
165void reapweakv(LispObj weakv);
166void reaphashv(LispObj hashv);
167Boolean mark_weak_hash_vector(hash_table_vector_header *hashp, natural elements);
168Boolean mark_weak_alist(LispObj weak_alist, int weak_type);
169void mark_tcr_tlb(TCR *);
170void mark_tcr_xframes(TCR *);
171void postGCfree(void *);
172void freeGCptrs(void);
173void reap_gcable_ptrs(void);
174unsigned short logcount16(unsigned short);
175void gc_init(void);
176LispObj node_forwarding_address(LispObj);
177Boolean update_noderef(LispObj *);
178void update_locref(LispObj *);
179void forward_gcable_ptrs(void);
180void forward_memoized_area(area *, natural);
181void forward_tcr_tlb(TCR *);
182void reclaim_static_dnodes(void);
183Boolean youngest_non_null_area_p(area *);
184void gc(TCR *, signed_natural);
185
186/* backend-interface */
187
188typedef void (*weak_mark_fun) (LispObj);
189weak_mark_fun mark_weak_htabv, dws_mark_weak_htabv;
190
191typedef void (*weak_process_fun)(void);
192
193weak_process_fun markhtabvs;
194
195
196#define hash_table_vector_header_count (sizeof(hash_table_vector_header)/sizeof(LispObj))
197
198void mark_root(LispObj);
199void rmark(LispObj);
200void mark_xp(ExceptionInformation *);
201LispObj dnode_forwarding_address(natural, int);
202LispObj locative_forwarding_address(LispObj);
203void check_refmap_consistency(LispObj *, LispObj *, bitvector);
204void check_all_areas(void);
205void mark_tstack_area(area *);
206void mark_vstack_area(area *);
207void mark_cstack_area(area *);
208void mark_simple_area_range(LispObj *, LispObj *);
209void mark_memoized_area(area *, natural);
210LispObj calculate_relocation(void);
211void forward_range(LispObj *, LispObj *);
212void forward_tstack_area(area *);
213void forward_vstack_area(area *);
214void forward_cstack_area(area *);
215LispObj compact_dynamic_heap(void);
216LispObj * skip_over_ivector(natural, LispObj);
217int purify(TCR *, signed_natural);
218int impurify(TCR *, signed_natural);
219
220#endif                          /* __GC_H__ */
Note: See TracBrowser for help on using the repository browser.