source: release/1.9/source/lisp-kernel/memprotect.h @ 16083

Last change on this file since 16083 was 15366, checked in by gb, 7 years ago

Change the write-barrier implementation on x86:
managed_static_area->refbits tracks references to (potential)
ephemeral objects and is traversed by the EGC; the new global
managed_static_refbits tracks references from the managed_static_area to
(potential) dynamic objects and is traversed by full GC.

To support this:

  • add a couple of new kernel globals (actually, conditionally redefine a few PPC-specific things) to keep track of the number of dnodes in the managed static area and the new managed_static_bitvector. (We might want to just add new globals and leave the PPC-specific things there; the managed_static_area is currently X86-specific, but we might want to use it on other architectures.)
  • change the image loading/saving code to restore/save managed_static_refbits
  • change purify/impurify on x86 to maintain both bitvectors
  • change the GC to traverse both bitvectors (in different situations)
  • initialize and maintain the new kernel globals
  • provide a way of reserving address space for reasons other than heap initialization
  • implement the new write barrier in the affected x86 subprimitives
  • maintain both bitvectors in pc_luser_xp
  • other incidental changes.

This seems to work reliably on X8664 Linux. Some stuff needs to be tested
on Win64 and the X8632 write-barrier code probably needs lots of testing
(that machine hardly has any registers ...). Other platforms shouldn't
be affected, but we'll see.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.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 __memprotect_h__
19#define __memprotect_h__
20
21
22
23#include <signal.h>
24#ifndef WINDOWS
25#ifdef DARWIN
26#include <sys/ucontext.h>
27#else
28#include <ucontext.h>
29#endif
30#endif
31
32#ifdef WINDOWS
33#define MAP_FAILED ((void *)(-1))
34
35#define MEMPROTECT_NONE PAGE_NOACCESS
36#define MEMPROTECT_RO   PAGE_READONLY
37#define MEMPROTECT_RW   PAGE_READWRITE
38#define MEMPROTECT_RX   PAGE_EXECUTE_READ
39#define MEMPROTECT_RWX  PAGE_EXECUTE_READWRITE
40
41#else
42
43#define MEMPROTECT_NONE PROT_NONE
44#define MEMPROTECT_RO   PROT_READ
45#define MEMPROTECT_RW   (PROT_READ|PROT_WRITE)
46#define MEMPROTECT_RX   (PROT_READ|PROT_EXEC)
47#define MEMPROTECT_RWX  (PROT_READ|PROT_WRITE|PROT_EXEC)
48
49
50#endif
51
52LogicalAddress
53ReserveMemoryForHeap(LogicalAddress want, natural totalsize);
54LogicalAddress
55ReserveMemory(natural totalsize);
56
57int
58CommitMemory (LogicalAddress start, natural len);
59
60void
61UnCommitMemory (LogicalAddress start, natural len);
62
63LogicalAddress
64MapMemory(LogicalAddress addr, natural nbytes, int protection);
65
66LogicalAddress
67MapMemoryForStack(natural nbytes);
68
69int
70UnMapMemory(LogicalAddress addr, natural nbytes);
71
72int
73ProtectMemory(LogicalAddress, natural);
74
75int
76UnProtectMemory(LogicalAddress, natural);
77
78int
79MapFile(LogicalAddress addr, natural pos, natural nbytes, int permissions, int fd);
80void allocation_failure(Boolean pointerp, natural size);
81
82void protect_watched_areas(void);
83void unprotect_watched_areas(void);
84
85typedef enum {
86  kNotProtected,                /* At least not at the moment. */
87  kVSPsoftguard,
88  kSPsoftguard,
89  kTSPsoftguard,
90  kSPhardguard,                 /* Touch one and die. */
91  kVSPhardguard,
92  kTSPhardguard,
93  kHEAPsoft,                    /* Uninitialized page in the heap */
94  kHEAPhard,                    /* The end-of-the-line in the heap */
95  /* Phony last entry. */
96  kNumProtectionKinds
97  } lisp_protection_kind;
98
99typedef
100struct protected_area {
101  struct protected_area *next;
102  BytePtr start;                /* first byte (page-aligned) that might be protected */
103  BytePtr end;                  /* last byte (page-aligned) that could be protected */
104  unsigned nprot;               /* Might be 0 */
105  unsigned protsize;            /* number of bytes to protect */
106  lisp_protection_kind why;
107} protected_area, *protected_area_ptr;
108
109void unprotect_area(protected_area_ptr);
110
111/* Various functions that try to respond to a protection violation */
112typedef 
113  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
114
115protection_handler
116  do_spurious_wp_fault,
117  do_soft_stack_overflow,
118  do_hard_stack_overflow,
119  do_tenured_space_write,
120  do_heap_soft_probe,
121  do_heap_hard_probe;
122
123extern protection_handler
124  *protection_handlers[];
125
126
127void
128exception_cleanup(void);
129
130
131 
132#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.