source: branches/purify/source/lisp-kernel/area.h @ 12890

Last change on this file since 12890 was 12890, checked in by gb, 11 years ago

Work-in-progress. Current plan:

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