source: release/1.7/source/lisp-kernel/area.h @ 15267

Last change on this file since 15267 was 15056, checked in by rme, 8 years ago

Merge r15055 from trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 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 __AREA_H__
19#define __AREA_H__ 1
20
21
22#include "bits.h"
23#include "memprotect.h"
24
25
26
27typedef enum {
28  AREA_VOID = 0,                /* Not really an area at all */
29  AREA_CSTACK = 1<<fixnumshift, /* A control stack */
30  AREA_VSTACK = 2<<fixnumshift, /* A value stack.  The GC sees it as being doubleword-aligned */
31  AREA_TSTACK = 3<<fixnumshift, /* A temp stack.  It -is- doubleword-aligned */
32  AREA_READONLY = 4<<fixnumshift, /* A (cfm) read-only section. */
33  AREA_WATCHED = 5<<fixnumshift, /* A static area containing a single object. */
34  AREA_STATIC_CONS = 6<<fixnumshift, /* static, conses only */
35  AREA_MANAGED_STATIC = 7<<fixnumshift, /* A resizable static area */
36  AREA_STATIC = 8<<fixnumshift, /* A  static section: contains
37                                 roots, but not GCed */
38  AREA_DYNAMIC = 9<<fixnumshift /* A heap. Only one such area is "the heap."*/
39} area_code;
40
41typedef struct area {
42  struct area* pred;            /* linked list predecessor */
43  struct area* succ;            /* linked list successor */
44  char* low;                    /* arithmetic lower limit on addresses
45                                   (inclusive) */
46  char* high;                   /* arithmetic upper limit on addresses
47                                   (exclusive) */
48  char* active;                 /* low bound (stack) or high bound
49                                   (heap) */
50  char* softlimit;              /* only makes sense for dynamic heaps
51                                   & stacks */
52  char* hardlimit;              /* only makes sense for dynamic heaps
53                                   & stacks */
54  natural code;
55  natural*  markbits;           /* markbits for active area */
56  natural ndnodes;              /* "active" size of dynamic area or
57                                   stack */
58  struct area* older;           /* if ephemeral, the next older ephemeral area
59                                 or the dynamic area */
60  struct area* younger;         /* if ephemeral, the next "younger"
61                                  ephemeral area if there is one.  If
62                                  dynamic, the oldest ephemeral
63                                  area. */
64  char*  h;                     /* The pointer allocated to contain
65                                 this area, or NULL if the operating
66                                 system allocated it for us. */
67  protected_area* softprot;     /* "soft" protected_area */
68  protected_area* hardprot;     /* "hard" protected_area */
69  TCR * owner;                  /* TCR that the area belongs to, if a stack */
70  natural*  refbits;            /* intergenerational references.  May
71                                               or may not be the same
72                                               as markbits */
73  natural threshold;            /* egc threshold (boxed "fullword
74                                   count") or 0 */
75  LispObj gccount;              /* boxed generation GC count. */
76  natural static_dnodes;        /* for hash consing, maybe other things. */
77  natural *static_used;         /* bitvector */
78} area;
79
80
81/*
82  Areas are kept in a doubly-linked list.
83  The list header is just a distinguished element of
84  that list; by convention, the "active" dynamic
85  area is described by that header's successor, and areas
86  that may have entries in their "markbits" vector (heaps)
87  precede (in the area_list->succ sense) those  that don't (stacks).
88  The list header's "area" pointer is an "AREA_VOID" area; the header
89  (once allocated during kernel initialization) never
90  moves or changes.  Lisp code can get its hands on
91  the list header via a nilreg global, and carefully,
92  atomically, traverse it to do ROOM, etc.
93*/
94
95
96area *new_area(BytePtr, BytePtr, area_code);
97void add_area(area *, TCR *);
98void add_area_holding_area_lock(area *);
99void condemn_area(area *, TCR *);
100void condemn_area_holding_area_lock(area *);
101area *area_containing(BytePtr);
102area *stack_area_containing(BytePtr);
103area *heap_area_containing(BytePtr);
104void tenure_to_area(area *);
105void untenure_from_area(area *);
106
107Boolean grow_dynamic_area(natural);
108Boolean shrink_dynamic_area(natural);
109
110/* serialize add_area/remove_area, and also the tcr queue */
111void *tcr_area_lock;
112
113#define reserved_area ((area *)(all_areas))
114#define active_dynamic_area ((area *)(reserved_area->succ))
115
116typedef struct area_list {
117  area *the_area;
118  struct area_list *next;
119} area_list;
120
121/* The useable size of a tsp or vsp stack segment.
122  */
123/* #define STACK_SEGMENT_SIZE (64<<10) */
124#define MIN_CSTACK_SIZE (1<<17)
125#define CSTACK_HARDPROT (100<<10)
126#define CSTACK_SOFTPROT (100<<10)
127#define MIN_VSTACK_SIZE (1<<16)
128#define VSTACK_HARDPROT (1<<12)
129
130#ifdef PPC
131#define VSTACK_SOFTPROT (1<<16)
132#else
133#define VSTACK_SOFTPROT CSTACK_SOFTPROT
134#endif
135
136#define MIN_TSTACK_SIZE (1<<18)
137#define TSTACK_HARDPROT ((1<<16)+(1<<12))
138#define TSTACK_SOFTPROT ((1<<16)+(1<<12))
139
140#ifdef PPC
141#define CS_OVERFLOW_FORCE_LIMIT ((natural)(-(sizeof(lisp_frame))))
142#endif
143
144#ifdef X86
145#define CS_OVERFLOW_FORCE_LIMIT ((natural)(-16))
146#endif
147
148#ifdef ARM
149#define CS_OVERFLOW_FORCE_LIMIT ((natural)(-(sizeof(lisp_frame))))
150#endif
151
152
153
154#if (WORD_SIZE==64)
155#define PURESPACE_RESERVE 0x2000000000LL /* 128 GB */
156#define PURESPACE_SIZE (1LL<<30LL)
157#else
158#ifdef ARM
159#define PURESPACE_RESERVE (64<<20)
160#define PURESPACE_SIZE (32<<20)
161#else
162#define PURESPACE_RESERVE (128<<20) /* MB */
163#define PURESPACE_SIZE (64<<20)
164#endif
165#endif
166
167#define STATIC_RESERVE (2<<12)
168
169
170#define SPJUMP_TARGET_ADDRESS (STATIC_BASE_ADDRESS+0x3000)
171
172extern LispObj image_base;
173extern BytePtr pure_space_start, pure_space_active, pure_space_limit;
174extern BytePtr static_space_start, static_space_active, static_space_limit;
175extern area *find_readonly_area(void);
176extern BytePtr low_relocatable_address, high_relocatable_address,
177  low_markable_address, high_markable_address, reserved_region_end;
178
179#endif /* __AREA_H__ */
Note: See TracBrowser for help on using the repository browser.