1999-04-07 10:01:40 +02:00
|
|
|
/*
|
1999-11-02 00:15:51 +01:00
|
|
|
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
1999-04-07 10:01:40 +02:00
|
|
|
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
1999-11-02 00:15:51 +01:00
|
|
|
* Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
|
|
|
|
* Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
|
1999-04-07 10:01:40 +02:00
|
|
|
*
|
|
|
|
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
|
|
|
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted to use or copy this program
|
|
|
|
* for any purpose, provided the above notices are retained on all copies.
|
|
|
|
* Permission to modify the code and to distribute modified code is granted,
|
|
|
|
* provided the above notices are retained, and a notice that the code was
|
|
|
|
* modified is included with the above copyright notice.
|
|
|
|
*/
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# include "private/gc_priv.h"
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# if defined(LINUX) && !defined(POWERPC)
|
|
|
|
# include <linux/version.h>
|
|
|
|
# if (LINUX_VERSION_CODE <= 0x10400)
|
|
|
|
/* Ugly hack to get struct sigcontext_struct definition. Required */
|
|
|
|
/* for some early 1.3.X releases. Will hopefully go away soon. */
|
|
|
|
/* in some later Linux releases, asm/sigcontext.h may have to */
|
|
|
|
/* be included instead. */
|
|
|
|
# define __KERNEL__
|
|
|
|
# include <asm/signal.h>
|
|
|
|
# undef __KERNEL__
|
|
|
|
# else
|
|
|
|
/* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
|
|
|
|
/* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */
|
|
|
|
/* prototypes, so we have to include the top-level sigcontext.h to */
|
|
|
|
/* make sure the former gets defined to be the latter if appropriate. */
|
|
|
|
# include <features.h>
|
1999-11-02 00:15:51 +01:00
|
|
|
# if 2 <= __GLIBC__
|
|
|
|
# if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
|
|
|
|
/* glibc 2.1 no longer has sigcontext.h. But signal.h */
|
|
|
|
/* has the right declaration for glibc 2.1. */
|
|
|
|
# include <sigcontext.h>
|
|
|
|
# endif /* 0 == __GLIBC_MINOR__ */
|
1999-04-07 10:01:40 +02:00
|
|
|
# else /* not 2 <= __GLIBC__ */
|
|
|
|
/* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
|
|
|
|
/* one. Check LINUX_VERSION_CODE to see which we should reference. */
|
|
|
|
# include <asm/sigcontext.h>
|
|
|
|
# endif /* 2 <= __GLIBC__ */
|
|
|
|
# endif
|
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
|
|
|
|
&& !defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
# include <sys/types.h>
|
|
|
|
# if !defined(MSWIN32) && !defined(SUNOS4)
|
|
|
|
# include <unistd.h>
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# include <stdio.h>
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWINCE)
|
|
|
|
# define SIGSEGV 0 /* value is irrelevant */
|
|
|
|
# else
|
|
|
|
# include <signal.h>
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
#if defined(LINUX) || defined(LINUX_STACKBOTTOM)
|
|
|
|
# include <ctype.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Blatantly OS dependent routines, except for those that are related */
|
1999-11-02 00:15:51 +01:00
|
|
|
/* to dynamic loading. */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(HEURISTIC2) || defined(SEARCH_FOR_DATA_START)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
# endif
|
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
# if !defined(STACKBOTTOM) && defined(HEURISTIC2)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
# endif
|
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
# if (defined(SUNOS4) && defined(DYNAMIC_LOADING)) && !defined(PCR)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
# endif
|
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
# if (defined(SVR4) || defined(AUX) || defined(DGUX) \
|
|
|
|
|| (defined(LINUX) && defined(SPARC))) && !defined(PCR)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
# endif
|
|
|
|
|
2007-01-16 20:38:59 +01:00
|
|
|
#if defined(FREEBSD) && (defined(I386) || defined(X86_64) || defined(powerpc) || defined(__powerpc__))
|
2003-07-28 06:18:23 +02:00
|
|
|
# include <machine/trap.h>
|
|
|
|
# if !defined(PCR)
|
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__) \
|
|
|
|
&& !defined(NEED_FIND_LIMIT)
|
|
|
|
/* Used by GC_init_netbsd_elf() below. */
|
|
|
|
# define NEED_FIND_LIMIT
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#ifdef NEED_FIND_LIMIT
|
|
|
|
# include <setjmp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AMIGA
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# define GC_AMIGA_DEF
|
|
|
|
# include "AmigaOS.c"
|
|
|
|
# undef GC_AMIGA_DEF
|
1999-04-07 10:01:40 +02:00
|
|
|
#endif
|
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# define NOSERVICE
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MACOS
|
|
|
|
# include <Processes.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IRIX5
|
|
|
|
# include <sys/uio.h>
|
|
|
|
# include <malloc.h> /* for locking */
|
|
|
|
#endif
|
2004-08-14 01:05:36 +02:00
|
|
|
#if defined(USE_MMAP) || defined(USE_MUNMAP)
|
|
|
|
# ifndef USE_MMAP
|
|
|
|
--> USE_MUNMAP requires USE_MMAP
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/mman.h>
|
|
|
|
# include <sys/stat.h>
|
2004-08-14 01:05:36 +02:00
|
|
|
# include <errno.h>
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef UNIX_LIKE
|
1999-04-07 10:01:40 +02:00
|
|
|
# include <fcntl.h>
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(SUNOS5SIGS) && !defined(FREEBSD)
|
2001-08-18 03:04:43 +02:00
|
|
|
# include <sys/siginfo.h>
|
|
|
|
# endif
|
2004-08-14 01:05:36 +02:00
|
|
|
/* Define SETJMP and friends to be the version that restores */
|
|
|
|
/* the signal mask. */
|
|
|
|
# define SETJMP(env) sigsetjmp(env, 1)
|
|
|
|
# define LONGJMP(env, val) siglongjmp(env, val)
|
|
|
|
# define JMP_BUF sigjmp_buf
|
|
|
|
#else
|
|
|
|
# define SETJMP(env) setjmp(env)
|
|
|
|
# define LONGJMP(env, val) longjmp(env, val)
|
|
|
|
# define JMP_BUF jmp_buf
|
1999-04-07 10:01:40 +02:00
|
|
|
#endif
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#ifdef DARWIN
|
|
|
|
/* for get_etext and friends */
|
|
|
|
#include <mach-o/getsect.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#ifdef DJGPP
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* Apparently necessary for djgpp 2.01. May cause problems with */
|
1999-04-07 10:01:40 +02:00
|
|
|
/* other versions. */
|
|
|
|
typedef long unsigned int caddr_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PCR
|
|
|
|
# include "il/PCR_IL.h"
|
|
|
|
# include "th/PCR_ThCtl.h"
|
|
|
|
# include "mm/PCR_MM.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NO_EXECUTE_PERMISSION)
|
|
|
|
# define OPT_PROT_EXEC PROT_EXEC
|
|
|
|
#else
|
|
|
|
# define OPT_PROT_EXEC 0
|
|
|
|
#endif
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if defined(LINUX) && \
|
|
|
|
(defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) || !defined(SMALL_CONFIG))
|
|
|
|
|
|
|
|
/* We need to parse /proc/self/maps, either to find dynamic libraries, */
|
|
|
|
/* and/or to find the register backing store base (IA64). Do it once */
|
|
|
|
/* here. */
|
|
|
|
|
|
|
|
#define READ read
|
|
|
|
|
|
|
|
/* Repeatedly perform a read call until the buffer is filled or */
|
|
|
|
/* we encounter EOF. */
|
|
|
|
ssize_t GC_repeat_read(int fd, char *buf, size_t count)
|
|
|
|
{
|
|
|
|
ssize_t num_read = 0;
|
|
|
|
ssize_t result;
|
|
|
|
|
|
|
|
while (num_read < count) {
|
|
|
|
result = READ(fd, buf + num_read, count - num_read);
|
|
|
|
if (result < 0) return result;
|
|
|
|
if (result == 0) break;
|
|
|
|
num_read += result;
|
|
|
|
}
|
|
|
|
return num_read;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Apply fn to a buffer containing the contents of /proc/self/maps.
|
|
|
|
* Return the result of fn or, if we failed, 0.
|
2004-08-14 01:05:36 +02:00
|
|
|
* We currently do nothing to /proc/self/maps other than simply read
|
|
|
|
* it. This code could be simplified if we could determine its size
|
|
|
|
* ahead of time.
|
2003-07-28 06:18:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
word GC_apply_to_maps(word (*fn)(char *))
|
|
|
|
{
|
|
|
|
int f;
|
|
|
|
int result;
|
2004-08-14 01:05:36 +02:00
|
|
|
size_t maps_size = 4000; /* Initial guess. */
|
|
|
|
static char init_buf[1];
|
|
|
|
static char *maps_buf = init_buf;
|
|
|
|
static size_t maps_buf_sz = 1;
|
|
|
|
|
|
|
|
/* Read /proc/self/maps, growing maps_buf as necessary. */
|
|
|
|
/* Note that we may not allocate conventionally, and */
|
|
|
|
/* thus can't use stdio. */
|
2003-07-28 06:18:23 +02:00
|
|
|
do {
|
2004-08-14 01:05:36 +02:00
|
|
|
if (maps_size >= maps_buf_sz) {
|
|
|
|
/* Grow only by powers of 2, since we leak "too small" buffers. */
|
|
|
|
while (maps_size >= maps_buf_sz) maps_buf_sz *= 2;
|
|
|
|
maps_buf = GC_scratch_alloc(maps_buf_sz);
|
|
|
|
if (maps_buf == 0) return 0;
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
f = open("/proc/self/maps", O_RDONLY);
|
|
|
|
if (-1 == f) return 0;
|
2004-08-14 01:05:36 +02:00
|
|
|
maps_size = 0;
|
|
|
|
do {
|
|
|
|
result = GC_repeat_read(f, maps_buf, maps_buf_sz-1);
|
|
|
|
if (result <= 0) return 0;
|
|
|
|
maps_size += result;
|
|
|
|
} while (result == maps_buf_sz-1);
|
|
|
|
close(f);
|
|
|
|
} while (maps_size >= maps_buf_sz);
|
|
|
|
maps_buf[maps_size] = '\0';
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
/* Apply fn to result. */
|
|
|
|
return fn(maps_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Need GC_apply_to_maps */
|
|
|
|
|
|
|
|
#if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64))
|
|
|
|
//
|
|
|
|
// GC_parse_map_entry parses an entry from /proc/self/maps so we can
|
|
|
|
// locate all writable data segments that belong to shared libraries.
|
|
|
|
// The format of one of these entries and the fields we care about
|
|
|
|
// is as follows:
|
|
|
|
// XXXXXXXX-XXXXXXXX r-xp 00000000 30:05 260537 name of mapping...\n
|
|
|
|
// ^^^^^^^^ ^^^^^^^^ ^^^^ ^^
|
|
|
|
// start end prot maj_dev
|
|
|
|
//
|
2006-01-25 04:03:14 +01:00
|
|
|
// Note that since about auguat 2003 kernels, the columns no longer have
|
|
|
|
// fixed offsets on 64-bit kernels. Hence we no longer rely on fixed offsets
|
|
|
|
// anywhere, which is safer anyway.
|
2003-07-28 06:18:23 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assign various fields of the first line in buf_ptr to *start, *end,
|
|
|
|
* *prot_buf and *maj_dev. Only *prot_buf may be set for unwritable maps.
|
|
|
|
*/
|
|
|
|
char *GC_parse_map_entry(char *buf_ptr, word *start, word *end,
|
|
|
|
char *prot_buf, unsigned int *maj_dev)
|
|
|
|
{
|
2006-01-25 04:03:14 +01:00
|
|
|
char *start_start, *end_start, *prot_start, *maj_dev_start;
|
|
|
|
char *p;
|
|
|
|
char *endp;
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
if (buf_ptr == NULL || *buf_ptr == '\0') {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
p = buf_ptr;
|
|
|
|
while (isspace(*p)) ++p;
|
|
|
|
start_start = p;
|
|
|
|
GC_ASSERT(isxdigit(*start_start));
|
|
|
|
*start = strtoul(start_start, &endp, 16); p = endp;
|
|
|
|
GC_ASSERT(*p=='-');
|
2003-07-28 06:18:23 +02:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
++p;
|
|
|
|
end_start = p;
|
|
|
|
GC_ASSERT(isxdigit(*end_start));
|
|
|
|
*end = strtoul(end_start, &endp, 16); p = endp;
|
|
|
|
GC_ASSERT(isspace(*p));
|
2003-07-28 06:18:23 +02:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
while (isspace(*p)) ++p;
|
|
|
|
prot_start = p;
|
|
|
|
GC_ASSERT(*prot_start == 'r' || *prot_start == '-');
|
|
|
|
memcpy(prot_buf, prot_start, 4);
|
|
|
|
prot_buf[4] = '\0';
|
|
|
|
if (prot_buf[1] == 'w') {/* we can skip the rest if it's not writable. */
|
|
|
|
/* Skip past protection field to offset field */
|
|
|
|
while (!isspace(*p)) ++p; while (isspace(*p)) ++p;
|
|
|
|
GC_ASSERT(isxdigit(*p));
|
|
|
|
/* Skip past offset field, which we ignore */
|
|
|
|
while (!isspace(*p)) ++p; while (isspace(*p)) ++p;
|
|
|
|
maj_dev_start = p;
|
|
|
|
GC_ASSERT(isxdigit(*maj_dev_start));
|
|
|
|
*maj_dev = strtoul(maj_dev_start, NULL, 16);
|
2003-07-28 06:18:23 +02:00
|
|
|
}
|
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
while (*p && *p++ != '\n');
|
2003-07-28 06:18:23 +02:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
return p;
|
2003-07-28 06:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Need to parse /proc/self/maps. */
|
|
|
|
|
2000-04-19 12:10:01 +02:00
|
|
|
#if defined(SEARCH_FOR_DATA_START)
|
1999-11-02 00:15:51 +01:00
|
|
|
/* The I386 case can be handled without a search. The Alpha case */
|
|
|
|
/* used to be handled differently as well, but the rules changed */
|
|
|
|
/* for recent Linux versions. This seems to be the easiest way to */
|
|
|
|
/* cover all versions. */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2001-04-05 02:14:18 +02:00
|
|
|
# ifdef LINUX
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Some Linux distributions arrange to define __data_start. Some */
|
|
|
|
/* define data_start as a weak symbol. The latter is technically */
|
|
|
|
/* broken, since the user program may define data_start, in which */
|
|
|
|
/* case we lose. Nonetheless, we try both, prefering __data_start. */
|
|
|
|
/* We assume gcc-compatible pragmas. */
|
2001-04-05 02:14:18 +02:00
|
|
|
# pragma weak __data_start
|
2002-03-27 20:21:32 +01:00
|
|
|
extern int __data_start[];
|
2001-04-05 02:14:18 +02:00
|
|
|
# pragma weak data_start
|
2002-03-27 20:21:32 +01:00
|
|
|
extern int data_start[];
|
2001-04-05 02:14:18 +02:00
|
|
|
# endif /* LINUX */
|
2002-03-27 20:21:32 +01:00
|
|
|
extern int _end[];
|
2001-04-05 02:14:18 +02:00
|
|
|
|
|
|
|
ptr_t GC_data_start;
|
1999-04-07 10:01:40 +02:00
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
void GC_init_linux_data_start()
|
1999-06-21 17:39:02 +02:00
|
|
|
{
|
1999-11-02 00:15:51 +01:00
|
|
|
extern ptr_t GC_find_limit();
|
1999-06-21 17:39:02 +02:00
|
|
|
|
2001-04-05 02:14:18 +02:00
|
|
|
# ifdef LINUX
|
|
|
|
/* Try the easy approaches first: */
|
2003-07-28 06:18:23 +02:00
|
|
|
if ((ptr_t)__data_start != 0) {
|
|
|
|
GC_data_start = (ptr_t)(__data_start);
|
2001-04-05 02:14:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
if ((ptr_t)data_start != 0) {
|
|
|
|
GC_data_start = (ptr_t)(data_start);
|
2001-04-05 02:14:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
# endif /* LINUX */
|
2003-07-28 06:18:23 +02:00
|
|
|
GC_data_start = GC_find_limit((ptr_t)(_end), FALSE);
|
1999-06-21 17:39:02 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:42 +02:00
|
|
|
# ifdef ECOS
|
|
|
|
|
|
|
|
# ifndef ECOS_GC_MEMORY_SIZE
|
|
|
|
# define ECOS_GC_MEMORY_SIZE (448 * 1024)
|
|
|
|
# endif /* ECOS_GC_MEMORY_SIZE */
|
|
|
|
|
|
|
|
// setjmp() function, as described in ANSI para 7.6.1.1
|
2004-08-14 01:05:36 +02:00
|
|
|
#undef SETJMP
|
|
|
|
#define SETJMP( __env__ ) hal_setjmp( __env__ )
|
1999-04-07 10:01:42 +02:00
|
|
|
|
|
|
|
// FIXME: This is a simple way of allocating memory which is
|
|
|
|
// compatible with ECOS early releases. Later releases use a more
|
|
|
|
// sophisticated means of allocating memory than this simple static
|
|
|
|
// allocator, but this method is at least bound to work.
|
|
|
|
static char memory[ECOS_GC_MEMORY_SIZE];
|
|
|
|
static char *brk = memory;
|
|
|
|
|
|
|
|
static void *tiny_sbrk(ptrdiff_t increment)
|
|
|
|
{
|
|
|
|
void *p = brk;
|
|
|
|
|
|
|
|
brk += increment;
|
|
|
|
|
|
|
|
if (brk > memory + sizeof memory)
|
|
|
|
{
|
|
|
|
brk -= increment;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
#define sbrk tiny_sbrk
|
|
|
|
# endif /* ECOS */
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
ptr_t GC_data_start;
|
|
|
|
|
|
|
|
void GC_init_netbsd_elf()
|
|
|
|
{
|
|
|
|
extern ptr_t GC_find_limit();
|
|
|
|
extern char **environ;
|
|
|
|
/* This may need to be environ, without the underscore, for */
|
|
|
|
/* some versions. */
|
|
|
|
GC_data_start = GC_find_limit((ptr_t)&environ, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
# ifdef OS2
|
|
|
|
|
|
|
|
# include <stddef.h>
|
|
|
|
|
|
|
|
# if !defined(__IBMC__) && !defined(__WATCOMC__) /* e.g. EMX */
|
|
|
|
|
|
|
|
struct exe_hdr {
|
|
|
|
unsigned short magic_number;
|
|
|
|
unsigned short padding[29];
|
|
|
|
long new_exe_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define E_MAGIC(x) (x).magic_number
|
|
|
|
#define EMAGIC 0x5A4D
|
|
|
|
#define E_LFANEW(x) (x).new_exe_offset
|
|
|
|
|
|
|
|
struct e32_exe {
|
|
|
|
unsigned char magic_number[2];
|
|
|
|
unsigned char byte_order;
|
|
|
|
unsigned char word_order;
|
|
|
|
unsigned long exe_format_level;
|
|
|
|
unsigned short cpu;
|
|
|
|
unsigned short os;
|
|
|
|
unsigned long padding1[13];
|
|
|
|
unsigned long object_table_offset;
|
|
|
|
unsigned long object_count;
|
|
|
|
unsigned long padding2[31];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define E32_MAGIC1(x) (x).magic_number[0]
|
|
|
|
#define E32MAGIC1 'L'
|
|
|
|
#define E32_MAGIC2(x) (x).magic_number[1]
|
|
|
|
#define E32MAGIC2 'X'
|
|
|
|
#define E32_BORDER(x) (x).byte_order
|
|
|
|
#define E32LEBO 0
|
|
|
|
#define E32_WORDER(x) (x).word_order
|
|
|
|
#define E32LEWO 0
|
|
|
|
#define E32_CPU(x) (x).cpu
|
|
|
|
#define E32CPU286 1
|
|
|
|
#define E32_OBJTAB(x) (x).object_table_offset
|
|
|
|
#define E32_OBJCNT(x) (x).object_count
|
|
|
|
|
|
|
|
struct o32_obj {
|
|
|
|
unsigned long size;
|
|
|
|
unsigned long base;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long pagemap;
|
|
|
|
unsigned long mapsize;
|
|
|
|
unsigned long reserved;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define O32_FLAGS(x) (x).flags
|
|
|
|
#define OBJREAD 0x0001L
|
|
|
|
#define OBJWRITE 0x0002L
|
|
|
|
#define OBJINVALID 0x0080L
|
|
|
|
#define O32_SIZE(x) (x).size
|
|
|
|
#define O32_BASE(x) (x).base
|
|
|
|
|
|
|
|
# else /* IBM's compiler */
|
|
|
|
|
|
|
|
/* A kludge to get around what appears to be a header file bug */
|
|
|
|
# ifndef WORD
|
|
|
|
# define WORD unsigned short
|
|
|
|
# endif
|
|
|
|
# ifndef DWORD
|
|
|
|
# define DWORD unsigned long
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# define EXE386 1
|
|
|
|
# include <newexe.h>
|
|
|
|
# include <exe386.h>
|
|
|
|
|
|
|
|
# endif /* __IBMC__ */
|
|
|
|
|
|
|
|
# define INCL_DOSEXCEPTIONS
|
|
|
|
# define INCL_DOSPROCESS
|
|
|
|
# define INCL_DOSERRORS
|
|
|
|
# define INCL_DOSMODULEMGR
|
|
|
|
# define INCL_DOSMEMMGR
|
|
|
|
# include <os2.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* Disable and enable signals during nontrivial allocations */
|
|
|
|
|
|
|
|
void GC_disable_signals(void)
|
|
|
|
{
|
|
|
|
ULONG nest;
|
|
|
|
|
|
|
|
DosEnterMustComplete(&nest);
|
|
|
|
if (nest != 1) ABORT("nested GC_disable_signals");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GC_enable_signals(void)
|
|
|
|
{
|
|
|
|
ULONG nest;
|
|
|
|
|
|
|
|
DosExitMustComplete(&nest);
|
|
|
|
if (nest != 0) ABORT("GC_enable_signals");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# if !defined(PCR) && !defined(AMIGA) && !defined(MSWIN32) \
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
&& !defined(MSWINCE) \
|
2002-02-09 01:50:05 +01:00
|
|
|
&& !defined(MACOS) && !defined(DJGPP) && !defined(DOS4GW) \
|
|
|
|
&& !defined(NOSYS) && !defined(ECOS)
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2009-11-30 01:23:45 +01:00
|
|
|
# if defined(SIG_BLOCK)
|
|
|
|
/* Use POSIX/SYSV interface */
|
|
|
|
# define SIGSET_T sigset_t
|
|
|
|
# define SIG_DEL(set, signal) sigdelset(&(set), (signal))
|
|
|
|
# define SIG_FILL(set) sigfillset(&set)
|
|
|
|
# define SIGSETMASK(old, new) sigprocmask(SIG_SETMASK, &(new), &(old))
|
|
|
|
# elif defined(sigmask) && !defined(UTS4) && !defined(HURD)
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Use the traditional BSD interface */
|
|
|
|
# define SIGSET_T int
|
|
|
|
# define SIG_DEL(set, signal) (set) &= ~(sigmask(signal))
|
|
|
|
# define SIG_FILL(set) (set) = 0x7fffffff
|
|
|
|
/* Setting the leading bit appears to provoke a bug in some */
|
|
|
|
/* longjmp implementations. Most systems appear not to have */
|
|
|
|
/* a signal 32. */
|
|
|
|
# define SIGSETMASK(old, new) (old) = sigsetmask(new)
|
|
|
|
# else
|
2009-11-30 01:23:45 +01:00
|
|
|
# error undetectable signal API
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
|
|
|
|
static GC_bool mask_initialized = FALSE;
|
|
|
|
|
|
|
|
static SIGSET_T new_mask;
|
|
|
|
|
|
|
|
static SIGSET_T old_mask;
|
|
|
|
|
|
|
|
static SIGSET_T dummy;
|
|
|
|
|
|
|
|
#if defined(PRINTSTATS) && !defined(THREADS)
|
|
|
|
# define CHECK_SIGNALS
|
|
|
|
int GC_sig_disabled = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void GC_disable_signals()
|
|
|
|
{
|
|
|
|
if (!mask_initialized) {
|
|
|
|
SIG_FILL(new_mask);
|
|
|
|
|
|
|
|
SIG_DEL(new_mask, SIGSEGV);
|
|
|
|
SIG_DEL(new_mask, SIGILL);
|
|
|
|
SIG_DEL(new_mask, SIGQUIT);
|
|
|
|
# ifdef SIGBUS
|
|
|
|
SIG_DEL(new_mask, SIGBUS);
|
|
|
|
# endif
|
|
|
|
# ifdef SIGIOT
|
|
|
|
SIG_DEL(new_mask, SIGIOT);
|
|
|
|
# endif
|
|
|
|
# ifdef SIGEMT
|
|
|
|
SIG_DEL(new_mask, SIGEMT);
|
|
|
|
# endif
|
|
|
|
# ifdef SIGTRAP
|
|
|
|
SIG_DEL(new_mask, SIGTRAP);
|
|
|
|
# endif
|
|
|
|
mask_initialized = TRUE;
|
|
|
|
}
|
|
|
|
# ifdef CHECK_SIGNALS
|
|
|
|
if (GC_sig_disabled != 0) ABORT("Nested disables");
|
|
|
|
GC_sig_disabled++;
|
|
|
|
# endif
|
|
|
|
SIGSETMASK(old_mask,new_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GC_enable_signals()
|
|
|
|
{
|
|
|
|
# ifdef CHECK_SIGNALS
|
|
|
|
if (GC_sig_disabled != 1) ABORT("Unmatched enable");
|
|
|
|
GC_sig_disabled--;
|
|
|
|
# endif
|
|
|
|
SIGSETMASK(dummy,old_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* !PCR */
|
|
|
|
|
|
|
|
# endif /*!OS/2 */
|
|
|
|
|
|
|
|
/* Ivan Demakov: simplest way (to me) */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#if defined (DOS4GW)
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_disable_signals() { }
|
|
|
|
void GC_enable_signals() { }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Find the page size */
|
|
|
|
word GC_page_size;
|
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE) || defined (CYGWIN32)
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_setpagesize()
|
|
|
|
{
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
GetSystemInfo(&GC_sysinfo);
|
|
|
|
GC_page_size = GC_sysinfo.dwPageSize;
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# else
|
1999-11-02 00:15:51 +01:00
|
|
|
# if defined(MPROTECT_VDB) || defined(PROC_VDB) || defined(USE_MMAP) \
|
|
|
|
|| defined(USE_MUNMAP)
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_setpagesize()
|
|
|
|
{
|
|
|
|
GC_page_size = GETPAGESIZE();
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
/* It's acceptable to fake it. */
|
|
|
|
void GC_setpagesize()
|
|
|
|
{
|
|
|
|
GC_page_size = HBLKSIZE;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the base of the stack.
|
|
|
|
* Used only in single-threaded environment.
|
|
|
|
* With threads, GC_mark_roots needs to know how to do this.
|
|
|
|
* Called with allocator lock held.
|
|
|
|
*/
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define is_writable(prot) ((prot) == PAGE_READWRITE \
|
|
|
|
|| (prot) == PAGE_WRITECOPY \
|
|
|
|
|| (prot) == PAGE_EXECUTE_READWRITE \
|
|
|
|
|| (prot) == PAGE_EXECUTE_WRITECOPY)
|
|
|
|
/* Return the number of bytes that are writable starting at p. */
|
|
|
|
/* The pointer p is assumed to be page aligned. */
|
|
|
|
/* If base is not 0, *base becomes the beginning of the */
|
|
|
|
/* allocation region containing p. */
|
|
|
|
word GC_get_writable_length(ptr_t p, ptr_t *base)
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION buf;
|
|
|
|
word result;
|
|
|
|
word protect;
|
|
|
|
|
|
|
|
result = VirtualQuery(p, &buf, sizeof(buf));
|
|
|
|
if (result != sizeof(buf)) ABORT("Weird VirtualQuery result");
|
|
|
|
if (base != 0) *base = (ptr_t)(buf.AllocationBase);
|
|
|
|
protect = (buf.Protect & ~(PAGE_GUARD | PAGE_NOCACHE));
|
|
|
|
if (!is_writable(protect)) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if (buf.State != MEM_COMMIT) return(0);
|
|
|
|
return(buf.RegionSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr_t GC_get_stack_base()
|
|
|
|
{
|
|
|
|
int dummy;
|
|
|
|
ptr_t sp = (ptr_t)(&dummy);
|
|
|
|
ptr_t trunc_sp = (ptr_t)((word)sp & ~(GC_page_size - 1));
|
|
|
|
word size = GC_get_writable_length(trunc_sp, 0);
|
|
|
|
|
|
|
|
return(trunc_sp + size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif /* MS Windows */
|
|
|
|
|
|
|
|
# ifdef BEOS
|
|
|
|
# include <kernel/OS.h>
|
|
|
|
ptr_t GC_get_stack_base(){
|
|
|
|
thread_info th;
|
|
|
|
get_thread_info(find_thread(NULL),&th);
|
|
|
|
return th.stack_end;
|
|
|
|
}
|
|
|
|
# endif /* BEOS */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifdef OS2
|
|
|
|
|
|
|
|
ptr_t GC_get_stack_base()
|
|
|
|
{
|
|
|
|
PTIB ptib;
|
|
|
|
PPIB ppib;
|
|
|
|
|
|
|
|
if (DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) {
|
|
|
|
GC_err_printf0("DosGetInfoBlocks failed\n");
|
|
|
|
ABORT("DosGetInfoBlocks failed\n");
|
|
|
|
}
|
|
|
|
return((ptr_t)(ptib -> tib_pstacklimit));
|
|
|
|
}
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif /* OS2 */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifdef AMIGA
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# define GC_AMIGA_SB
|
|
|
|
# include "AmigaOS.c"
|
|
|
|
# undef GC_AMIGA_SB
|
|
|
|
# endif /* AMIGA */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2002-02-09 01:50:05 +01:00
|
|
|
# if defined(NEED_FIND_LIMIT) || defined(UNIX_LIKE)
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifdef __STDC__
|
|
|
|
typedef void (*handler)(int);
|
|
|
|
# else
|
|
|
|
typedef void (*handler)();
|
|
|
|
# endif
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \
|
|
|
|
|| defined(HURD) || defined(NETBSD)
|
1999-04-07 10:01:40 +02:00
|
|
|
static struct sigaction old_segv_act;
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(IRIX5) || defined(HPUX) \
|
2004-08-14 01:05:36 +02:00
|
|
|
|| defined(HURD) || defined(NETBSD)
|
1999-11-02 00:15:51 +01:00
|
|
|
static struct sigaction old_bus_act;
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
|
|
|
static handler old_segv_handler, old_bus_handler;
|
|
|
|
# endif
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifdef __STDC__
|
|
|
|
void GC_set_and_save_fault_handler(handler h)
|
|
|
|
# else
|
|
|
|
void GC_set_and_save_fault_handler(h)
|
|
|
|
handler h;
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(SUNOS5SIGS) || defined(IRIX5) \
|
|
|
|
|| defined(OSF1) || defined(HURD) || defined(NETBSD)
|
1999-04-07 10:01:40 +02:00
|
|
|
struct sigaction act;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
act.sa_handler = h;
|
2004-08-14 01:05:36 +02:00
|
|
|
# if 0 /* Was necessary for Solaris 2.3 and very temporary */
|
|
|
|
/* NetBSD bugs. */
|
2001-08-18 03:04:43 +02:00
|
|
|
act.sa_flags = SA_RESTART | SA_NODEFER;
|
|
|
|
# else
|
|
|
|
act.sa_flags = SA_RESTART;
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
(void) sigemptyset(&act.sa_mask);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_IRIX_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Older versions have a bug related to retrieving and */
|
|
|
|
/* and setting a handler at the same time. */
|
|
|
|
(void) sigaction(SIGSEGV, 0, &old_segv_act);
|
|
|
|
(void) sigaction(SIGSEGV, &act, 0);
|
2006-01-25 04:03:14 +01:00
|
|
|
(void) sigaction(SIGBUS, 0, &old_bus_act);
|
|
|
|
(void) sigaction(SIGBUS, &act, 0);
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
|
|
|
(void) sigaction(SIGSEGV, &act, &old_segv_act);
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(IRIX5) \
|
2004-08-14 01:05:36 +02:00
|
|
|
|| defined(HPUX) || defined(HURD) || defined(NETBSD)
|
1999-11-02 00:15:51 +01:00
|
|
|
/* Under Irix 5.x or HP/UX, we may get SIGBUS. */
|
|
|
|
/* Pthreads doesn't exist under Irix 5.x, so we */
|
|
|
|
/* don't have to worry in the threads case. */
|
1999-04-07 10:01:40 +02:00
|
|
|
(void) sigaction(SIGBUS, &act, &old_bus_act);
|
|
|
|
# endif
|
2001-10-16 11:01:40 +02:00
|
|
|
# endif /* GC_IRIX_THREADS */
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
old_segv_handler = signal(SIGSEGV, h);
|
1999-04-07 10:01:40 +02:00
|
|
|
# ifdef SIGBUS
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
old_bus_handler = signal(SIGBUS, h);
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif /* NEED_FIND_LIMIT || UNIX_LIKE */
|
|
|
|
|
|
|
|
# ifdef NEED_FIND_LIMIT
|
|
|
|
/* Some tools to implement HEURISTIC2 */
|
|
|
|
# define MIN_PAGE_SIZE 256 /* Smallest conceivable page size, bytes */
|
2004-08-14 01:05:36 +02:00
|
|
|
/* static */ JMP_BUF GC_jmp_buf;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void GC_fault_handler(sig)
|
|
|
|
int sig;
|
|
|
|
{
|
2004-08-14 01:05:36 +02:00
|
|
|
LONGJMP(GC_jmp_buf, 1);
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GC_setup_temporary_fault_handler()
|
|
|
|
{
|
|
|
|
GC_set_and_save_fault_handler(GC_fault_handler);
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
void GC_reset_fault_handler()
|
|
|
|
{
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(SUNOS5SIGS) || defined(IRIX5) \
|
|
|
|
|| defined(OSF1) || defined(HURD) || defined(NETBSD)
|
|
|
|
(void) sigaction(SIGSEGV, &old_segv_act, 0);
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(IRIX5) \
|
2004-08-14 01:05:36 +02:00
|
|
|
|| defined(HPUX) || defined(HURD) || defined(NETBSD)
|
|
|
|
(void) sigaction(SIGBUS, &old_bus_act, 0);
|
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
(void) signal(SIGSEGV, old_segv_handler);
|
|
|
|
# ifdef SIGBUS
|
|
|
|
(void) signal(SIGBUS, old_bus_handler);
|
|
|
|
# endif
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the first nonaddressible location > p (up) or */
|
2003-07-28 06:18:23 +02:00
|
|
|
/* the smallest location q s.t. [q,p) is addressable (!up). */
|
|
|
|
/* We assume that p (up) or p-1 (!up) is addressable. */
|
1999-04-07 10:01:40 +02:00
|
|
|
ptr_t GC_find_limit(p, up)
|
|
|
|
ptr_t p;
|
|
|
|
GC_bool up;
|
|
|
|
{
|
2004-08-14 01:05:36 +02:00
|
|
|
static VOLATILE ptr_t result;
|
|
|
|
/* Needs to be static, since otherwise it may not be */
|
|
|
|
/* preserved across the longjmp. Can safely be */
|
|
|
|
/* static since it's only called once, with the */
|
|
|
|
/* allocation lock held. */
|
|
|
|
|
|
|
|
|
|
|
|
GC_setup_temporary_fault_handler();
|
|
|
|
if (SETJMP(GC_jmp_buf) == 0) {
|
|
|
|
result = (ptr_t)(((word)(p))
|
|
|
|
& ~(MIN_PAGE_SIZE-1));
|
|
|
|
for (;;) {
|
|
|
|
if (up) {
|
|
|
|
result += MIN_PAGE_SIZE;
|
|
|
|
} else {
|
|
|
|
result -= MIN_PAGE_SIZE;
|
|
|
|
}
|
|
|
|
GC_noop1((word)(*result));
|
|
|
|
}
|
2002-02-09 01:50:05 +01:00
|
|
|
}
|
2004-08-14 01:05:36 +02:00
|
|
|
GC_reset_fault_handler();
|
|
|
|
if (!up) {
|
|
|
|
result += MIN_PAGE_SIZE;
|
|
|
|
}
|
|
|
|
return(result);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if defined(ECOS) || defined(NOSYS)
|
|
|
|
ptr_t GC_get_stack_base()
|
|
|
|
{
|
|
|
|
return STACKBOTTOM;
|
|
|
|
}
|
|
|
|
#endif
|
1999-11-02 00:15:51 +01:00
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#ifdef HPUX_STACKBOTTOM
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/pstat.h>
|
|
|
|
|
|
|
|
ptr_t GC_get_register_stack_base(void)
|
|
|
|
{
|
|
|
|
struct pst_vm_status vm_status;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
while (pstat_getprocvm(&vm_status, sizeof(vm_status), 0, i++) == 1) {
|
|
|
|
if (vm_status.pst_type == PS_RSESTACK) {
|
|
|
|
return (ptr_t) vm_status.pst_vaddr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* old way to get the register stackbottom */
|
|
|
|
return (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1)
|
|
|
|
& ~(BACKING_STORE_ALIGNMENT - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HPUX_STACK_BOTTOM */
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
#ifdef LINUX_STACKBOTTOM
|
|
|
|
|
2000-05-07 02:43:49 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
# define STAT_SKIP 27 /* Number of fields preceding startstack */
|
2000-04-19 12:10:01 +02:00
|
|
|
/* field in /proc/self/stat */
|
1999-11-02 00:15:51 +01:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
#ifdef USE_LIBC_PRIVATES
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# pragma weak __libc_stack_end
|
|
|
|
extern ptr_t __libc_stack_end;
|
2006-01-25 04:03:14 +01:00
|
|
|
#endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
# ifdef IA64
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Try to read the backing store base from /proc/self/maps. */
|
|
|
|
/* We look for the writable mapping with a 0 major device, */
|
|
|
|
/* which is as close to our frame as possible, but below it.*/
|
|
|
|
static word backing_store_base_from_maps(char *maps)
|
|
|
|
{
|
|
|
|
char prot_buf[5];
|
|
|
|
char *buf_ptr = maps;
|
|
|
|
word start, end;
|
|
|
|
unsigned int maj_dev;
|
|
|
|
word current_best = 0;
|
|
|
|
word dummy;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
buf_ptr = GC_parse_map_entry(buf_ptr, &start, &end, prot_buf, &maj_dev);
|
|
|
|
if (buf_ptr == NULL) return current_best;
|
|
|
|
if (prot_buf[1] == 'w' && maj_dev == 0) {
|
|
|
|
if (end < (word)(&dummy) && start > current_best) current_best = start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return current_best;
|
|
|
|
}
|
|
|
|
|
|
|
|
static word backing_store_base_from_proc(void)
|
|
|
|
{
|
|
|
|
return GC_apply_to_maps(backing_store_base_from_maps);
|
|
|
|
}
|
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
# ifdef USE_LIBC_PRIVATES
|
|
|
|
# pragma weak __libc_ia64_register_backing_store_base
|
|
|
|
extern ptr_t __libc_ia64_register_backing_store_base;
|
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
ptr_t GC_get_register_stack_base(void)
|
|
|
|
{
|
2006-01-25 04:03:14 +01:00
|
|
|
# ifdef USE_LIBC_PRIVATES
|
|
|
|
if (0 != &__libc_ia64_register_backing_store_base
|
|
|
|
&& 0 != __libc_ia64_register_backing_store_base) {
|
|
|
|
/* Glibc 2.2.4 has a bug such that for dynamically linked */
|
|
|
|
/* executables __libc_ia64_register_backing_store_base is */
|
|
|
|
/* defined but uninitialized during constructor calls. */
|
|
|
|
/* Hence we check for both nonzero address and value. */
|
|
|
|
return __libc_ia64_register_backing_store_base;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
word result = backing_store_base_from_proc();
|
|
|
|
if (0 == result) {
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Use dumb heuristics. Works only for default configuration. */
|
|
|
|
result = (word)GC_stackbottom - BACKING_STORE_DISPLACEMENT;
|
|
|
|
result += BACKING_STORE_ALIGNMENT - 1;
|
|
|
|
result &= ~(BACKING_STORE_ALIGNMENT - 1);
|
|
|
|
/* Verify that it's at least readable. If not, we goofed. */
|
|
|
|
GC_noop1(*(word *)result);
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
2006-01-25 04:03:14 +01:00
|
|
|
return (ptr_t)result;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
ptr_t GC_linux_stack_base(void)
|
|
|
|
{
|
2000-05-07 02:43:49 +02:00
|
|
|
/* We read the stack base value from /proc/self/stat. We do this */
|
|
|
|
/* using direct I/O system calls in order to avoid calling malloc */
|
|
|
|
/* in case REDIRECT_MALLOC is defined. */
|
|
|
|
# define STAT_BUF_SIZE 4096
|
2003-07-28 06:18:23 +02:00
|
|
|
# define STAT_READ read
|
|
|
|
/* Should probably call the real read, if read is wrapped. */
|
2000-05-07 02:43:49 +02:00
|
|
|
char stat_buf[STAT_BUF_SIZE];
|
|
|
|
int f;
|
1999-11-02 00:15:51 +01:00
|
|
|
char c;
|
|
|
|
word result = 0;
|
2000-05-07 02:43:49 +02:00
|
|
|
size_t i, buf_offset = 0;
|
1999-11-02 00:15:51 +01:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* First try the easy way. This should work for glibc 2.2 */
|
2004-08-14 01:05:36 +02:00
|
|
|
/* This fails in a prelinked ("prelink" command) executable */
|
|
|
|
/* since the correct value of __libc_stack_end never */
|
|
|
|
/* becomes visible to us. The second test works around */
|
|
|
|
/* this. */
|
2006-01-25 04:03:14 +01:00
|
|
|
# ifdef USE_LIBC_PRIVATES
|
2004-08-14 01:05:36 +02:00
|
|
|
if (0 != &__libc_stack_end && 0 != __libc_stack_end ) {
|
2003-07-28 06:18:23 +02:00
|
|
|
# ifdef IA64
|
|
|
|
/* Some versions of glibc set the address 16 bytes too */
|
|
|
|
/* low while the initialization code is running. */
|
|
|
|
if (((word)__libc_stack_end & 0xfff) + 0x10 < 0x1000) {
|
|
|
|
return __libc_stack_end + 0x10;
|
|
|
|
} /* Otherwise it's not safe to add 16 bytes and we fall */
|
|
|
|
/* back to using /proc. */
|
|
|
|
# else
|
2005-04-18 00:01:21 +02:00
|
|
|
# ifdef SPARC
|
|
|
|
/* Older versions of glibc for 64-bit Sparc do not set
|
|
|
|
* this variable correctly, it gets set to either zero
|
|
|
|
* or one.
|
|
|
|
*/
|
|
|
|
if (__libc_stack_end != (ptr_t) (unsigned long)0x1)
|
|
|
|
return __libc_stack_end;
|
|
|
|
# else
|
2003-07-28 06:18:23 +02:00
|
|
|
return __libc_stack_end;
|
2005-04-18 00:01:21 +02:00
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
2006-01-25 04:03:14 +01:00
|
|
|
# endif
|
2000-05-07 02:43:49 +02:00
|
|
|
f = open("/proc/self/stat", O_RDONLY);
|
2000-05-10 23:59:16 +02:00
|
|
|
if (f < 0 || STAT_READ(f, stat_buf, STAT_BUF_SIZE) < 2 * STAT_SKIP) {
|
2000-05-07 02:43:49 +02:00
|
|
|
ABORT("Couldn't read /proc/self/stat");
|
|
|
|
}
|
|
|
|
c = stat_buf[buf_offset++];
|
1999-11-02 00:15:51 +01:00
|
|
|
/* Skip the required number of fields. This number is hopefully */
|
|
|
|
/* constant across all Linux implementations. */
|
|
|
|
for (i = 0; i < STAT_SKIP; ++i) {
|
2000-05-07 02:43:49 +02:00
|
|
|
while (isspace(c)) c = stat_buf[buf_offset++];
|
|
|
|
while (!isspace(c)) c = stat_buf[buf_offset++];
|
1999-11-02 00:15:51 +01:00
|
|
|
}
|
2000-05-07 02:43:49 +02:00
|
|
|
while (isspace(c)) c = stat_buf[buf_offset++];
|
1999-11-02 00:15:51 +01:00
|
|
|
while (isdigit(c)) {
|
|
|
|
result *= 10;
|
|
|
|
result += c - '0';
|
2000-05-07 02:43:49 +02:00
|
|
|
c = stat_buf[buf_offset++];
|
1999-11-02 00:15:51 +01:00
|
|
|
}
|
2000-05-07 02:43:49 +02:00
|
|
|
close(f);
|
1999-11-02 00:15:51 +01:00
|
|
|
if (result < 0x10000000) ABORT("Absurd stack bottom value");
|
|
|
|
return (ptr_t)result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* LINUX_STACKBOTTOM */
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#ifdef FREEBSD_STACKBOTTOM
|
|
|
|
|
|
|
|
/* This uses an undocumented sysctl call, but at least one expert */
|
|
|
|
/* believes it will stay. */
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
ptr_t GC_freebsd_stack_base(void)
|
|
|
|
{
|
2002-03-22 03:40:32 +01:00
|
|
|
int nm[2] = {CTL_KERN, KERN_USRSTACK};
|
|
|
|
ptr_t base;
|
|
|
|
size_t len = sizeof(ptr_t);
|
|
|
|
int r = sysctl(nm, 2, &base, &len, NULL, 0);
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
if (r) ABORT("Error getting stack base");
|
|
|
|
|
2002-03-22 03:40:32 +01:00
|
|
|
return base;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* FREEBSD_STACKBOTTOM */
|
|
|
|
|
|
|
|
#if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
|
2003-09-22 18:00:23 +02:00
|
|
|
&& !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS)
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
ptr_t GC_get_stack_base()
|
|
|
|
{
|
2003-07-28 06:18:23 +02:00
|
|
|
# if defined(HEURISTIC1) || defined(HEURISTIC2) || \
|
|
|
|
defined(LINUX_STACKBOTTOM) || defined(FREEBSD_STACKBOTTOM)
|
1999-04-07 10:01:40 +02:00
|
|
|
word dummy;
|
|
|
|
ptr_t result;
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# define STACKBOTTOM_ALIGNMENT_M1 ((word)STACK_GRAN - 1)
|
|
|
|
|
|
|
|
# ifdef STACKBOTTOM
|
|
|
|
return(STACKBOTTOM);
|
|
|
|
# else
|
|
|
|
# ifdef HEURISTIC1
|
|
|
|
# ifdef STACK_GROWS_DOWN
|
|
|
|
result = (ptr_t)((((word)(&dummy))
|
|
|
|
+ STACKBOTTOM_ALIGNMENT_M1)
|
|
|
|
& ~STACKBOTTOM_ALIGNMENT_M1);
|
|
|
|
# else
|
|
|
|
result = (ptr_t)(((word)(&dummy))
|
|
|
|
& ~STACKBOTTOM_ALIGNMENT_M1);
|
|
|
|
# endif
|
|
|
|
# endif /* HEURISTIC1 */
|
1999-11-02 00:15:51 +01:00
|
|
|
# ifdef LINUX_STACKBOTTOM
|
|
|
|
result = GC_linux_stack_base();
|
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifdef FREEBSD_STACKBOTTOM
|
|
|
|
result = GC_freebsd_stack_base();
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# ifdef HEURISTIC2
|
|
|
|
# ifdef STACK_GROWS_DOWN
|
|
|
|
result = GC_find_limit((ptr_t)(&dummy), TRUE);
|
|
|
|
# ifdef HEURISTIC2_LIMIT
|
|
|
|
if (result > HEURISTIC2_LIMIT
|
|
|
|
&& (ptr_t)(&dummy) < HEURISTIC2_LIMIT) {
|
|
|
|
result = HEURISTIC2_LIMIT;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
result = GC_find_limit((ptr_t)(&dummy), FALSE);
|
|
|
|
# ifdef HEURISTIC2_LIMIT
|
|
|
|
if (result < HEURISTIC2_LIMIT
|
|
|
|
&& (ptr_t)(&dummy) > HEURISTIC2_LIMIT) {
|
|
|
|
result = HEURISTIC2_LIMIT;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# endif /* HEURISTIC2 */
|
1999-11-02 00:15:51 +01:00
|
|
|
# ifdef STACK_GROWS_DOWN
|
|
|
|
if (result == 0) result = (ptr_t)(signed_word)(-sizeof(ptr_t));
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
return(result);
|
|
|
|
# endif /* STACKBOTTOM */
|
|
|
|
}
|
|
|
|
|
2003-09-22 18:00:23 +02:00
|
|
|
# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register static data segment(s) as roots.
|
|
|
|
* If more data segments are added later then they need to be registered
|
|
|
|
* add that point (as we do with SunOS dynamic loading),
|
|
|
|
* or GC_mark_roots needs to check for them (as we do with PCR).
|
|
|
|
* Called with allocator lock held.
|
|
|
|
*/
|
|
|
|
|
|
|
|
# ifdef OS2
|
|
|
|
|
|
|
|
void GC_register_data_segments()
|
|
|
|
{
|
|
|
|
PTIB ptib;
|
|
|
|
PPIB ppib;
|
|
|
|
HMODULE module_handle;
|
|
|
|
# define PBUFSIZ 512
|
|
|
|
UCHAR path[PBUFSIZ];
|
|
|
|
FILE * myexefile;
|
|
|
|
struct exe_hdr hdrdos; /* MSDOS header. */
|
|
|
|
struct e32_exe hdr386; /* Real header for my executable */
|
|
|
|
struct o32_obj seg; /* Currrent segment */
|
|
|
|
int nsegs;
|
|
|
|
|
|
|
|
|
|
|
|
if (DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) {
|
|
|
|
GC_err_printf0("DosGetInfoBlocks failed\n");
|
|
|
|
ABORT("DosGetInfoBlocks failed\n");
|
|
|
|
}
|
|
|
|
module_handle = ppib -> pib_hmte;
|
|
|
|
if (DosQueryModuleName(module_handle, PBUFSIZ, path) != NO_ERROR) {
|
|
|
|
GC_err_printf0("DosQueryModuleName failed\n");
|
|
|
|
ABORT("DosGetInfoBlocks failed\n");
|
|
|
|
}
|
|
|
|
myexefile = fopen(path, "rb");
|
|
|
|
if (myexefile == 0) {
|
|
|
|
GC_err_puts("Couldn't open executable ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Failed to open executable\n");
|
|
|
|
}
|
|
|
|
if (fread((char *)(&hdrdos), 1, sizeof hdrdos, myexefile) < sizeof hdrdos) {
|
|
|
|
GC_err_puts("Couldn't read MSDOS header from ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Couldn't read MSDOS header");
|
|
|
|
}
|
|
|
|
if (E_MAGIC(hdrdos) != EMAGIC) {
|
|
|
|
GC_err_puts("Executable has wrong DOS magic number: ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Bad DOS magic number");
|
|
|
|
}
|
|
|
|
if (fseek(myexefile, E_LFANEW(hdrdos), SEEK_SET) != 0) {
|
|
|
|
GC_err_puts("Seek to new header failed in ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Bad DOS magic number");
|
|
|
|
}
|
|
|
|
if (fread((char *)(&hdr386), 1, sizeof hdr386, myexefile) < sizeof hdr386) {
|
|
|
|
GC_err_puts("Couldn't read MSDOS header from ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Couldn't read OS/2 header");
|
|
|
|
}
|
|
|
|
if (E32_MAGIC1(hdr386) != E32MAGIC1 || E32_MAGIC2(hdr386) != E32MAGIC2) {
|
|
|
|
GC_err_puts("Executable has wrong OS/2 magic number:");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Bad OS/2 magic number");
|
|
|
|
}
|
|
|
|
if ( E32_BORDER(hdr386) != E32LEBO || E32_WORDER(hdr386) != E32LEWO) {
|
|
|
|
GC_err_puts("Executable %s has wrong byte order: ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Bad byte order");
|
|
|
|
}
|
|
|
|
if ( E32_CPU(hdr386) == E32CPU286) {
|
|
|
|
GC_err_puts("GC can't handle 80286 executables: ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
EXIT();
|
|
|
|
}
|
|
|
|
if (fseek(myexefile, E_LFANEW(hdrdos) + E32_OBJTAB(hdr386),
|
|
|
|
SEEK_SET) != 0) {
|
|
|
|
GC_err_puts("Seek to object table failed: ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Seek to object table failed");
|
|
|
|
}
|
|
|
|
for (nsegs = E32_OBJCNT(hdr386); nsegs > 0; nsegs--) {
|
|
|
|
int flags;
|
|
|
|
if (fread((char *)(&seg), 1, sizeof seg, myexefile) < sizeof seg) {
|
|
|
|
GC_err_puts("Couldn't read obj table entry from ");
|
|
|
|
GC_err_puts(path); GC_err_puts("\n");
|
|
|
|
ABORT("Couldn't read obj table entry");
|
|
|
|
}
|
|
|
|
flags = O32_FLAGS(seg);
|
|
|
|
if (!(flags & OBJWRITE)) continue;
|
|
|
|
if (!(flags & OBJREAD)) continue;
|
|
|
|
if (flags & OBJINVALID) {
|
|
|
|
GC_err_printf0("Object with invalid pages?\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
GC_add_roots_inner(O32_BASE(seg), O32_BASE(seg)+O32_SIZE(seg), FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# else /* !OS2 */
|
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE) || defined (CYGWIN32)
|
|
|
|
|
|
|
|
# ifdef CYGWIN32
|
|
|
|
# define GC_no_win32_dlls (FALSE)
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifdef MSWIN32
|
|
|
|
/* Unfortunately, we have to handle win32s very differently from NT, */
|
|
|
|
/* Since VirtualQuery has very different semantics. In particular, */
|
|
|
|
/* under win32s a VirtualQuery call on an unmapped page returns an */
|
2003-07-28 06:18:23 +02:00
|
|
|
/* invalid result. Under NT, GC_register_data_segments is a noop and */
|
1999-04-07 10:01:40 +02:00
|
|
|
/* all real work is done by GC_register_dynamic_libraries. Under */
|
|
|
|
/* win32s, we cannot find the data segments associated with dll's. */
|
2003-07-28 06:18:23 +02:00
|
|
|
/* We register the main data segment here. */
|
2002-03-12 20:06:36 +01:00
|
|
|
GC_bool GC_no_win32_dlls = FALSE;
|
2003-07-28 06:18:23 +02:00
|
|
|
/* This used to be set for gcc, to avoid dealing with */
|
|
|
|
/* the structured exception handling issues. But we now have */
|
|
|
|
/* assembly code to do that right. */
|
2006-06-20 19:10:19 +02:00
|
|
|
GC_bool GC_wnt = FALSE;
|
|
|
|
/* This is a Windows NT derivative, i.e. NT, W2K, XP or later. */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
void GC_init_win32()
|
|
|
|
{
|
2002-03-12 20:06:36 +01:00
|
|
|
/* if we're running under win32s, assume that no DLLs will be loaded */
|
|
|
|
DWORD v = GetVersion();
|
2006-06-20 19:10:19 +02:00
|
|
|
GC_wnt = !(v & 0x80000000);
|
|
|
|
GC_no_win32_dlls |= ((!GC_wnt) && (v & 0xff) <= 3);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Return the smallest address a such that VirtualQuery */
|
|
|
|
/* returns correct results for all addresses between a and start. */
|
|
|
|
/* Assumes VirtualQuery returns correct information for start. */
|
|
|
|
ptr_t GC_least_described_address(ptr_t start)
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION buf;
|
|
|
|
DWORD result;
|
|
|
|
LPVOID limit;
|
|
|
|
ptr_t p;
|
|
|
|
LPVOID q;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
limit = GC_sysinfo.lpMinimumApplicationAddress;
|
1999-04-07 10:01:40 +02:00
|
|
|
p = (ptr_t)((word)start & ~(GC_page_size - 1));
|
|
|
|
for (;;) {
|
|
|
|
q = (LPVOID)(p - GC_page_size);
|
|
|
|
if ((ptr_t)q > (ptr_t)p /* underflow */ || q < limit) break;
|
|
|
|
result = VirtualQuery(q, &buf, sizeof(buf));
|
|
|
|
if (result != sizeof(buf) || buf.AllocationBase == 0) break;
|
|
|
|
p = (ptr_t)(buf.AllocationBase);
|
|
|
|
}
|
|
|
|
return(p);
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
# ifndef REDIRECT_MALLOC
|
|
|
|
/* We maintain a linked list of AllocationBase values that we know */
|
|
|
|
/* correspond to malloc heap sections. Currently this is only called */
|
|
|
|
/* during a GC. But there is some hope that for long running */
|
|
|
|
/* programs we will eventually see most heap sections. */
|
|
|
|
|
|
|
|
/* In the long run, it would be more reliable to occasionally walk */
|
|
|
|
/* the malloc heap with HeapWalk on the default heap. But that */
|
|
|
|
/* apparently works only for NT-based Windows. */
|
|
|
|
|
|
|
|
/* In the long run, a better data structure would also be nice ... */
|
|
|
|
struct GC_malloc_heap_list {
|
|
|
|
void * allocation_base;
|
|
|
|
struct GC_malloc_heap_list *next;
|
|
|
|
} *GC_malloc_heap_l = 0;
|
|
|
|
|
|
|
|
/* Is p the base of one of the malloc heap sections we already know */
|
|
|
|
/* about? */
|
|
|
|
GC_bool GC_is_malloc_heap_base(ptr_t p)
|
|
|
|
{
|
|
|
|
struct GC_malloc_heap_list *q = GC_malloc_heap_l;
|
|
|
|
|
|
|
|
while (0 != q) {
|
|
|
|
if (q -> allocation_base == p) return TRUE;
|
|
|
|
q = q -> next;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *GC_get_allocation_base(void *p)
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION buf;
|
|
|
|
DWORD result = VirtualQuery(p, &buf, sizeof(buf));
|
|
|
|
if (result != sizeof(buf)) {
|
|
|
|
ABORT("Weird VirtualQuery result");
|
|
|
|
}
|
|
|
|
return buf.AllocationBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t GC_max_root_size = 100000; /* Appr. largest root size. */
|
|
|
|
|
|
|
|
void GC_add_current_malloc_heap()
|
|
|
|
{
|
|
|
|
struct GC_malloc_heap_list *new_l =
|
|
|
|
malloc(sizeof(struct GC_malloc_heap_list));
|
|
|
|
void * candidate = GC_get_allocation_base(new_l);
|
|
|
|
|
|
|
|
if (new_l == 0) return;
|
|
|
|
if (GC_is_malloc_heap_base(candidate)) {
|
|
|
|
/* Try a little harder to find malloc heap. */
|
|
|
|
size_t req_size = 10000;
|
|
|
|
do {
|
|
|
|
void *p = malloc(req_size);
|
|
|
|
if (0 == p) { free(new_l); return; }
|
|
|
|
candidate = GC_get_allocation_base(p);
|
|
|
|
free(p);
|
|
|
|
req_size *= 2;
|
|
|
|
} while (GC_is_malloc_heap_base(candidate)
|
|
|
|
&& req_size < GC_max_root_size/10 && req_size < 500000);
|
|
|
|
if (GC_is_malloc_heap_base(candidate)) {
|
|
|
|
free(new_l); return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# ifdef CONDPRINT
|
|
|
|
if (GC_print_stats)
|
|
|
|
GC_printf1("Found new system malloc AllocationBase at 0x%lx\n",
|
|
|
|
candidate);
|
|
|
|
# endif
|
|
|
|
new_l -> allocation_base = candidate;
|
|
|
|
new_l -> next = GC_malloc_heap_l;
|
|
|
|
GC_malloc_heap_l = new_l;
|
|
|
|
}
|
|
|
|
# endif /* REDIRECT_MALLOC */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
/* Is p the start of either the malloc heap, or of one of our */
|
|
|
|
/* heap sections? */
|
|
|
|
GC_bool GC_is_heap_base (ptr_t p)
|
|
|
|
{
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
unsigned i;
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifndef REDIRECT_MALLOC
|
2003-07-28 06:18:23 +02:00
|
|
|
static word last_gc_no = -1;
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
if (last_gc_no != GC_gc_no) {
|
|
|
|
GC_add_current_malloc_heap();
|
|
|
|
last_gc_no = GC_gc_no;
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
if (GC_root_size > GC_max_root_size) GC_max_root_size = GC_root_size;
|
|
|
|
if (GC_is_malloc_heap_base(p)) return TRUE;
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
for (i = 0; i < GC_n_heap_bases; i++) {
|
2003-07-28 06:18:23 +02:00
|
|
|
if (GC_heap_bases[i] == p) return TRUE;
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
return FALSE ;
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
# ifdef MSWIN32
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_register_root_section(ptr_t static_root)
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION buf;
|
|
|
|
DWORD result;
|
|
|
|
DWORD protect;
|
|
|
|
LPVOID p;
|
|
|
|
char * base;
|
|
|
|
char * limit, * new_limit;
|
|
|
|
|
2002-03-12 20:06:36 +01:00
|
|
|
if (!GC_no_win32_dlls) return;
|
1999-04-07 10:01:40 +02:00
|
|
|
p = base = limit = GC_least_described_address(static_root);
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
while (p < GC_sysinfo.lpMaximumApplicationAddress) {
|
1999-04-07 10:01:40 +02:00
|
|
|
result = VirtualQuery(p, &buf, sizeof(buf));
|
|
|
|
if (result != sizeof(buf) || buf.AllocationBase == 0
|
|
|
|
|| GC_is_heap_base(buf.AllocationBase)) break;
|
|
|
|
new_limit = (char *)p + buf.RegionSize;
|
|
|
|
protect = buf.Protect;
|
|
|
|
if (buf.State == MEM_COMMIT
|
|
|
|
&& is_writable(protect)) {
|
|
|
|
if ((char *)p == limit) {
|
|
|
|
limit = new_limit;
|
|
|
|
} else {
|
|
|
|
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
|
|
|
|
base = p;
|
|
|
|
limit = new_limit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p > (LPVOID)new_limit /* overflow */) break;
|
|
|
|
p = (LPVOID)new_limit;
|
|
|
|
}
|
|
|
|
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
void GC_register_data_segments()
|
|
|
|
{
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifdef MSWIN32
|
1999-04-07 10:01:40 +02:00
|
|
|
static char dummy;
|
|
|
|
GC_register_root_section((ptr_t)(&dummy));
|
1999-11-02 00:15:51 +01:00
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# else /* !OS2 && !Windows */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2000-04-27 02:43:33 +02:00
|
|
|
# if (defined(SVR4) || defined(AUX) || defined(DGUX) \
|
|
|
|
|| (defined(LINUX) && defined(SPARC))) && !defined(PCR)
|
2003-07-28 06:18:23 +02:00
|
|
|
ptr_t GC_SysVGetDataStart(max_page_size, etext_addr)
|
1999-04-07 10:01:40 +02:00
|
|
|
int max_page_size;
|
|
|
|
int * etext_addr;
|
|
|
|
{
|
|
|
|
word text_end = ((word)(etext_addr) + sizeof(word) - 1)
|
|
|
|
& ~(sizeof(word) - 1);
|
|
|
|
/* etext rounded to word boundary */
|
|
|
|
word next_page = ((text_end + (word)max_page_size - 1)
|
|
|
|
& ~((word)max_page_size - 1));
|
|
|
|
word page_offset = (text_end & ((word)max_page_size - 1));
|
|
|
|
VOLATILE char * result = (char *)(next_page + page_offset);
|
|
|
|
/* Note that this isnt equivalent to just adding */
|
|
|
|
/* max_page_size to &etext if &etext is at a page boundary */
|
|
|
|
|
|
|
|
GC_setup_temporary_fault_handler();
|
2004-08-14 01:05:36 +02:00
|
|
|
if (SETJMP(GC_jmp_buf) == 0) {
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Try writing to the address. */
|
|
|
|
*result = *result;
|
|
|
|
GC_reset_fault_handler();
|
|
|
|
} else {
|
|
|
|
GC_reset_fault_handler();
|
|
|
|
/* We got here via a longjmp. The address is not readable. */
|
|
|
|
/* This is known to happen under Solaris 2.4 + gcc, which place */
|
|
|
|
/* string constants in the text segment, but after etext. */
|
|
|
|
/* Use plan B. Note that we now know there is a gap between */
|
|
|
|
/* text and data segments, so plan A bought us something. */
|
2003-07-28 06:18:23 +02:00
|
|
|
result = (char *)GC_find_limit((ptr_t)(DATAEND), FALSE);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
return((ptr_t)result);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
2007-01-16 20:38:59 +01:00
|
|
|
# if defined(FREEBSD) && (defined(I386) || defined(X86_64) || defined(powerpc) || defined(__powerpc__)) && !defined(PCR)
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Its unclear whether this should be identical to the above, or */
|
|
|
|
/* whether it should apply to non-X86 architectures. */
|
|
|
|
/* For now we don't assume that there is always an empty page after */
|
|
|
|
/* etext. But in some cases there actually seems to be slightly more. */
|
|
|
|
/* This also deals with holes between read-only data and writable data. */
|
|
|
|
ptr_t GC_FreeBSDGetDataStart(max_page_size, etext_addr)
|
|
|
|
int max_page_size;
|
|
|
|
int * etext_addr;
|
|
|
|
{
|
|
|
|
word text_end = ((word)(etext_addr) + sizeof(word) - 1)
|
|
|
|
& ~(sizeof(word) - 1);
|
|
|
|
/* etext rounded to word boundary */
|
|
|
|
VOLATILE word next_page = (text_end + (word)max_page_size - 1)
|
|
|
|
& ~((word)max_page_size - 1);
|
|
|
|
VOLATILE ptr_t result = (ptr_t)text_end;
|
|
|
|
GC_setup_temporary_fault_handler();
|
2004-08-14 01:05:36 +02:00
|
|
|
if (SETJMP(GC_jmp_buf) == 0) {
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Try reading at the address. */
|
|
|
|
/* This should happen before there is another thread. */
|
|
|
|
for (; next_page < (word)(DATAEND); next_page += (word)max_page_size)
|
|
|
|
*(VOLATILE char *)next_page;
|
|
|
|
GC_reset_fault_handler();
|
|
|
|
} else {
|
|
|
|
GC_reset_fault_handler();
|
|
|
|
/* As above, we go to plan B */
|
|
|
|
result = GC_find_limit((ptr_t)(DATAEND), FALSE);
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#ifdef AMIGA
|
|
|
|
|
|
|
|
# define GC_AMIGA_DS
|
|
|
|
# include "AmigaOS.c"
|
|
|
|
# undef GC_AMIGA_DS
|
|
|
|
|
|
|
|
#else /* !OS2 && !Windows && !AMIGA */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_register_data_segments()
|
|
|
|
{
|
2003-07-28 06:18:23 +02:00
|
|
|
# if !defined(PCR) && !defined(SRC_M3) && !defined(MACOS)
|
2001-10-16 11:01:40 +02:00
|
|
|
# if defined(REDIRECT_MALLOC) && defined(GC_SOLARIS_THREADS)
|
1999-04-07 10:01:40 +02:00
|
|
|
/* As of Solaris 2.3, the Solaris threads implementation */
|
|
|
|
/* allocates the data structure for the initial thread with */
|
|
|
|
/* sbrk at process startup. It needs to be scanned, so that */
|
|
|
|
/* we don't lose some malloc allocated data structures */
|
|
|
|
/* hanging from it. We're on thin ice here ... */
|
|
|
|
extern caddr_t sbrk();
|
|
|
|
|
|
|
|
GC_add_roots_inner(DATASTART, (char *)sbrk(0), FALSE);
|
|
|
|
# else
|
|
|
|
GC_add_roots_inner(DATASTART, (char *)(DATAEND), FALSE);
|
2002-02-12 05:37:57 +01:00
|
|
|
# if defined(DATASTART2)
|
|
|
|
GC_add_roots_inner(DATASTART2, (char *)(DATAEND2), FALSE);
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# if defined(MACOS)
|
|
|
|
{
|
|
|
|
# if defined(THINK_C)
|
|
|
|
extern void* GC_MacGetDataStart(void);
|
|
|
|
/* globals begin above stack and end at a5. */
|
|
|
|
GC_add_roots_inner((ptr_t)GC_MacGetDataStart(),
|
|
|
|
(ptr_t)LMGetCurrentA5(), FALSE);
|
|
|
|
# else
|
|
|
|
# if defined(__MWERKS__)
|
|
|
|
# if !__POWERPC__
|
|
|
|
extern void* GC_MacGetDataStart(void);
|
1999-11-02 00:15:51 +01:00
|
|
|
/* MATTHEW: Function to handle Far Globals (CW Pro 3) */
|
|
|
|
# if __option(far_data)
|
|
|
|
extern void* GC_MacGetDataEnd(void);
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
/* globals begin above stack and end at a5. */
|
|
|
|
GC_add_roots_inner((ptr_t)GC_MacGetDataStart(),
|
|
|
|
(ptr_t)LMGetCurrentA5(), FALSE);
|
1999-11-02 00:15:51 +01:00
|
|
|
/* MATTHEW: Handle Far Globals */
|
|
|
|
# if __option(far_data)
|
|
|
|
/* Far globals follow he QD globals: */
|
|
|
|
GC_add_roots_inner((ptr_t)LMGetCurrentA5(),
|
|
|
|
(ptr_t)GC_MacGetDataEnd(), FALSE);
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
|
|
|
extern char __data_start__[], __data_end__[];
|
|
|
|
GC_add_roots_inner((ptr_t)&__data_start__,
|
|
|
|
(ptr_t)&__data_end__, FALSE);
|
|
|
|
# endif /* __POWERPC__ */
|
|
|
|
# endif /* __MWERKS__ */
|
|
|
|
# endif /* !THINK_C */
|
|
|
|
}
|
|
|
|
# endif /* MACOS */
|
|
|
|
|
|
|
|
/* Dynamic libraries are added at every collection, since they may */
|
|
|
|
/* change. */
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* ! AMIGA */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif /* ! MSWIN32 && ! MSWINCE*/
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif /* ! OS2 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Auxiliary routines for obtaining memory from OS.
|
|
|
|
*/
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
&& !defined(MSWIN32) && !defined(MSWINCE) \
|
|
|
|
&& !defined(MACOS) && !defined(DOS4GW)
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# ifdef SUNOS4
|
|
|
|
extern caddr_t sbrk();
|
|
|
|
# endif
|
|
|
|
# ifdef __STDC__
|
|
|
|
# define SBRK_ARG_T ptrdiff_t
|
|
|
|
# else
|
|
|
|
# define SBRK_ARG_T int
|
|
|
|
# endif
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
# if 0 && defined(RS6000) /* We now use mmap */
|
1999-04-07 10:01:40 +02:00
|
|
|
/* The compiler seems to generate speculative reads one past the end of */
|
|
|
|
/* an allocated object. Hence we need to make sure that the page */
|
|
|
|
/* following the last heap page is also mapped. */
|
|
|
|
ptr_t GC_unix_get_mem(bytes)
|
|
|
|
word bytes;
|
|
|
|
{
|
|
|
|
caddr_t cur_brk = (caddr_t)sbrk(0);
|
|
|
|
caddr_t result;
|
|
|
|
SBRK_ARG_T lsbs = (word)cur_brk & (GC_page_size-1);
|
|
|
|
static caddr_t my_brk_val = 0;
|
|
|
|
|
|
|
|
if ((SBRK_ARG_T)bytes < 0) return(0); /* too big */
|
|
|
|
if (lsbs != 0) {
|
|
|
|
if((caddr_t)(sbrk(GC_page_size - lsbs)) == (caddr_t)(-1)) return(0);
|
|
|
|
}
|
|
|
|
if (cur_brk == my_brk_val) {
|
|
|
|
/* Use the extra block we allocated last time. */
|
|
|
|
result = (ptr_t)sbrk((SBRK_ARG_T)bytes);
|
|
|
|
if (result == (caddr_t)(-1)) return(0);
|
|
|
|
result -= GC_page_size;
|
|
|
|
} else {
|
|
|
|
result = (ptr_t)sbrk(GC_page_size + (SBRK_ARG_T)bytes);
|
|
|
|
if (result == (caddr_t)(-1)) return(0);
|
|
|
|
}
|
|
|
|
my_brk_val = result + bytes + GC_page_size; /* Always page aligned */
|
|
|
|
return((ptr_t)result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* Not RS6000 */
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#if defined(USE_MMAP) || defined(USE_MUNMAP)
|
1999-11-02 00:15:51 +01:00
|
|
|
|
|
|
|
#ifdef USE_MMAP_FIXED
|
|
|
|
# define GC_MMAP_FLAGS MAP_FIXED | MAP_PRIVATE
|
|
|
|
/* Seems to yield better performance on Solaris 2, but can */
|
|
|
|
/* be unreliable if something is already mapped at the address. */
|
|
|
|
#else
|
|
|
|
# define GC_MMAP_FLAGS MAP_PRIVATE
|
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#ifdef USE_MMAP_ANON
|
|
|
|
# define zero_fd -1
|
|
|
|
# if defined(MAP_ANONYMOUS)
|
|
|
|
# define OPT_MAP_ANON MAP_ANONYMOUS
|
|
|
|
# else
|
|
|
|
# define OPT_MAP_ANON MAP_ANON
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
static int zero_fd;
|
|
|
|
# define OPT_MAP_ANON 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* defined(USE_MMAP) || defined(USE_MUNMAP) */
|
|
|
|
|
|
|
|
#if defined(USE_MMAP)
|
|
|
|
/* Tested only under Linux, IRIX5 and Solaris 2 */
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#ifndef HEAP_START
|
|
|
|
# define HEAP_START 0
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
ptr_t GC_unix_get_mem(bytes)
|
|
|
|
word bytes;
|
|
|
|
{
|
|
|
|
void *result;
|
|
|
|
static ptr_t last_addr = HEAP_START;
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
# ifndef USE_MMAP_ANON
|
|
|
|
static GC_bool initialized = FALSE;
|
|
|
|
|
|
|
|
if (!initialized) {
|
2004-08-14 01:05:36 +02:00
|
|
|
zero_fd = open("/dev/zero", O_RDONLY);
|
|
|
|
fcntl(zero_fd, F_SETFD, FD_CLOEXEC);
|
2003-07-28 06:18:23 +02:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
if (bytes & (GC_page_size -1)) ABORT("Bad GET_MEM arg");
|
2004-08-14 01:05:36 +02:00
|
|
|
result = mmap(last_addr, bytes, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
|
|
|
|
GC_MMAP_FLAGS | OPT_MAP_ANON, zero_fd, 0/* offset */);
|
1999-04-07 10:01:40 +02:00
|
|
|
if (result == MAP_FAILED) return(0);
|
|
|
|
last_addr = (ptr_t)result + bytes + GC_page_size - 1;
|
|
|
|
last_addr = (ptr_t)((word)last_addr & ~(GC_page_size - 1));
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if !defined(LINUX)
|
|
|
|
if (last_addr == 0) {
|
|
|
|
/* Oops. We got the end of the address space. This isn't */
|
|
|
|
/* usable by arbitrary C code, since one-past-end pointers */
|
|
|
|
/* don't work, so we discard it and try again. */
|
|
|
|
munmap(result, (size_t)(-GC_page_size) - (size_t)result);
|
|
|
|
/* Leave last page mapped, so we can't repeat. */
|
|
|
|
return GC_unix_get_mem(bytes);
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
GC_ASSERT(last_addr != 0);
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
return((ptr_t)result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* Not RS6000, not USE_MMAP */
|
|
|
|
ptr_t GC_unix_get_mem(bytes)
|
|
|
|
word bytes;
|
|
|
|
{
|
|
|
|
ptr_t result;
|
|
|
|
# ifdef IRIX5
|
|
|
|
/* Bare sbrk isn't thread safe. Play by malloc rules. */
|
|
|
|
/* The equivalent may be needed on other systems as well. */
|
|
|
|
__LOCK_MALLOC();
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
ptr_t cur_brk = (ptr_t)sbrk(0);
|
|
|
|
SBRK_ARG_T lsbs = (word)cur_brk & (GC_page_size-1);
|
|
|
|
|
|
|
|
if ((SBRK_ARG_T)bytes < 0) return(0); /* too big */
|
|
|
|
if (lsbs != 0) {
|
|
|
|
if((ptr_t)sbrk(GC_page_size - lsbs) == (ptr_t)(-1)) return(0);
|
|
|
|
}
|
|
|
|
result = (ptr_t)sbrk((SBRK_ARG_T)bytes);
|
|
|
|
if (result == (ptr_t)(-1)) result = 0;
|
|
|
|
}
|
|
|
|
# ifdef IRIX5
|
|
|
|
__UNLOCK_MALLOC();
|
|
|
|
# endif
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Not USE_MMAP */
|
|
|
|
#endif /* Not RS6000 */
|
|
|
|
|
|
|
|
# endif /* UN*X */
|
|
|
|
|
|
|
|
# ifdef OS2
|
|
|
|
|
|
|
|
void * os2_alloc(size_t bytes)
|
|
|
|
{
|
|
|
|
void * result;
|
|
|
|
|
|
|
|
if (DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ |
|
|
|
|
PAG_WRITE | PAG_COMMIT)
|
|
|
|
!= NO_ERROR) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if (result == 0) return(os2_alloc(bytes));
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* OS2 */
|
|
|
|
|
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
SYSTEM_INFO GC_sysinfo;
|
|
|
|
# endif
|
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
# if defined(MSWIN32) || defined(CYGWIN32)
|
|
|
|
|
|
|
|
word GC_n_heap_bases = 0;
|
2002-02-12 05:37:57 +01:00
|
|
|
|
|
|
|
# ifdef USE_GLOBAL_ALLOC
|
|
|
|
# define GLOBAL_ALLOC_TEST 1
|
|
|
|
# else
|
2002-03-12 20:06:36 +01:00
|
|
|
# define GLOBAL_ALLOC_TEST GC_no_win32_dlls
|
2002-02-12 05:37:57 +01:00
|
|
|
# endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
ptr_t GC_win32_get_mem(bytes)
|
|
|
|
word bytes;
|
|
|
|
{
|
|
|
|
ptr_t result;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
2010-03-21 20:34:19 +01:00
|
|
|
# ifdef CYGWIN32
|
|
|
|
result = GC_unix_get_mem (bytes);
|
|
|
|
# else
|
2002-02-12 05:37:57 +01:00
|
|
|
if (GLOBAL_ALLOC_TEST) {
|
1999-04-07 10:01:40 +02:00
|
|
|
/* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */
|
|
|
|
/* There are also unconfirmed rumors of other */
|
|
|
|
/* problems, so we dodge the issue. */
|
|
|
|
result = (ptr_t) GlobalAlloc(0, bytes + HBLKSIZE);
|
|
|
|
result = (ptr_t)(((word)result + HBLKSIZE) & ~(HBLKSIZE-1));
|
|
|
|
} else {
|
2003-07-28 06:18:23 +02:00
|
|
|
/* VirtualProtect only works on regions returned by a */
|
|
|
|
/* single VirtualAlloc call. Thus we allocate one */
|
|
|
|
/* extra page, which will prevent merging of blocks */
|
|
|
|
/* in separate regions, and eliminate any temptation */
|
|
|
|
/* to call VirtualProtect on a range spanning regions. */
|
|
|
|
/* This wastes a small amount of memory, and risks */
|
|
|
|
/* increased fragmentation. But better alternatives */
|
|
|
|
/* would require effort. */
|
|
|
|
result = (ptr_t) VirtualAlloc(NULL, bytes + 1,
|
1999-04-07 10:01:40 +02:00
|
|
|
MEM_COMMIT | MEM_RESERVE,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
}
|
2010-03-21 20:34:19 +01:00
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
|
|
|
|
/* If I read the documentation correctly, this can */
|
|
|
|
/* only happen if HBLKSIZE > 64k or not a power of 2. */
|
|
|
|
if (GC_n_heap_bases >= MAX_HEAP_SECTS) ABORT("Too many heap sections");
|
|
|
|
GC_heap_bases[GC_n_heap_bases++] = result;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
void GC_win32_free_heap ()
|
|
|
|
{
|
2002-03-12 20:06:36 +01:00
|
|
|
if (GC_no_win32_dlls) {
|
1999-11-02 00:15:51 +01:00
|
|
|
while (GC_n_heap_bases > 0) {
|
2010-03-21 20:34:19 +01:00
|
|
|
# ifdef CYGWIN32
|
|
|
|
free (GC_heap_bases[--GC_n_heap_bases]);
|
|
|
|
# else
|
1999-11-02 00:15:51 +01:00
|
|
|
GlobalFree (GC_heap_bases[--GC_n_heap_bases]);
|
2010-03-21 20:34:19 +01:00
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
GC_heap_bases[GC_n_heap_bases] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif
|
|
|
|
|
|
|
|
#ifdef AMIGA
|
|
|
|
# define GC_AMIGA_AM
|
|
|
|
# include "AmigaOS.c"
|
|
|
|
# undef GC_AMIGA_AM
|
|
|
|
#endif
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifdef MSWINCE
|
|
|
|
word GC_n_heap_bases = 0;
|
|
|
|
|
|
|
|
ptr_t GC_wince_get_mem(bytes)
|
|
|
|
word bytes;
|
|
|
|
{
|
|
|
|
ptr_t result;
|
|
|
|
word i;
|
|
|
|
|
|
|
|
/* Round up allocation size to multiple of page size */
|
|
|
|
bytes = (bytes + GC_page_size-1) & ~(GC_page_size-1);
|
|
|
|
|
|
|
|
/* Try to find reserved, uncommitted pages */
|
|
|
|
for (i = 0; i < GC_n_heap_bases; i++) {
|
|
|
|
if (((word)(-(signed_word)GC_heap_lengths[i])
|
|
|
|
& (GC_sysinfo.dwAllocationGranularity-1))
|
|
|
|
>= bytes) {
|
|
|
|
result = GC_heap_bases[i] + GC_heap_lengths[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == GC_n_heap_bases) {
|
|
|
|
/* Reserve more pages */
|
|
|
|
word res_bytes = (bytes + GC_sysinfo.dwAllocationGranularity-1)
|
|
|
|
& ~(GC_sysinfo.dwAllocationGranularity-1);
|
2003-07-28 06:18:23 +02:00
|
|
|
/* If we ever support MPROTECT_VDB here, we will probably need to */
|
|
|
|
/* ensure that res_bytes is strictly > bytes, so that VirtualProtect */
|
|
|
|
/* never spans regions. It seems to be OK for a VirtualFree argument */
|
|
|
|
/* to span regions, so we should be OK for now. */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
result = (ptr_t) VirtualAlloc(NULL, res_bytes,
|
|
|
|
MEM_RESERVE | MEM_TOP_DOWN,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
|
|
|
|
/* If I read the documentation correctly, this can */
|
|
|
|
/* only happen if HBLKSIZE > 64k or not a power of 2. */
|
|
|
|
if (GC_n_heap_bases >= MAX_HEAP_SECTS) ABORT("Too many heap sections");
|
|
|
|
GC_heap_bases[GC_n_heap_bases] = result;
|
|
|
|
GC_heap_lengths[GC_n_heap_bases] = 0;
|
|
|
|
GC_n_heap_bases++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Commit pages */
|
|
|
|
result = (ptr_t) VirtualAlloc(result, bytes,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (result != NULL) {
|
|
|
|
if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
|
|
|
|
GC_heap_lengths[i] += bytes;
|
|
|
|
}
|
1999-11-02 00:15:51 +01:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
return(result);
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
#ifdef USE_MUNMAP
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* For now, this only works on Win32/WinCE and some Unix-like */
|
|
|
|
/* systems. If you have something else, don't define */
|
|
|
|
/* USE_MUNMAP. */
|
1999-11-02 00:15:51 +01:00
|
|
|
/* We assume ANSI C to support this feature. */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
#if !defined(MSWIN32) && !defined(MSWINCE)
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
#endif
|
1999-11-02 00:15:51 +01:00
|
|
|
|
|
|
|
/* Compute a page aligned starting address for the unmap */
|
|
|
|
/* operation on a block of size bytes starting at start. */
|
|
|
|
/* Return 0 if the block is too small to make this feasible. */
|
|
|
|
ptr_t GC_unmap_start(ptr_t start, word bytes)
|
|
|
|
{
|
|
|
|
ptr_t result = start;
|
|
|
|
/* Round start to next page boundary. */
|
|
|
|
result += GC_page_size - 1;
|
|
|
|
result = (ptr_t)((word)result & ~(GC_page_size - 1));
|
|
|
|
if (result + GC_page_size > start + bytes) return 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute end address for an unmap operation on the indicated */
|
|
|
|
/* block. */
|
|
|
|
ptr_t GC_unmap_end(ptr_t start, word bytes)
|
|
|
|
{
|
|
|
|
ptr_t end_addr = start + bytes;
|
|
|
|
end_addr = (ptr_t)((word)end_addr & ~(GC_page_size - 1));
|
|
|
|
return end_addr;
|
|
|
|
}
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* Under Win32/WinCE we commit (map) and decommit (unmap) */
|
|
|
|
/* memory using VirtualAlloc and VirtualFree. These functions */
|
|
|
|
/* work on individual allocations of virtual memory, made */
|
|
|
|
/* previously using VirtualAlloc with the MEM_RESERVE flag. */
|
|
|
|
/* The ranges we need to (de)commit may span several of these */
|
|
|
|
/* allocations; therefore we use VirtualQuery to check */
|
|
|
|
/* allocation lengths, and split up the range as necessary. */
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
/* We assume that GC_remap is called on exactly the same range */
|
|
|
|
/* as a previous call to GC_unmap. It is safe to consistently */
|
|
|
|
/* round the endpoints in both places. */
|
|
|
|
void GC_unmap(ptr_t start, word bytes)
|
|
|
|
{
|
|
|
|
ptr_t start_addr = GC_unmap_start(start, bytes);
|
|
|
|
ptr_t end_addr = GC_unmap_end(start, bytes);
|
|
|
|
word len = end_addr - start_addr;
|
|
|
|
if (0 == start_addr) return;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
|
|
|
while (len != 0) {
|
|
|
|
MEMORY_BASIC_INFORMATION mem_info;
|
|
|
|
GC_word free_len;
|
|
|
|
if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
|
|
|
|
!= sizeof(mem_info))
|
|
|
|
ABORT("Weird VirtualQuery result");
|
|
|
|
free_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
|
|
|
|
if (!VirtualFree(start_addr, free_len, MEM_DECOMMIT))
|
|
|
|
ABORT("VirtualFree failed");
|
|
|
|
GC_unmapped_bytes += free_len;
|
|
|
|
start_addr += free_len;
|
|
|
|
len -= free_len;
|
|
|
|
}
|
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
/* We immediately remap it to prevent an intervening mmap from */
|
|
|
|
/* accidentally grabbing the same address space. */
|
|
|
|
{
|
|
|
|
void * result;
|
|
|
|
result = mmap(start_addr, len, PROT_NONE,
|
|
|
|
MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
|
|
|
|
zero_fd, 0/* offset */);
|
|
|
|
if (result != (void *)start_addr) ABORT("mmap(...PROT_NONE...) failed");
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
GC_unmapped_bytes += len;
|
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GC_remap(ptr_t start, word bytes)
|
|
|
|
{
|
|
|
|
ptr_t start_addr = GC_unmap_start(start, bytes);
|
|
|
|
ptr_t end_addr = GC_unmap_end(start, bytes);
|
|
|
|
word len = end_addr - start_addr;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
2004-08-14 01:05:36 +02:00
|
|
|
ptr_t result;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
if (0 == start_addr) return;
|
|
|
|
while (len != 0) {
|
|
|
|
MEMORY_BASIC_INFORMATION mem_info;
|
|
|
|
GC_word alloc_len;
|
|
|
|
if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
|
|
|
|
!= sizeof(mem_info))
|
|
|
|
ABORT("Weird VirtualQuery result");
|
|
|
|
alloc_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
|
|
|
|
result = VirtualAlloc(start_addr, alloc_len,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (result != start_addr) {
|
|
|
|
ABORT("VirtualAlloc remapping failed");
|
|
|
|
}
|
|
|
|
GC_unmapped_bytes -= alloc_len;
|
|
|
|
start_addr += alloc_len;
|
|
|
|
len -= alloc_len;
|
|
|
|
}
|
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
/* It was already remapped with PROT_NONE. */
|
|
|
|
int result;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
if (0 == start_addr) return;
|
2004-08-14 01:05:36 +02:00
|
|
|
result = mprotect(start_addr, len,
|
|
|
|
PROT_READ | PROT_WRITE | OPT_PROT_EXEC);
|
|
|
|
if (result != 0) {
|
|
|
|
GC_err_printf3(
|
|
|
|
"Mprotect failed at 0x%lx (length %ld) with errno %ld\n",
|
|
|
|
start_addr, len, errno);
|
|
|
|
ABORT("Mprotect remapping failed");
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
|
|
|
GC_unmapped_bytes -= len;
|
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Two adjacent blocks have already been unmapped and are about to */
|
|
|
|
/* be merged. Unmap the whole block. This typically requires */
|
|
|
|
/* that we unmap a small section in the middle that was not previously */
|
|
|
|
/* unmapped due to alignment constraints. */
|
|
|
|
void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2)
|
|
|
|
{
|
|
|
|
ptr_t start1_addr = GC_unmap_start(start1, bytes1);
|
|
|
|
ptr_t end1_addr = GC_unmap_end(start1, bytes1);
|
|
|
|
ptr_t start2_addr = GC_unmap_start(start2, bytes2);
|
|
|
|
ptr_t end2_addr = GC_unmap_end(start2, bytes2);
|
|
|
|
ptr_t start_addr = end1_addr;
|
|
|
|
ptr_t end_addr = start2_addr;
|
|
|
|
word len;
|
|
|
|
GC_ASSERT(start1 + bytes1 == start2);
|
|
|
|
if (0 == start1_addr) start_addr = GC_unmap_start(start1, bytes1 + bytes2);
|
|
|
|
if (0 == start2_addr) end_addr = GC_unmap_end(start1, bytes1 + bytes2);
|
|
|
|
if (0 == start_addr) return;
|
|
|
|
len = end_addr - start_addr;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
|
|
|
while (len != 0) {
|
|
|
|
MEMORY_BASIC_INFORMATION mem_info;
|
|
|
|
GC_word free_len;
|
|
|
|
if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
|
|
|
|
!= sizeof(mem_info))
|
|
|
|
ABORT("Weird VirtualQuery result");
|
|
|
|
free_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
|
|
|
|
if (!VirtualFree(start_addr, free_len, MEM_DECOMMIT))
|
|
|
|
ABORT("VirtualFree failed");
|
|
|
|
GC_unmapped_bytes += free_len;
|
|
|
|
start_addr += free_len;
|
|
|
|
len -= free_len;
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
if (len != 0 && munmap(start_addr, len) != 0) ABORT("munmap failed");
|
|
|
|
GC_unmapped_bytes += len;
|
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* USE_MUNMAP */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Routine for pushing any additional roots. In THREADS */
|
|
|
|
/* environment, this is also responsible for marking from */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* thread stacks. */
|
1999-04-07 10:01:40 +02:00
|
|
|
#ifndef THREADS
|
|
|
|
void (*GC_push_other_roots)() = 0;
|
|
|
|
#else /* THREADS */
|
|
|
|
|
|
|
|
# ifdef PCR
|
|
|
|
PCR_ERes GC_push_thread_stack(PCR_Th_T *t, PCR_Any dummy)
|
|
|
|
{
|
|
|
|
struct PCR_ThCtl_TInfoRep info;
|
|
|
|
PCR_ERes result;
|
|
|
|
|
|
|
|
info.ti_stkLow = info.ti_stkHi = 0;
|
|
|
|
result = PCR_ThCtl_GetInfo(t, &info);
|
|
|
|
GC_push_all_stack((ptr_t)(info.ti_stkLow), (ptr_t)(info.ti_stkHi));
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Push the contents of an old object. We treat this as stack */
|
|
|
|
/* data only becasue that makes it robust against mark stack */
|
|
|
|
/* overflow. */
|
|
|
|
PCR_ERes GC_push_old_obj(void *p, size_t size, PCR_Any data)
|
|
|
|
{
|
|
|
|
GC_push_all_stack((ptr_t)p, (ptr_t)p + size);
|
|
|
|
return(PCR_ERes_okay);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void GC_default_push_other_roots GC_PROTO((void))
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
/* Traverse data allocated by previous memory managers. */
|
|
|
|
{
|
|
|
|
extern struct PCR_MM_ProcsRep * GC_old_allocator;
|
|
|
|
|
|
|
|
if ((*(GC_old_allocator->mmp_enumerate))(PCR_Bool_false,
|
|
|
|
GC_push_old_obj, 0)
|
|
|
|
!= PCR_ERes_okay) {
|
|
|
|
ABORT("Old object enumeration failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Traverse all thread stacks. */
|
|
|
|
if (PCR_ERes_IsErr(
|
|
|
|
PCR_ThCtl_ApplyToAllOtherThreads(GC_push_thread_stack,0))
|
|
|
|
|| PCR_ERes_IsErr(GC_push_thread_stack(PCR_Th_CurrThread(), 0))) {
|
|
|
|
ABORT("Thread stack marking failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* PCR */
|
|
|
|
|
|
|
|
# ifdef SRC_M3
|
|
|
|
|
|
|
|
# ifdef ALL_INTERIOR_POINTERS
|
|
|
|
--> misconfigured
|
|
|
|
# endif
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void GC_push_thread_structures GC_PROTO((void))
|
|
|
|
{
|
|
|
|
/* Not our responsibibility. */
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
extern void ThreadF__ProcessStacks();
|
|
|
|
|
|
|
|
void GC_push_thread_stack(start, stop)
|
|
|
|
word start, stop;
|
|
|
|
{
|
|
|
|
GC_push_all_stack((ptr_t)start, (ptr_t)stop + sizeof(word));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Push routine with M3 specific calling convention. */
|
|
|
|
GC_m3_push_root(dummy1, p, dummy2, dummy3)
|
|
|
|
word *p;
|
|
|
|
ptr_t dummy1, dummy2;
|
|
|
|
int dummy3;
|
|
|
|
{
|
|
|
|
word q = *p;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
GC_PUSH_ONE_STACK(q, p);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* M3 set equivalent to RTHeap.TracedRefTypes */
|
|
|
|
typedef struct { int elts[1]; } RefTypeSet;
|
|
|
|
RefTypeSet GC_TracedRefTypes = {{0x1}};
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void GC_default_push_other_roots GC_PROTO((void))
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* Use the M3 provided routine for finding static roots. */
|
|
|
|
/* This is a bit dubious, since it presumes no C roots. */
|
|
|
|
/* We handle the collector roots explicitly in GC_push_roots */
|
|
|
|
RTMain__GlobalMapProc(GC_m3_push_root, 0, GC_TracedRefTypes);
|
1999-04-07 10:01:40 +02:00
|
|
|
if (GC_words_allocd > 0) {
|
|
|
|
ThreadF__ProcessStacks(GC_push_thread_stack);
|
|
|
|
}
|
|
|
|
/* Otherwise this isn't absolutely necessary, and we have */
|
|
|
|
/* startup ordering problems. */
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* SRC_M3 */
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
# if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS) || \
|
|
|
|
defined(GC_WIN32_THREADS)
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
extern void GC_push_all_stacks();
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void GC_default_push_other_roots GC_PROTO((void))
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
GC_push_all_stacks();
|
|
|
|
}
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
# endif /* GC_SOLARIS_THREADS || GC_PTHREADS */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void (*GC_push_other_roots) GC_PROTO((void)) = GC_default_push_other_roots;
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
#endif /* THREADS */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines for accessing dirty bits on virtual pages.
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
* We plan to eventually implement four strategies for doing so:
|
1999-04-07 10:01:40 +02:00
|
|
|
* DEFAULT_VDB: A simple dummy implementation that treats every page
|
|
|
|
* as possibly dirty. This makes incremental collection
|
|
|
|
* useless, but the implementation is still correct.
|
|
|
|
* PCR_VDB: Use PPCRs virtual dirty bit facility.
|
|
|
|
* PROC_VDB: Use the /proc facility for reading dirty bits. Only
|
|
|
|
* works under some SVR4 variants. Even then, it may be
|
|
|
|
* too slow to be entirely satisfactory. Requires reading
|
|
|
|
* dirty bits for entire address space. Implementations tend
|
|
|
|
* to assume that the client is a (slow) debugger.
|
|
|
|
* MPROTECT_VDB:Protect pages and then catch the faults to keep track of
|
|
|
|
* dirtied pages. The implementation (and implementability)
|
|
|
|
* is highly system dependent. This usually fails when system
|
|
|
|
* calls write to a protected page. We prevent the read system
|
|
|
|
* call from doing so. It is the clients responsibility to
|
|
|
|
* make sure that other system calls are similarly protected
|
|
|
|
* or write only to the stack.
|
|
|
|
*/
|
|
|
|
GC_bool GC_dirty_maintained = FALSE;
|
|
|
|
|
|
|
|
# ifdef DEFAULT_VDB
|
|
|
|
|
|
|
|
/* All of the following assume the allocation lock is held, and */
|
|
|
|
/* signals are disabled. */
|
|
|
|
|
|
|
|
/* The client asserts that unallocated pages in the heap are never */
|
|
|
|
/* written. */
|
|
|
|
|
|
|
|
/* Initialize virtual dirty bit implementation. */
|
|
|
|
void GC_dirty_init()
|
|
|
|
{
|
2003-07-28 06:18:23 +02:00
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_printf0("Initializing DEFAULT_VDB...\n");
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
GC_dirty_maintained = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Retrieve system dirty bits for heap to a local buffer. */
|
|
|
|
/* Restore the systems notion of which pages are dirty. */
|
|
|
|
void GC_read_dirty()
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* Is the HBLKSIZE sized page at h marked dirty in the local buffer? */
|
|
|
|
/* If the actual page size is different, this returns TRUE if any */
|
|
|
|
/* of the pages overlapping h are dirty. This routine may err on the */
|
|
|
|
/* side of labelling pages as dirty (and this implementation does). */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
GC_bool GC_page_was_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following two routines are typically less crucial. They matter
|
|
|
|
* most with large dynamic libraries, or if we can't accurately identify
|
|
|
|
* stacks, e.g. under Solaris 2.X. Otherwise the following default
|
|
|
|
* versions are adequate.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Could any valid GC heap pointer ever have been written to this page? */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
GC_bool GC_page_was_ever_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the n pages starting at h to "was never dirty" status. */
|
|
|
|
void GC_is_fresh(h, n)
|
|
|
|
struct hblk *h;
|
|
|
|
word n;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
/* A call that: */
|
|
|
|
/* I) hints that [h, h+nblocks) is about to be written. */
|
|
|
|
/* II) guarantees that protection is removed. */
|
|
|
|
/* (I) may speed up some dirty bit implementations. */
|
|
|
|
/* (II) may be essential if we need to ensure that */
|
|
|
|
/* pointer-free system call buffers in the heap are */
|
|
|
|
/* not protected. */
|
1999-04-07 10:01:40 +02:00
|
|
|
/*ARGSUSED*/
|
2002-02-12 05:37:57 +01:00
|
|
|
void GC_remove_protection(h, nblocks, is_ptrfree)
|
1999-04-07 10:01:40 +02:00
|
|
|
struct hblk *h;
|
2002-02-12 05:37:57 +01:00
|
|
|
word nblocks;
|
|
|
|
GC_bool is_ptrfree;
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* DEFAULT_VDB */
|
|
|
|
|
|
|
|
|
|
|
|
# ifdef MPROTECT_VDB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See DEFAULT_VDB for interface descriptions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This implementation maintains dirty bits itself by catching write
|
|
|
|
* faults and keeping track of them. We assume nobody else catches
|
2003-07-28 06:18:23 +02:00
|
|
|
* SIGBUS or SIGSEGV. We assume no write faults occur in system calls.
|
|
|
|
* This means that clients must ensure that system calls don't write
|
|
|
|
* to the write-protected heap. Probably the best way to do this is to
|
|
|
|
* ensure that system calls write at most to POINTERFREE objects in the
|
|
|
|
* heap, and do even that only if we are on a platform on which those
|
|
|
|
* are not protected. Another alternative is to wrap system calls
|
|
|
|
* (see example for read below), but the current implementation holds
|
|
|
|
* a lock across blocking calls, making it problematic for multithreaded
|
|
|
|
* applications.
|
1999-04-07 10:01:40 +02:00
|
|
|
* We assume the page size is a multiple of HBLKSIZE.
|
2003-07-28 06:18:23 +02:00
|
|
|
* We prefer them to be the same. We avoid protecting POINTERFREE
|
|
|
|
* objects only if they are the same.
|
1999-04-07 10:01:40 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(DARWIN)
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
# include <sys/mman.h>
|
|
|
|
# include <signal.h>
|
|
|
|
# include <sys/syscall.h>
|
|
|
|
|
|
|
|
# define PROTECT(addr, len) \
|
1999-11-02 00:15:51 +01:00
|
|
|
if (mprotect((caddr_t)(addr), (size_t)(len), \
|
1999-04-07 10:01:40 +02:00
|
|
|
PROT_READ | OPT_PROT_EXEC) < 0) { \
|
|
|
|
ABORT("mprotect failed"); \
|
|
|
|
}
|
|
|
|
# define UNPROTECT(addr, len) \
|
1999-11-02 00:15:51 +01:00
|
|
|
if (mprotect((caddr_t)(addr), (size_t)(len), \
|
1999-04-07 10:01:40 +02:00
|
|
|
PROT_WRITE | PROT_READ | OPT_PROT_EXEC ) < 0) { \
|
|
|
|
ABORT("un-mprotect failed"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
# ifdef DARWIN
|
|
|
|
/* Using vm_protect (mach syscall) over mprotect (BSD syscall) seems to
|
|
|
|
decrease the likelihood of some of the problems described below. */
|
|
|
|
#include <mach/vm_map.h>
|
2004-07-07 05:08:14 +02:00
|
|
|
static mach_port_t GC_task_self;
|
2003-07-28 06:18:23 +02:00
|
|
|
#define PROTECT(addr,len) \
|
|
|
|
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
|
|
|
|
FALSE,VM_PROT_READ) != KERN_SUCCESS) { \
|
|
|
|
ABORT("vm_portect failed"); \
|
|
|
|
}
|
|
|
|
#define UNPROTECT(addr,len) \
|
|
|
|
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
|
|
|
|
FALSE,VM_PROT_READ|VM_PROT_WRITE) != KERN_SUCCESS) { \
|
|
|
|
ABORT("vm_portect failed"); \
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifndef MSWINCE
|
|
|
|
# include <signal.h>
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
static DWORD protect_junk;
|
|
|
|
# define PROTECT(addr, len) \
|
|
|
|
if (!VirtualProtect((addr), (len), PAGE_EXECUTE_READ, \
|
|
|
|
&protect_junk)) { \
|
|
|
|
DWORD last_error = GetLastError(); \
|
|
|
|
GC_printf1("Last error code: %lx\n", last_error); \
|
|
|
|
ABORT("VirtualProtect failed"); \
|
|
|
|
}
|
|
|
|
# define UNPROTECT(addr, len) \
|
|
|
|
if (!VirtualProtect((addr), (len), PAGE_EXECUTE_READWRITE, \
|
|
|
|
&protect_junk)) { \
|
|
|
|
ABORT("un-VirtualProtect failed"); \
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* !DARWIN */
|
|
|
|
# endif /* MSWIN32 || MSWINCE || DARWIN */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#if defined(SUNOS4) || (defined(FREEBSD) && !defined(SUNOS5SIGS))
|
1999-04-07 10:01:40 +02:00
|
|
|
typedef void (* SIG_PF)();
|
2004-08-14 01:05:36 +02:00
|
|
|
#endif /* SUNOS4 || (FREEBSD && !SUNOS5SIGS) */
|
2003-07-28 06:18:23 +02:00
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) \
|
2003-07-28 06:18:23 +02:00
|
|
|
|| defined(HURD)
|
1999-11-02 00:15:51 +01:00
|
|
|
# ifdef __STDC__
|
1999-04-07 10:01:40 +02:00
|
|
|
typedef void (* SIG_PF)(int);
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
|
|
|
typedef void (* SIG_PF)();
|
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* SUNOS5SIGS || OSF1 || LINUX || HURD */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#if defined(MSWIN32)
|
|
|
|
typedef LPTOP_LEVEL_EXCEPTION_FILTER SIG_PF;
|
|
|
|
# undef SIG_DFL
|
|
|
|
# define SIG_DFL (LPTOP_LEVEL_EXCEPTION_FILTER) (-1)
|
|
|
|
#endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#if defined(MSWINCE)
|
|
|
|
typedef LONG (WINAPI *SIG_PF)(struct _EXCEPTION_POINTERS *);
|
|
|
|
# undef SIG_DFL
|
|
|
|
# define SIG_DFL (SIG_PF) (-1)
|
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
#if defined(IRIX5) || defined(OSF1) || defined(HURD)
|
1999-04-07 10:01:40 +02:00
|
|
|
typedef void (* REAL_SIG_PF)(int, int, struct sigcontext *);
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* IRIX5 || OSF1 || HURD */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#if defined(SUNOS5SIGS)
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(HPUX) || defined(FREEBSD)
|
|
|
|
# define SIGINFO_T siginfo_t
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# define SIGINFO_T struct siginfo
|
1999-11-02 00:15:51 +01:00
|
|
|
# endif
|
|
|
|
# ifdef __STDC__
|
2004-08-14 01:05:36 +02:00
|
|
|
typedef void (* REAL_SIG_PF)(int, SIGINFO_T *, void *);
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
|
|
|
typedef void (* REAL_SIG_PF)();
|
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* SUNOS5SIGS */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#if defined(LINUX)
|
2002-02-12 05:37:57 +01:00
|
|
|
# if __GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2
|
1999-11-02 00:15:51 +01:00
|
|
|
typedef struct sigcontext s_c;
|
2002-02-12 05:37:57 +01:00
|
|
|
# else /* glibc < 2.2 */
|
|
|
|
# include <linux/version.h>
|
2003-07-28 06:18:23 +02:00
|
|
|
# if (LINUX_VERSION_CODE >= 0x20100) && !defined(M68K) || defined(ALPHA) || defined(ARM32)
|
2002-02-12 05:37:57 +01:00
|
|
|
typedef struct sigcontext s_c;
|
|
|
|
# else
|
|
|
|
typedef struct sigcontext_struct s_c;
|
|
|
|
# endif
|
|
|
|
# endif /* glibc < 2.2 */
|
1999-11-02 00:15:51 +01:00
|
|
|
# if defined(ALPHA) || defined(M68K)
|
|
|
|
typedef void (* REAL_SIG_PF)(int, int, s_c *);
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(IA64) || defined(HP_PA) || defined(X86_64)
|
1999-11-02 00:15:51 +01:00
|
|
|
typedef void (* REAL_SIG_PF)(int, siginfo_t *, s_c *);
|
2004-08-14 01:05:36 +02:00
|
|
|
/* FIXME: */
|
|
|
|
/* According to SUSV3, the last argument should have type */
|
|
|
|
/* void * or ucontext_t * */
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
|
|
|
typedef void (* REAL_SIG_PF)(int, s_c);
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
# ifdef ALPHA
|
|
|
|
/* Retrieve fault address from sigcontext structure by decoding */
|
|
|
|
/* instruction. */
|
|
|
|
char * get_fault_addr(s_c *sc) {
|
|
|
|
unsigned instr;
|
|
|
|
word faultaddr;
|
|
|
|
|
|
|
|
instr = *((unsigned *)(sc->sc_pc));
|
|
|
|
faultaddr = sc->sc_regs[(instr >> 16) & 0x1f];
|
|
|
|
faultaddr += (word) (((int)instr << 16) >> 16);
|
|
|
|
return (char *)faultaddr;
|
|
|
|
}
|
|
|
|
# endif /* !ALPHA */
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* LINUX */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#ifndef DARWIN
|
1999-04-07 10:01:40 +02:00
|
|
|
SIG_PF GC_old_bus_handler;
|
|
|
|
SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* !DARWIN */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if defined(THREADS)
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* We need to lock around the bitmap update in the write fault handler */
|
|
|
|
/* in order to avoid the risk of losing a bit. We do this with a */
|
|
|
|
/* test-and-set spin lock if we know how to do that. Otherwise we */
|
|
|
|
/* check whether we are already in the handler and use the dumb but */
|
|
|
|
/* safe fallback algorithm of setting all bits in the word. */
|
|
|
|
/* Contention should be very rare, so we do the minimum to handle it */
|
|
|
|
/* correctly. */
|
|
|
|
#ifdef GC_TEST_AND_SET_DEFINED
|
|
|
|
static VOLATILE unsigned int fault_handler_lock = 0;
|
|
|
|
void async_set_pht_entry_from_index(VOLATILE page_hash_table db, int index) {
|
2001-08-18 03:04:43 +02:00
|
|
|
while (GC_test_and_set(&fault_handler_lock)) {}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* Could also revert to set_pht_entry_from_index_safe if initial */
|
|
|
|
/* GC_test_and_set fails. */
|
|
|
|
set_pht_entry_from_index(db, index);
|
|
|
|
GC_clear(&fault_handler_lock);
|
|
|
|
}
|
|
|
|
#else /* !GC_TEST_AND_SET_DEFINED */
|
|
|
|
/* THIS IS INCORRECT! The dirty bit vector may be temporarily wrong, */
|
|
|
|
/* just before we notice the conflict and correct it. We may end up */
|
|
|
|
/* looking at it while it's wrong. But this requires contention */
|
|
|
|
/* exactly when a GC is triggered, which seems far less likely to */
|
|
|
|
/* fail than the old code, which had no reported failures. Thus we */
|
|
|
|
/* leave it this way while we think of something better, or support */
|
|
|
|
/* GC_test_and_set on the remaining platforms. */
|
|
|
|
static VOLATILE word currently_updating = 0;
|
|
|
|
void async_set_pht_entry_from_index(VOLATILE page_hash_table db, int index) {
|
|
|
|
unsigned int update_dummy;
|
|
|
|
currently_updating = (word)(&update_dummy);
|
|
|
|
set_pht_entry_from_index(db, index);
|
|
|
|
/* If we get contention in the 10 or so instruction window here, */
|
|
|
|
/* and we get stopped by a GC between the two updates, we lose! */
|
|
|
|
if (currently_updating != (word)(&update_dummy)) {
|
|
|
|
set_pht_entry_from_index_safe(db, index);
|
|
|
|
/* We claim that if two threads concurrently try to update the */
|
|
|
|
/* dirty bit vector, the first one to execute UPDATE_START */
|
|
|
|
/* will see it changed when UPDATE_END is executed. (Note that */
|
|
|
|
/* &update_dummy must differ in two distinct threads.) It */
|
|
|
|
/* will then execute set_pht_entry_from_index_safe, thus */
|
|
|
|
/* returning us to a safe state, though not soon enough. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* !GC_TEST_AND_SET_DEFINED */
|
|
|
|
#else /* !THREADS */
|
|
|
|
# define async_set_pht_entry_from_index(db, index) \
|
|
|
|
set_pht_entry_from_index(db, index)
|
|
|
|
#endif /* !THREADS */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/*ARGSUSED*/
|
2003-07-28 06:18:23 +02:00
|
|
|
#if !defined(DARWIN)
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined (SUNOS4) || (defined(FREEBSD) && !defined(SUNOS5SIGS))
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_write_fault_handler(sig, code, scp, addr)
|
|
|
|
int sig, code;
|
|
|
|
struct sigcontext *scp;
|
|
|
|
char * addr;
|
|
|
|
# ifdef SUNOS4
|
|
|
|
# define SIG_OK (sig == SIGSEGV || sig == SIGBUS)
|
|
|
|
# define CODE_OK (FC_CODE(code) == FC_PROT \
|
|
|
|
|| (FC_CODE(code) == FC_OBJERR \
|
|
|
|
&& FC_ERRNO(code) == FC_PROT))
|
|
|
|
# endif
|
|
|
|
# ifdef FREEBSD
|
|
|
|
# define SIG_OK (sig == SIGBUS)
|
2006-01-25 04:03:14 +01:00
|
|
|
# define CODE_OK TRUE
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
2004-08-14 01:05:36 +02:00
|
|
|
# endif /* SUNOS4 || (FREEBSD && !SUNOS5SIGS) */
|
2003-07-28 06:18:23 +02:00
|
|
|
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(IRIX5) || defined(OSF1) || defined(HURD)
|
1999-04-07 10:01:40 +02:00
|
|
|
# include <errno.h>
|
|
|
|
void GC_write_fault_handler(int sig, int code, struct sigcontext *scp)
|
|
|
|
# ifdef OSF1
|
2001-08-18 03:04:43 +02:00
|
|
|
# define SIG_OK (sig == SIGSEGV)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define CODE_OK (code == 2 /* experimentally determined */)
|
|
|
|
# endif
|
|
|
|
# ifdef IRIX5
|
2001-08-18 03:04:43 +02:00
|
|
|
# define SIG_OK (sig == SIGSEGV)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define CODE_OK (code == EACCES)
|
|
|
|
# endif
|
2001-08-18 03:04:43 +02:00
|
|
|
# ifdef HURD
|
|
|
|
# define SIG_OK (sig == SIGBUS || sig == SIGSEGV)
|
|
|
|
# define CODE_OK TRUE
|
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* IRIX5 || OSF1 || HURD */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
# if defined(LINUX)
|
1999-11-02 00:15:51 +01:00
|
|
|
# if defined(ALPHA) || defined(M68K)
|
|
|
|
void GC_write_fault_handler(int sig, int code, s_c * sc)
|
1999-04-07 10:01:40 +02:00
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(IA64) || defined(HP_PA) || defined(X86_64)
|
1999-11-02 00:15:51 +01:00
|
|
|
void GC_write_fault_handler(int sig, siginfo_t * si, s_c * scp)
|
|
|
|
# else
|
2003-07-28 06:18:23 +02:00
|
|
|
# if defined(ARM32)
|
|
|
|
void GC_write_fault_handler(int sig, int a2, int a3, int a4, s_c sc)
|
|
|
|
# else
|
|
|
|
void GC_write_fault_handler(int sig, s_c sc)
|
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
# define SIG_OK (sig == SIGSEGV)
|
|
|
|
# define CODE_OK TRUE
|
1999-11-02 00:15:51 +01:00
|
|
|
/* Empirically c.trapno == 14, on IA32, but is that useful? */
|
|
|
|
/* Should probably consider alignment issues on other */
|
|
|
|
/* architectures. */
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* LINUX */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
# if defined(SUNOS5SIGS)
|
1999-11-02 00:15:51 +01:00
|
|
|
# ifdef __STDC__
|
2004-08-14 01:05:36 +02:00
|
|
|
void GC_write_fault_handler(int sig, SIGINFO_T *scp, void * context)
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
|
|
|
void GC_write_fault_handler(sig, scp, context)
|
|
|
|
int sig;
|
2004-08-14 01:05:36 +02:00
|
|
|
SIGINFO_T *scp;
|
1999-11-02 00:15:51 +01:00
|
|
|
void * context;
|
|
|
|
# endif
|
|
|
|
# ifdef HPUX
|
|
|
|
# define SIG_OK (sig == SIGSEGV || sig == SIGBUS)
|
|
|
|
# define CODE_OK (scp -> si_code == SEGV_ACCERR) \
|
|
|
|
|| (scp -> si_code == BUS_ADRERR) \
|
|
|
|
|| (scp -> si_code == BUS_UNKNOWN) \
|
|
|
|
|| (scp -> si_code == SEGV_UNKNOWN) \
|
|
|
|
|| (scp -> si_code == BUS_OBJERR)
|
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# ifdef FREEBSD
|
|
|
|
# define SIG_OK (sig == SIGBUS)
|
|
|
|
# define CODE_OK (scp -> si_code == BUS_PAGE_FAULT)
|
|
|
|
# else
|
|
|
|
# define SIG_OK (sig == SIGSEGV)
|
|
|
|
# define CODE_OK (scp -> si_code == SEGV_ACCERR)
|
|
|
|
# endif
|
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* SUNOS5SIGS */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info)
|
|
|
|
# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode == \
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
STATUS_ACCESS_VIOLATION)
|
1999-04-07 10:01:40 +02:00
|
|
|
# define CODE_OK (exc_info -> ExceptionRecord -> ExceptionInformation[0] == 1)
|
|
|
|
/* Write fault */
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif /* MSWIN32 || MSWINCE */
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
register unsigned i;
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(HURD)
|
|
|
|
char *addr = (char *) code;
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# ifdef IRIX5
|
|
|
|
char * addr = (char *) (size_t) (scp -> sc_badvaddr);
|
|
|
|
# endif
|
|
|
|
# if defined(OSF1) && defined(ALPHA)
|
|
|
|
char * addr = (char *) (scp -> sc_traparg_a0);
|
|
|
|
# endif
|
|
|
|
# ifdef SUNOS5SIGS
|
|
|
|
char * addr = (char *) (scp -> si_addr);
|
|
|
|
# endif
|
|
|
|
# ifdef LINUX
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(I386)
|
1999-04-07 10:01:40 +02:00
|
|
|
char * addr = (char *) (sc.cr2);
|
|
|
|
# else
|
1999-11-02 00:15:51 +01:00
|
|
|
# if defined(M68K)
|
|
|
|
char * addr = NULL;
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
struct sigcontext *scp = (struct sigcontext *)(sc);
|
1999-11-02 00:15:51 +01:00
|
|
|
|
|
|
|
int format = (scp->sc_formatvec >> 12) & 0xf;
|
|
|
|
unsigned long *framedata = (unsigned long *)(scp + 1);
|
|
|
|
unsigned long ea;
|
|
|
|
|
|
|
|
if (format == 0xa || format == 0xb) {
|
|
|
|
/* 68020/030 */
|
|
|
|
ea = framedata[2];
|
|
|
|
} else if (format == 7) {
|
|
|
|
/* 68040 */
|
|
|
|
ea = framedata[3];
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
if (framedata[1] & 0x08000000) {
|
|
|
|
/* correct addr on misaligned access */
|
|
|
|
ea = (ea+4095)&(~4095);
|
|
|
|
}
|
1999-11-02 00:15:51 +01:00
|
|
|
} else if (format == 4) {
|
|
|
|
/* 68060 */
|
|
|
|
ea = framedata[0];
|
|
|
|
if (framedata[1] & 0x08000000) {
|
|
|
|
/* correct addr on misaligned access */
|
|
|
|
ea = (ea+4095)&(~4095);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addr = (char *)ea;
|
|
|
|
# else
|
|
|
|
# ifdef ALPHA
|
|
|
|
char * addr = get_fault_addr(sc);
|
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(IA64) || defined(HP_PA) || defined(X86_64)
|
1999-11-02 00:15:51 +01:00
|
|
|
char * addr = si -> si_addr;
|
2000-04-19 12:10:01 +02:00
|
|
|
/* I believe this is claimed to work on all platforms for */
|
|
|
|
/* Linux 2.3.47 and later. Hopefully we don't have to */
|
|
|
|
/* worry about earlier kernels on IA64. */
|
1999-11-02 00:15:51 +01:00
|
|
|
# else
|
|
|
|
# if defined(POWERPC)
|
|
|
|
char * addr = (char *) (sc.regs->dar);
|
|
|
|
# else
|
2003-07-28 06:18:23 +02:00
|
|
|
# if defined(ARM32)
|
|
|
|
char * addr = (char *)sc.fault_address;
|
|
|
|
# else
|
2005-04-19 18:01:38 +02:00
|
|
|
# if defined(CRIS)
|
|
|
|
char * addr = (char *)sc.regs.csraddr;
|
|
|
|
# else
|
|
|
|
--> architecture not supported
|
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
# endif
|
1999-11-02 00:15:51 +01:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
char * addr = (char *) (exc_info -> ExceptionRecord
|
|
|
|
-> ExceptionInformation[1]);
|
|
|
|
# define sig SIGSEGV
|
|
|
|
# endif
|
|
|
|
|
|
|
|
if (SIG_OK && CODE_OK) {
|
|
|
|
register struct hblk * h =
|
|
|
|
(struct hblk *)((word)addr & ~(GC_page_size-1));
|
|
|
|
GC_bool in_allocd_block;
|
|
|
|
|
|
|
|
# ifdef SUNOS5SIGS
|
|
|
|
/* Address is only within the correct physical page. */
|
|
|
|
in_allocd_block = FALSE;
|
|
|
|
for (i = 0; i < divHBLKSZ(GC_page_size); i++) {
|
|
|
|
if (HDR(h+i) != 0) {
|
|
|
|
in_allocd_block = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
in_allocd_block = (HDR(addr) != 0);
|
|
|
|
# endif
|
|
|
|
if (!in_allocd_block) {
|
2004-08-14 01:05:36 +02:00
|
|
|
/* FIXME - We should make sure that we invoke the */
|
|
|
|
/* old handler with the appropriate calling */
|
|
|
|
/* sequence, which often depends on SA_SIGINFO. */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Heap blocks now begin and end on page boundaries */
|
|
|
|
SIG_PF old_handler;
|
|
|
|
|
|
|
|
if (sig == SIGSEGV) {
|
|
|
|
old_handler = GC_old_segv_handler;
|
|
|
|
} else {
|
|
|
|
old_handler = GC_old_bus_handler;
|
|
|
|
}
|
|
|
|
if (old_handler == SIG_DFL) {
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if !defined(MSWIN32) && !defined(MSWINCE)
|
1999-11-02 00:15:51 +01:00
|
|
|
GC_err_printf1("Segfault at 0x%lx\n", addr);
|
1999-04-07 10:01:40 +02:00
|
|
|
ABORT("Unexpected bus error or segmentation fault");
|
|
|
|
# else
|
|
|
|
return(EXCEPTION_CONTINUE_SEARCH);
|
|
|
|
# endif
|
|
|
|
} else {
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined (SUNOS4) \
|
|
|
|
|| (defined(FREEBSD) && !defined(SUNOS5SIGS))
|
1999-04-07 10:01:40 +02:00
|
|
|
(*old_handler) (sig, code, scp, addr);
|
|
|
|
return;
|
|
|
|
# endif
|
|
|
|
# if defined (SUNOS5SIGS)
|
2004-08-14 01:05:36 +02:00
|
|
|
/*
|
|
|
|
* FIXME: For FreeBSD, this code should check if the
|
|
|
|
* old signal handler used the traditional BSD style and
|
|
|
|
* if so call it using that style.
|
|
|
|
*/
|
1999-04-07 10:01:40 +02:00
|
|
|
(*(REAL_SIG_PF)old_handler) (sig, scp, context);
|
|
|
|
return;
|
|
|
|
# endif
|
|
|
|
# if defined (LINUX)
|
1999-11-02 00:15:51 +01:00
|
|
|
# if defined(ALPHA) || defined(M68K)
|
|
|
|
(*(REAL_SIG_PF)old_handler) (sig, code, sc);
|
|
|
|
# else
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(IA64) || defined(HP_PA) || defined(X86_64)
|
1999-11-02 00:15:51 +01:00
|
|
|
(*(REAL_SIG_PF)old_handler) (sig, si, scp);
|
|
|
|
# else
|
|
|
|
(*(REAL_SIG_PF)old_handler) (sig, sc);
|
|
|
|
# endif
|
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
return;
|
|
|
|
# endif
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined (IRIX5) || defined(OSF1) || defined(HURD)
|
1999-04-07 10:01:40 +02:00
|
|
|
(*(REAL_SIG_PF)old_handler) (sig, code, scp);
|
|
|
|
return;
|
|
|
|
# endif
|
|
|
|
# ifdef MSWIN32
|
|
|
|
return((*old_handler)(exc_info));
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
}
|
2001-08-18 03:04:43 +02:00
|
|
|
UNPROTECT(h, GC_page_size);
|
|
|
|
/* We need to make sure that no collection occurs between */
|
|
|
|
/* the UNPROTECT and the setting of the dirty bit. Otherwise */
|
|
|
|
/* a write by a third thread might go unnoticed. Reversing */
|
|
|
|
/* the order is just as bad, since we would end up unprotecting */
|
|
|
|
/* a page in a GC cycle during which it's not marked. */
|
|
|
|
/* Currently we do this by disabling the thread stopping */
|
|
|
|
/* signals while this handler is running. An alternative might */
|
|
|
|
/* be to record the fact that we're about to unprotect, or */
|
|
|
|
/* have just unprotected a page in the GC's thread structure, */
|
|
|
|
/* and then to have the thread stopping code set the dirty */
|
|
|
|
/* flag, if necessary. */
|
1999-04-07 10:01:40 +02:00
|
|
|
for (i = 0; i < divHBLKSZ(GC_page_size); i++) {
|
|
|
|
register int index = PHT_HASH(h+i);
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
async_set_pht_entry_from_index(GC_dirty_pages, index);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(OSF1)
|
1999-04-07 10:01:40 +02:00
|
|
|
/* These reset the signal handler each time by default. */
|
|
|
|
signal(SIGSEGV, (SIG_PF) GC_write_fault_handler);
|
|
|
|
# endif
|
|
|
|
/* The write may not take place before dirty bits are read. */
|
|
|
|
/* But then we'll fault again ... */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# if defined(MSWIN32) || defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
return(EXCEPTION_CONTINUE_EXECUTION);
|
|
|
|
# else
|
|
|
|
return;
|
|
|
|
# endif
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#if defined(MSWIN32) || defined(MSWINCE)
|
1999-04-07 10:01:40 +02:00
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
#else
|
1999-11-02 00:15:51 +01:00
|
|
|
GC_err_printf1("Segfault at 0x%lx\n", addr);
|
1999-04-07 10:01:40 +02:00
|
|
|
ABORT("Unexpected bus error or segmentation fault");
|
|
|
|
#endif
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* !DARWIN */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We hold the allocation lock. We expect block h to be written
|
2003-07-28 06:18:23 +02:00
|
|
|
* shortly. Ensure that all pages containing any part of the n hblks
|
2002-02-12 05:37:57 +01:00
|
|
|
* starting at h are no longer protected. If is_ptrfree is false,
|
|
|
|
* also ensure that they will subsequently appear to be dirty.
|
1999-04-07 10:01:40 +02:00
|
|
|
*/
|
2002-02-12 05:37:57 +01:00
|
|
|
void GC_remove_protection(h, nblocks, is_ptrfree)
|
1999-04-07 10:01:40 +02:00
|
|
|
struct hblk *h;
|
2002-02-12 05:37:57 +01:00
|
|
|
word nblocks;
|
|
|
|
GC_bool is_ptrfree;
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
2002-02-12 05:37:57 +01:00
|
|
|
struct hblk * h_trunc; /* Truncated to page boundary */
|
|
|
|
struct hblk * h_end; /* Page boundary following block end */
|
|
|
|
struct hblk * current;
|
|
|
|
GC_bool found_clean;
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
if (!GC_dirty_maintained) return;
|
|
|
|
h_trunc = (struct hblk *)((word)h & ~(GC_page_size-1));
|
2002-02-12 05:37:57 +01:00
|
|
|
h_end = (struct hblk *)(((word)(h + nblocks) + GC_page_size-1)
|
|
|
|
& ~(GC_page_size-1));
|
1999-04-07 10:01:40 +02:00
|
|
|
found_clean = FALSE;
|
2002-02-12 05:37:57 +01:00
|
|
|
for (current = h_trunc; current < h_end; ++current) {
|
|
|
|
int index = PHT_HASH(current);
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
if (!is_ptrfree || current < h || current >= h + nblocks) {
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
async_set_pht_entry_from_index(GC_dirty_pages, index);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
}
|
2002-02-12 05:37:57 +01:00
|
|
|
UNPROTECT(h_trunc, (ptr_t)h_end - (ptr_t)h_trunc);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if !defined(DARWIN)
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_dirty_init()
|
|
|
|
{
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(LINUX) || \
|
|
|
|
defined(OSF1) || defined(HURD)
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
struct sigaction act, oldact;
|
2001-08-18 03:04:43 +02:00
|
|
|
/* We should probably specify SA_SIGINFO for Linux, and handle */
|
|
|
|
/* the different architectures more uniformly. */
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(IRIX5) || defined(LINUX) && !defined(X86_64) \
|
|
|
|
|| defined(OSF1) || defined(HURD)
|
1999-04-07 10:01:40 +02:00
|
|
|
act.sa_flags = SA_RESTART;
|
2001-08-18 03:04:43 +02:00
|
|
|
act.sa_handler = (SIG_PF)GC_write_fault_handler;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# else
|
1999-04-07 10:01:40 +02:00
|
|
|
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
|
|
|
act.sa_sigaction = GC_write_fault_handler;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif
|
|
|
|
(void)sigemptyset(&act.sa_mask);
|
2001-08-18 03:04:43 +02:00
|
|
|
# ifdef SIG_SUSPEND
|
|
|
|
/* Arrange to postpone SIG_SUSPEND while we're in a write fault */
|
|
|
|
/* handler. This effectively makes the handler atomic w.r.t. */
|
|
|
|
/* stopping the world for GC. */
|
|
|
|
(void)sigaddset(&act.sa_mask, SIG_SUSPEND);
|
|
|
|
# endif /* SIG_SUSPEND */
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# endif
|
1999-04-07 10:01:40 +02:00
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_printf0("Inititalizing mprotect virtual dirty bit implementation\n");
|
|
|
|
# endif
|
|
|
|
GC_dirty_maintained = TRUE;
|
|
|
|
if (GC_page_size % HBLKSIZE != 0) {
|
|
|
|
GC_err_printf0("Page size not multiple of HBLKSIZE\n");
|
|
|
|
ABORT("Page size not multiple of HBLKSIZE");
|
|
|
|
}
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(SUNOS4) || (defined(FREEBSD) && !defined(SUNOS5SIGS))
|
1999-04-07 10:01:40 +02:00
|
|
|
GC_old_bus_handler = signal(SIGBUS, GC_write_fault_handler);
|
|
|
|
if (GC_old_bus_handler == SIG_IGN) {
|
|
|
|
GC_err_printf0("Previously ignored bus error!?");
|
|
|
|
GC_old_bus_handler = SIG_DFL;
|
|
|
|
}
|
|
|
|
if (GC_old_bus_handler != SIG_DFL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other SIGBUS handler\n");
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
# endif
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(SUNOS4)
|
1999-04-07 10:01:40 +02:00
|
|
|
GC_old_segv_handler = signal(SIGSEGV, (SIG_PF)GC_write_fault_handler);
|
|
|
|
if (GC_old_segv_handler == SIG_IGN) {
|
|
|
|
GC_err_printf0("Previously ignored segmentation violation!?");
|
|
|
|
GC_old_segv_handler = SIG_DFL;
|
|
|
|
}
|
|
|
|
if (GC_old_segv_handler != SIG_DFL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other SIGSEGV handler\n");
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
# endif
|
2004-08-14 01:05:36 +02:00
|
|
|
# if (defined(SUNOS5SIGS) && !defined(FREEBSD)) || defined(IRIX5) \
|
|
|
|
|| defined(LINUX) || defined(OSF1) || defined(HURD)
|
2001-08-18 03:04:43 +02:00
|
|
|
/* SUNOS5SIGS includes HPUX */
|
2001-10-16 11:01:40 +02:00
|
|
|
# if defined(GC_IRIX_THREADS)
|
1999-04-07 10:01:40 +02:00
|
|
|
sigaction(SIGSEGV, 0, &oldact);
|
|
|
|
sigaction(SIGSEGV, &act, 0);
|
2004-08-14 01:05:36 +02:00
|
|
|
# else
|
2003-07-28 06:18:23 +02:00
|
|
|
{
|
|
|
|
int res = sigaction(SIGSEGV, &act, &oldact);
|
|
|
|
if (res != 0) ABORT("Sigaction failed");
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
# if defined(_sigargs) || defined(HURD) || !defined(SA_SIGINFO)
|
1999-04-07 10:01:40 +02:00
|
|
|
/* This is Irix 5.x, not 6.x. Irix 5.x does not have */
|
|
|
|
/* sa_sigaction. */
|
|
|
|
GC_old_segv_handler = oldact.sa_handler;
|
2001-08-18 03:04:43 +02:00
|
|
|
# else /* Irix 6.x or SUNOS5SIGS or LINUX */
|
1999-04-07 10:01:40 +02:00
|
|
|
if (oldact.sa_flags & SA_SIGINFO) {
|
|
|
|
GC_old_segv_handler = (SIG_PF)(oldact.sa_sigaction);
|
|
|
|
} else {
|
|
|
|
GC_old_segv_handler = oldact.sa_handler;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
if (GC_old_segv_handler == SIG_IGN) {
|
|
|
|
GC_err_printf0("Previously ignored segmentation violation!?");
|
|
|
|
GC_old_segv_handler = SIG_DFL;
|
|
|
|
}
|
|
|
|
if (GC_old_segv_handler != SIG_DFL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other SIGSEGV handler\n");
|
|
|
|
# endif
|
|
|
|
}
|
2004-08-14 01:05:36 +02:00
|
|
|
# endif /* (SUNOS5SIGS && !FREEBSD) || IRIX5 || LINUX || OSF1 || HURD */
|
|
|
|
# if defined(HPUX) || defined(LINUX) || defined(HURD) \
|
|
|
|
|| (defined(FREEBSD) && defined(SUNOS5SIGS))
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
sigaction(SIGBUS, &act, &oldact);
|
|
|
|
GC_old_bus_handler = oldact.sa_handler;
|
|
|
|
if (GC_old_bus_handler == SIG_IGN) {
|
|
|
|
GC_err_printf0("Previously ignored bus error!?");
|
|
|
|
GC_old_bus_handler = SIG_DFL;
|
|
|
|
}
|
|
|
|
if (GC_old_bus_handler != SIG_DFL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other SIGBUS handler\n");
|
|
|
|
# endif
|
|
|
|
}
|
2004-08-14 01:05:36 +02:00
|
|
|
# endif /* HPUX || LINUX || HURD || (FREEBSD && SUNOS5SIGS) */
|
1999-04-07 10:01:40 +02:00
|
|
|
# if defined(MSWIN32)
|
|
|
|
GC_old_segv_handler = SetUnhandledExceptionFilter(GC_write_fault_handler);
|
|
|
|
if (GC_old_segv_handler != NULL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other UnhandledExceptionFilter\n");
|
|
|
|
# endif
|
|
|
|
} else {
|
|
|
|
GC_old_segv_handler = SIG_DFL;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* !DARWIN */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
int GC_incremental_protection_needs()
|
|
|
|
{
|
|
|
|
if (GC_page_size == HBLKSIZE) {
|
|
|
|
return GC_PROTECTS_POINTER_HEAP;
|
|
|
|
} else {
|
|
|
|
return GC_PROTECTS_POINTER_HEAP | GC_PROTECTS_PTRFREE_HEAP;
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#define HAVE_INCREMENTAL_PROTECTION_NEEDS
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#define IS_PTRFREE(hhdr) ((hhdr)->hb_descr == 0)
|
|
|
|
|
|
|
|
#define PAGE_ALIGNED(x) !((word)(x) & (GC_page_size - 1))
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_protect_heap()
|
|
|
|
{
|
|
|
|
ptr_t start;
|
|
|
|
word len;
|
2002-02-12 05:37:57 +01:00
|
|
|
struct hblk * current;
|
|
|
|
struct hblk * current_start; /* Start of block to be protected. */
|
|
|
|
struct hblk * limit;
|
1999-04-07 10:01:40 +02:00
|
|
|
unsigned i;
|
2002-02-12 05:37:57 +01:00
|
|
|
GC_bool protect_all =
|
|
|
|
(0 != (GC_incremental_protection_needs() & GC_PROTECTS_PTRFREE_HEAP));
|
1999-04-07 10:01:40 +02:00
|
|
|
for (i = 0; i < GC_n_heap_sects; i++) {
|
|
|
|
start = GC_heap_sects[i].hs_start;
|
|
|
|
len = GC_heap_sects[i].hs_bytes;
|
2002-02-12 05:37:57 +01:00
|
|
|
if (protect_all) {
|
|
|
|
PROTECT(start, len);
|
|
|
|
} else {
|
|
|
|
GC_ASSERT(PAGE_ALIGNED(len))
|
|
|
|
GC_ASSERT(PAGE_ALIGNED(start))
|
|
|
|
current_start = current = (struct hblk *)start;
|
|
|
|
limit = (struct hblk *)(start + len);
|
|
|
|
while (current < limit) {
|
|
|
|
hdr * hhdr;
|
|
|
|
word nhblks;
|
|
|
|
GC_bool is_ptrfree;
|
|
|
|
|
|
|
|
GC_ASSERT(PAGE_ALIGNED(current));
|
|
|
|
GET_HDR(current, hhdr);
|
|
|
|
if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
|
|
|
|
/* This can happen only if we're at the beginning of a */
|
|
|
|
/* heap segment, and a block spans heap segments. */
|
|
|
|
/* We will handle that block as part of the preceding */
|
|
|
|
/* segment. */
|
|
|
|
GC_ASSERT(current_start == current);
|
|
|
|
current_start = ++current;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (HBLK_IS_FREE(hhdr)) {
|
|
|
|
GC_ASSERT(PAGE_ALIGNED(hhdr -> hb_sz));
|
|
|
|
nhblks = divHBLKSZ(hhdr -> hb_sz);
|
|
|
|
is_ptrfree = TRUE; /* dirty on alloc */
|
|
|
|
} else {
|
|
|
|
nhblks = OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz);
|
|
|
|
is_ptrfree = IS_PTRFREE(hhdr);
|
|
|
|
}
|
|
|
|
if (is_ptrfree) {
|
|
|
|
if (current_start < current) {
|
|
|
|
PROTECT(current_start, (ptr_t)current - (ptr_t)current_start);
|
|
|
|
}
|
|
|
|
current_start = (current += nhblks);
|
|
|
|
} else {
|
|
|
|
current += nhblks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (current_start < current) {
|
|
|
|
PROTECT(current_start, (ptr_t)current - (ptr_t)current_start);
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We assume that either the world is stopped or its OK to lose dirty */
|
|
|
|
/* bits while this is happenning (as in GC_enable_incremental). */
|
|
|
|
void GC_read_dirty()
|
|
|
|
{
|
|
|
|
BCOPY((word *)GC_dirty_pages, GC_grungy_pages,
|
|
|
|
(sizeof GC_dirty_pages));
|
|
|
|
BZERO((word *)GC_dirty_pages, (sizeof GC_dirty_pages));
|
|
|
|
GC_protect_heap();
|
|
|
|
}
|
|
|
|
|
|
|
|
GC_bool GC_page_was_dirty(h)
|
|
|
|
struct hblk * h;
|
|
|
|
{
|
|
|
|
register word index = PHT_HASH(h);
|
|
|
|
|
|
|
|
return(HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, index));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Acquiring the allocation lock here is dangerous, since this
|
|
|
|
* can be called from within GC_call_with_alloc_lock, and the cord
|
|
|
|
* package does so. On systems that allow nested lock acquisition, this
|
|
|
|
* happens to work.
|
|
|
|
* On other systems, SET_LOCK_HOLDER and friends must be suitably defined.
|
|
|
|
*/
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
static GC_bool syscall_acquired_lock = FALSE; /* Protected by GC lock. */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
void GC_begin_syscall()
|
|
|
|
{
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
if (!I_HOLD_LOCK()) {
|
|
|
|
LOCK();
|
|
|
|
syscall_acquired_lock = TRUE;
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GC_end_syscall()
|
|
|
|
{
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
if (syscall_acquired_lock) {
|
|
|
|
syscall_acquired_lock = FALSE;
|
|
|
|
UNLOCK();
|
|
|
|
}
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GC_unprotect_range(addr, len)
|
|
|
|
ptr_t addr;
|
|
|
|
word len;
|
|
|
|
{
|
|
|
|
struct hblk * start_block;
|
|
|
|
struct hblk * end_block;
|
|
|
|
register struct hblk *h;
|
|
|
|
ptr_t obj_start;
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
if (!GC_dirty_maintained) return;
|
1999-04-07 10:01:40 +02:00
|
|
|
obj_start = GC_base(addr);
|
|
|
|
if (obj_start == 0) return;
|
|
|
|
if (GC_base(addr + len - 1) != obj_start) {
|
|
|
|
ABORT("GC_unprotect_range(range bigger than object)");
|
|
|
|
}
|
|
|
|
start_block = (struct hblk *)((word)addr & ~(GC_page_size - 1));
|
|
|
|
end_block = (struct hblk *)((word)(addr + len - 1) & ~(GC_page_size - 1));
|
|
|
|
end_block += GC_page_size/HBLKSIZE - 1;
|
|
|
|
for (h = start_block; h <= end_block; h++) {
|
|
|
|
register word index = PHT_HASH(h);
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
async_set_pht_entry_from_index(GC_dirty_pages, index);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
UNPROTECT(start_block,
|
|
|
|
((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE);
|
|
|
|
}
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
/* We no longer wrap read by default, since that was causing too many */
|
|
|
|
/* problems. It is preferred that the client instead avoids writing */
|
|
|
|
/* to the write-protected heap with a system call. */
|
|
|
|
/* This still serves as sample code if you do want to wrap system calls.*/
|
|
|
|
|
|
|
|
#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(GC_USE_LD_WRAP)
|
|
|
|
/* Replacement for UNIX system call. */
|
|
|
|
/* Other calls that write to the heap should be handled similarly. */
|
|
|
|
/* Note that this doesn't work well for blocking reads: It will hold */
|
|
|
|
/* the allocation lock for the entire duration of the call. Multithreaded */
|
|
|
|
/* clients should really ensure that it won't block, either by setting */
|
|
|
|
/* the descriptor nonblocking, or by calling select or poll first, to */
|
|
|
|
/* make sure that input is available. */
|
|
|
|
/* Another, preferred alternative is to ensure that system calls never */
|
|
|
|
/* write to the protected heap (see above). */
|
1999-04-07 10:01:40 +02:00
|
|
|
# if defined(__STDC__) && !defined(SUNOS4)
|
|
|
|
# include <unistd.h>
|
2000-04-19 12:10:01 +02:00
|
|
|
# include <sys/uio.h>
|
1999-04-07 10:01:40 +02:00
|
|
|
ssize_t read(int fd, void *buf, size_t nbyte)
|
|
|
|
# else
|
|
|
|
# ifndef LINT
|
|
|
|
int read(fd, buf, nbyte)
|
|
|
|
# else
|
|
|
|
int GC_read(fd, buf, nbyte)
|
|
|
|
# endif
|
|
|
|
int fd;
|
|
|
|
char *buf;
|
|
|
|
int nbyte;
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
GC_begin_syscall();
|
|
|
|
GC_unprotect_range(buf, (word)nbyte);
|
2001-10-16 11:01:40 +02:00
|
|
|
# if defined(IRIX5) || defined(GC_LINUX_THREADS)
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Indirect system call may not always be easily available. */
|
|
|
|
/* We could call _read, but that would interfere with the */
|
|
|
|
/* libpthread interception of read. */
|
2000-04-19 12:10:01 +02:00
|
|
|
/* On Linux, we have to be careful with the linuxthreads */
|
|
|
|
/* read interception. */
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
struct iovec iov;
|
|
|
|
|
|
|
|
iov.iov_base = buf;
|
|
|
|
iov.iov_len = nbyte;
|
|
|
|
result = readv(fd, &iov, 1);
|
|
|
|
}
|
|
|
|
# else
|
2001-08-18 03:04:43 +02:00
|
|
|
# if defined(HURD)
|
|
|
|
result = __read(fd, buf, nbyte);
|
|
|
|
# else
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
/* The two zero args at the end of this list are because one
|
|
|
|
IA-64 syscall() implementation actually requires six args
|
|
|
|
to be passed, even though they aren't always used. */
|
|
|
|
result = syscall(SYS_read, fd, buf, nbyte, 0, 0);
|
2001-08-18 03:04:43 +02:00
|
|
|
# endif /* !HURD */
|
1999-04-07 10:01:40 +02:00
|
|
|
# endif
|
|
|
|
GC_end_syscall();
|
|
|
|
return(result);
|
|
|
|
}
|
2001-10-16 11:01:40 +02:00
|
|
|
#endif /* !MSWIN32 && !MSWINCE && !GC_LINUX_THREADS */
|
2000-04-19 12:10:01 +02:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#if defined(GC_USE_LD_WRAP) && !defined(THREADS)
|
2000-04-19 12:10:01 +02:00
|
|
|
/* We use the GNU ld call wrapping facility. */
|
|
|
|
/* This requires that the linker be invoked with "--wrap read". */
|
|
|
|
/* This can be done by passing -Wl,"--wrap read" to gcc. */
|
|
|
|
/* I'm not sure that this actually wraps whatever version of read */
|
|
|
|
/* is called by stdio. That code also mentions __read. */
|
|
|
|
# include <unistd.h>
|
|
|
|
ssize_t __wrap_read(int fd, void *buf, size_t nbyte)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
GC_begin_syscall();
|
|
|
|
GC_unprotect_range(buf, (word)nbyte);
|
|
|
|
result = __real_read(fd, buf, nbyte);
|
|
|
|
GC_end_syscall();
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We should probably also do this for __read, or whatever stdio */
|
|
|
|
/* actually calls. */
|
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* 0 */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/*ARGSUSED*/
|
|
|
|
GC_bool GC_page_was_ever_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the n pages starting at h to "was never dirty" status. */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void GC_is_fresh(h, n)
|
|
|
|
struct hblk *h;
|
|
|
|
word n;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* MPROTECT_VDB */
|
|
|
|
|
|
|
|
# ifdef PROC_VDB
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See DEFAULT_VDB for interface descriptions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This implementaion assumes a Solaris 2.X like /proc pseudo-file-system
|
|
|
|
* from which we can read page modified bits. This facility is far from
|
|
|
|
* optimal (e.g. we would like to get the info for only some of the
|
|
|
|
* address space), but it avoids intercepting system calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/fault.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <sys/procfs.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#define INITIAL_BUF_SZ 16384
|
1999-04-07 10:01:40 +02:00
|
|
|
word GC_proc_buf_size = INITIAL_BUF_SZ;
|
|
|
|
char *GC_proc_buf;
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
#ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
/* We don't have exact sp values for threads. So we count on */
|
|
|
|
/* occasionally declaring stack pages to be fresh. Thus we */
|
|
|
|
/* need a real implementation of GC_is_fresh. We can't clear */
|
|
|
|
/* entries in GC_written_pages, since that would declare all */
|
|
|
|
/* pages with the given hash address to be fresh. */
|
|
|
|
# define MAX_FRESH_PAGES 8*1024 /* Must be power of 2 */
|
|
|
|
struct hblk ** GC_fresh_pages; /* A direct mapped cache. */
|
|
|
|
/* Collisions are dropped. */
|
|
|
|
|
|
|
|
# define FRESH_PAGE_SLOT(h) (divHBLKSZ((word)(h)) & (MAX_FRESH_PAGES-1))
|
|
|
|
# define ADD_FRESH_PAGE(h) \
|
|
|
|
GC_fresh_pages[FRESH_PAGE_SLOT(h)] = (h)
|
|
|
|
# define PAGE_IS_FRESH(h) \
|
|
|
|
(GC_fresh_pages[FRESH_PAGE_SLOT(h)] == (h) && (h) != 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Add all pages in pht2 to pht1 */
|
|
|
|
void GC_or_pages(pht1, pht2)
|
|
|
|
page_hash_table pht1, pht2;
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
int GC_proc_fd;
|
|
|
|
|
|
|
|
void GC_dirty_init()
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char buf[30];
|
|
|
|
|
|
|
|
GC_dirty_maintained = TRUE;
|
|
|
|
if (GC_words_allocd != 0 || GC_words_allocd_before_gc != 0) {
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
for (i = 0; i < PHT_SIZE; i++) GC_written_pages[i] = (word)(-1);
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_printf1("Allocated words:%lu:all pages may have been written\n",
|
|
|
|
(unsigned long)
|
|
|
|
(GC_words_allocd + GC_words_allocd_before_gc));
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
sprintf(buf, "/proc/%d", getpid());
|
|
|
|
fd = open(buf, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
ABORT("/proc open failed");
|
|
|
|
}
|
|
|
|
GC_proc_fd = syscall(SYS_ioctl, fd, PIOCOPENPD, 0);
|
|
|
|
close(fd);
|
2003-07-28 06:18:23 +02:00
|
|
|
syscall(SYS_fcntl, GC_proc_fd, F_SETFD, FD_CLOEXEC);
|
1999-04-07 10:01:40 +02:00
|
|
|
if (GC_proc_fd < 0) {
|
|
|
|
ABORT("/proc ioctl failed");
|
|
|
|
}
|
|
|
|
GC_proc_buf = GC_scratch_alloc(GC_proc_buf_size);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
GC_fresh_pages = (struct hblk **)
|
|
|
|
GC_scratch_alloc(MAX_FRESH_PAGES * sizeof (struct hblk *));
|
|
|
|
if (GC_fresh_pages == 0) {
|
|
|
|
GC_err_printf0("No space for fresh pages\n");
|
|
|
|
EXIT();
|
|
|
|
}
|
|
|
|
BZERO(GC_fresh_pages, MAX_FRESH_PAGES * sizeof (struct hblk *));
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ignore write hints. They don't help us here. */
|
|
|
|
/*ARGSUSED*/
|
2002-02-12 05:37:57 +01:00
|
|
|
void GC_remove_protection(h, nblocks, is_ptrfree)
|
1999-04-07 10:01:40 +02:00
|
|
|
struct hblk *h;
|
2002-02-12 05:37:57 +01:00
|
|
|
word nblocks;
|
|
|
|
GC_bool is_ptrfree;
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
#ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
# define READ(fd,buf,nbytes) syscall(SYS_read, fd, buf, nbytes)
|
|
|
|
#else
|
|
|
|
# define READ(fd,buf,nbytes) read(fd, buf, nbytes)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void GC_read_dirty()
|
|
|
|
{
|
|
|
|
unsigned long ps, np;
|
|
|
|
int nmaps;
|
|
|
|
ptr_t vaddr;
|
|
|
|
struct prasmap * map;
|
|
|
|
char * bufp;
|
|
|
|
ptr_t current_addr, limit;
|
|
|
|
int i;
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
BZERO(GC_grungy_pages, (sizeof GC_grungy_pages));
|
|
|
|
|
|
|
|
bufp = GC_proc_buf;
|
|
|
|
if (READ(GC_proc_fd, bufp, GC_proc_buf_size) <= 0) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_printf1("/proc read failed: GC_proc_buf_size = %lu\n",
|
|
|
|
GC_proc_buf_size);
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
/* Retry with larger buffer. */
|
|
|
|
word new_size = 2 * GC_proc_buf_size;
|
|
|
|
char * new_buf = GC_scratch_alloc(new_size);
|
|
|
|
|
|
|
|
if (new_buf != 0) {
|
|
|
|
GC_proc_buf = bufp = new_buf;
|
|
|
|
GC_proc_buf_size = new_size;
|
|
|
|
}
|
2004-08-14 01:05:36 +02:00
|
|
|
if (READ(GC_proc_fd, bufp, GC_proc_buf_size) <= 0) {
|
1999-04-07 10:01:40 +02:00
|
|
|
WARN("Insufficient space for /proc read\n", 0);
|
|
|
|
/* Punt: */
|
|
|
|
memset(GC_grungy_pages, 0xff, sizeof (page_hash_table));
|
|
|
|
memset(GC_written_pages, 0xff, sizeof(page_hash_table));
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
BZERO(GC_fresh_pages,
|
|
|
|
MAX_FRESH_PAGES * sizeof (struct hblk *));
|
|
|
|
# endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Copy dirty bits into GC_grungy_pages */
|
|
|
|
nmaps = ((struct prpageheader *)bufp) -> pr_nmap;
|
|
|
|
/* printf( "nmaps = %d, PG_REFERENCED = %d, PG_MODIFIED = %d\n",
|
|
|
|
nmaps, PG_REFERENCED, PG_MODIFIED); */
|
|
|
|
bufp = bufp + sizeof(struct prpageheader);
|
|
|
|
for (i = 0; i < nmaps; i++) {
|
|
|
|
map = (struct prasmap *)bufp;
|
|
|
|
vaddr = (ptr_t)(map -> pr_vaddr);
|
|
|
|
ps = map -> pr_pagesize;
|
|
|
|
np = map -> pr_npage;
|
|
|
|
/* printf("vaddr = 0x%X, ps = 0x%X, np = 0x%X\n", vaddr, ps, np); */
|
|
|
|
limit = vaddr + ps * np;
|
|
|
|
bufp += sizeof (struct prasmap);
|
|
|
|
for (current_addr = vaddr;
|
|
|
|
current_addr < limit; current_addr += ps){
|
|
|
|
if ((*bufp++) & PG_MODIFIED) {
|
|
|
|
register struct hblk * h = (struct hblk *) current_addr;
|
|
|
|
|
|
|
|
while ((ptr_t)h < current_addr + ps) {
|
|
|
|
register word index = PHT_HASH(h);
|
|
|
|
|
|
|
|
set_pht_entry_from_index(GC_grungy_pages, index);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
|
|
|
register int slot = FRESH_PAGE_SLOT(h);
|
|
|
|
|
|
|
|
if (GC_fresh_pages[slot] == h) {
|
|
|
|
GC_fresh_pages[slot] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bufp += sizeof(long) - 1;
|
|
|
|
bufp = (char *)((unsigned long)bufp & ~(sizeof(long)-1));
|
|
|
|
}
|
|
|
|
/* Update GC_written_pages. */
|
|
|
|
GC_or_pages(GC_written_pages, GC_grungy_pages);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Make sure that old stacks are considered completely clean */
|
|
|
|
/* unless written again. */
|
|
|
|
GC_old_stacks_are_fresh();
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef READ
|
|
|
|
|
|
|
|
GC_bool GC_page_was_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
register word index = PHT_HASH(h);
|
|
|
|
register GC_bool result;
|
|
|
|
|
|
|
|
result = get_pht_entry_from_index(GC_grungy_pages, index);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
if (result && PAGE_IS_FRESH(h)) result = FALSE;
|
|
|
|
/* This happens only if page was declared fresh since */
|
|
|
|
/* the read_dirty call, e.g. because it's in an unused */
|
|
|
|
/* thread stack. It's OK to treat it as clean, in */
|
|
|
|
/* that case. And it's consistent with */
|
|
|
|
/* GC_page_was_ever_dirty. */
|
|
|
|
# endif
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
GC_bool GC_page_was_ever_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
register word index = PHT_HASH(h);
|
|
|
|
register GC_bool result;
|
|
|
|
|
|
|
|
result = get_pht_entry_from_index(GC_written_pages, index);
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
if (result && PAGE_IS_FRESH(h)) result = FALSE;
|
|
|
|
# endif
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Caller holds allocation lock. */
|
|
|
|
void GC_is_fresh(h, n)
|
|
|
|
struct hblk *h;
|
|
|
|
word n;
|
|
|
|
{
|
|
|
|
|
|
|
|
register word index;
|
|
|
|
|
2001-10-16 11:01:40 +02:00
|
|
|
# ifdef GC_SOLARIS_THREADS
|
1999-04-07 10:01:40 +02:00
|
|
|
register word i;
|
|
|
|
|
|
|
|
if (GC_fresh_pages != 0) {
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
ADD_FRESH_PAGE(h + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* PROC_VDB */
|
|
|
|
|
|
|
|
|
|
|
|
# ifdef PCR_VDB
|
|
|
|
|
|
|
|
# include "vd/PCR_VD.h"
|
|
|
|
|
|
|
|
# define NPAGES (32*1024) /* 128 MB */
|
|
|
|
|
|
|
|
PCR_VD_DB GC_grungy_bits[NPAGES];
|
|
|
|
|
|
|
|
ptr_t GC_vd_base; /* Address corresponding to GC_grungy_bits[0] */
|
|
|
|
/* HBLKSIZE aligned. */
|
|
|
|
|
|
|
|
void GC_dirty_init()
|
|
|
|
{
|
|
|
|
GC_dirty_maintained = TRUE;
|
|
|
|
/* For the time being, we assume the heap generally grows up */
|
|
|
|
GC_vd_base = GC_heap_sects[0].hs_start;
|
|
|
|
if (GC_vd_base == 0) {
|
|
|
|
ABORT("Bad initial heap segment");
|
|
|
|
}
|
|
|
|
if (PCR_VD_Start(HBLKSIZE, GC_vd_base, NPAGES*HBLKSIZE)
|
|
|
|
!= PCR_ERes_okay) {
|
|
|
|
ABORT("dirty bit initialization failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GC_read_dirty()
|
|
|
|
{
|
|
|
|
/* lazily enable dirty bits on newly added heap sects */
|
|
|
|
{
|
|
|
|
static int onhs = 0;
|
|
|
|
int nhs = GC_n_heap_sects;
|
|
|
|
for( ; onhs < nhs; onhs++ ) {
|
|
|
|
PCR_VD_WriteProtectEnable(
|
|
|
|
GC_heap_sects[onhs].hs_start,
|
|
|
|
GC_heap_sects[onhs].hs_bytes );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PCR_VD_Clear(GC_vd_base, NPAGES*HBLKSIZE, GC_grungy_bits)
|
|
|
|
!= PCR_ERes_okay) {
|
|
|
|
ABORT("dirty bit read failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GC_bool GC_page_was_dirty(h)
|
|
|
|
struct hblk *h;
|
|
|
|
{
|
|
|
|
if((ptr_t)h < GC_vd_base || (ptr_t)h >= GC_vd_base + NPAGES*HBLKSIZE) {
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
return(GC_grungy_bits[h - (struct hblk *)GC_vd_base] & PCR_VD_DB_dirtyBit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2002-02-12 05:37:57 +01:00
|
|
|
void GC_remove_protection(h, nblocks, is_ptrfree)
|
1999-04-07 10:01:40 +02:00
|
|
|
struct hblk *h;
|
2002-02-12 05:37:57 +01:00
|
|
|
word nblocks;
|
|
|
|
GC_bool is_ptrfree;
|
1999-04-07 10:01:40 +02:00
|
|
|
{
|
2002-02-12 05:37:57 +01:00
|
|
|
PCR_VD_WriteProtectDisable(h, nblocks*HBLKSIZE);
|
|
|
|
PCR_VD_WriteProtectEnable(h, nblocks*HBLKSIZE);
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* PCR_VDB */
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#if defined(MPROTECT_VDB) && defined(DARWIN)
|
|
|
|
/* The following sources were used as a *reference* for this exception handling
|
|
|
|
code:
|
|
|
|
1. Apple's mach/xnu documentation
|
|
|
|
2. Timothy J. Wood's "Mach Exception Handlers 101" post to the
|
|
|
|
omnigroup's macosx-dev list.
|
2007-01-15 22:24:42 +01:00
|
|
|
www.omnigroup.com/mailman/archive/macosx-dev/2000-June/014178.html
|
2003-07-28 06:18:23 +02:00
|
|
|
3. macosx-nat.c from Apple's GDB source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The bug that caused all this trouble should now be fixed. This should
|
|
|
|
eventually be removed if all goes well. */
|
|
|
|
/* define BROKEN_EXCEPTION_HANDLING */
|
|
|
|
|
|
|
|
#include <mach/mach.h>
|
|
|
|
#include <mach/mach_error.h>
|
|
|
|
#include <mach/thread_status.h>
|
|
|
|
#include <mach/exception.h>
|
|
|
|
#include <mach/task.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
/* These are not defined in any header, although they are documented */
|
|
|
|
extern boolean_t exc_server(mach_msg_header_t *,mach_msg_header_t *);
|
|
|
|
extern kern_return_t exception_raise(
|
|
|
|
mach_port_t,mach_port_t,mach_port_t,
|
|
|
|
exception_type_t,exception_data_t,mach_msg_type_number_t);
|
|
|
|
extern kern_return_t exception_raise_state(
|
|
|
|
mach_port_t,mach_port_t,mach_port_t,
|
|
|
|
exception_type_t,exception_data_t,mach_msg_type_number_t,
|
|
|
|
thread_state_flavor_t*,thread_state_t,mach_msg_type_number_t,
|
|
|
|
thread_state_t,mach_msg_type_number_t*);
|
|
|
|
extern kern_return_t exception_raise_state_identity(
|
|
|
|
mach_port_t,mach_port_t,mach_port_t,
|
|
|
|
exception_type_t,exception_data_t,mach_msg_type_number_t,
|
|
|
|
thread_state_flavor_t*,thread_state_t,mach_msg_type_number_t,
|
|
|
|
thread_state_t,mach_msg_type_number_t*);
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_EXCEPTION_PORTS 16
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
mach_msg_type_number_t count;
|
|
|
|
exception_mask_t masks[MAX_EXCEPTION_PORTS];
|
|
|
|
exception_handler_t ports[MAX_EXCEPTION_PORTS];
|
|
|
|
exception_behavior_t behaviors[MAX_EXCEPTION_PORTS];
|
|
|
|
thread_state_flavor_t flavors[MAX_EXCEPTION_PORTS];
|
|
|
|
} GC_old_exc_ports;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
mach_port_t exception;
|
|
|
|
#if defined(THREADS)
|
|
|
|
mach_port_t reply;
|
|
|
|
#endif
|
|
|
|
} GC_ports;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
mach_msg_header_t head;
|
|
|
|
} GC_msg_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GC_MP_NORMAL, GC_MP_DISCARDING, GC_MP_STOPPED
|
|
|
|
} GC_mprotect_state_t;
|
|
|
|
|
|
|
|
/* FIXME: 1 and 2 seem to be safe to use in the msgh_id field,
|
|
|
|
but it isn't documented. Use the source and see if they
|
|
|
|
should be ok. */
|
|
|
|
#define ID_STOP 1
|
|
|
|
#define ID_RESUME 2
|
|
|
|
|
|
|
|
/* These values are only used on the reply port */
|
|
|
|
#define ID_ACK 3
|
|
|
|
|
|
|
|
#if defined(THREADS)
|
|
|
|
|
|
|
|
GC_mprotect_state_t GC_mprotect_state;
|
|
|
|
|
|
|
|
/* The following should ONLY be called when the world is stopped */
|
|
|
|
static void GC_mprotect_thread_notify(mach_msg_id_t id) {
|
|
|
|
struct {
|
|
|
|
GC_msg_t msg;
|
|
|
|
mach_msg_trailer_t trailer;
|
|
|
|
} buf;
|
|
|
|
mach_msg_return_t r;
|
|
|
|
/* remote, local */
|
|
|
|
buf.msg.head.msgh_bits =
|
|
|
|
MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND,0);
|
|
|
|
buf.msg.head.msgh_size = sizeof(buf.msg);
|
|
|
|
buf.msg.head.msgh_remote_port = GC_ports.exception;
|
|
|
|
buf.msg.head.msgh_local_port = MACH_PORT_NULL;
|
|
|
|
buf.msg.head.msgh_id = id;
|
|
|
|
|
|
|
|
r = mach_msg(
|
|
|
|
&buf.msg.head,
|
|
|
|
MACH_SEND_MSG|MACH_RCV_MSG|MACH_RCV_LARGE,
|
|
|
|
sizeof(buf.msg),
|
|
|
|
sizeof(buf),
|
|
|
|
GC_ports.reply,
|
|
|
|
MACH_MSG_TIMEOUT_NONE,
|
|
|
|
MACH_PORT_NULL);
|
|
|
|
if(r != MACH_MSG_SUCCESS)
|
|
|
|
ABORT("mach_msg failed in GC_mprotect_thread_notify");
|
|
|
|
if(buf.msg.head.msgh_id != ID_ACK)
|
|
|
|
ABORT("invalid ack in GC_mprotect_thread_notify");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should only be called by the mprotect thread */
|
|
|
|
static void GC_mprotect_thread_reply() {
|
|
|
|
GC_msg_t msg;
|
|
|
|
mach_msg_return_t r;
|
|
|
|
/* remote, local */
|
|
|
|
msg.head.msgh_bits =
|
|
|
|
MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND,0);
|
|
|
|
msg.head.msgh_size = sizeof(msg);
|
|
|
|
msg.head.msgh_remote_port = GC_ports.reply;
|
|
|
|
msg.head.msgh_local_port = MACH_PORT_NULL;
|
|
|
|
msg.head.msgh_id = ID_ACK;
|
|
|
|
|
|
|
|
r = mach_msg(
|
|
|
|
&msg.head,
|
|
|
|
MACH_SEND_MSG,
|
|
|
|
sizeof(msg),
|
|
|
|
0,
|
|
|
|
MACH_PORT_NULL,
|
|
|
|
MACH_MSG_TIMEOUT_NONE,
|
|
|
|
MACH_PORT_NULL);
|
|
|
|
if(r != MACH_MSG_SUCCESS)
|
|
|
|
ABORT("mach_msg failed in GC_mprotect_thread_reply");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GC_mprotect_stop() {
|
|
|
|
GC_mprotect_thread_notify(ID_STOP);
|
|
|
|
}
|
|
|
|
void GC_mprotect_resume() {
|
|
|
|
GC_mprotect_thread_notify(ID_RESUME);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !THREADS */
|
|
|
|
/* The compiler should optimize away any GC_mprotect_state computations */
|
|
|
|
#define GC_mprotect_state GC_MP_NORMAL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void *GC_mprotect_thread(void *arg) {
|
|
|
|
mach_msg_return_t r;
|
|
|
|
/* These two structures contain some private kernel data. We don't need to
|
|
|
|
access any of it so we don't bother defining a proper struct. The
|
|
|
|
correct definitions are in the xnu source code. */
|
|
|
|
struct {
|
|
|
|
mach_msg_header_t head;
|
|
|
|
char data[256];
|
|
|
|
} reply;
|
|
|
|
struct {
|
|
|
|
mach_msg_header_t head;
|
|
|
|
mach_msg_body_t msgh_body;
|
|
|
|
char data[1024];
|
|
|
|
} msg;
|
|
|
|
|
|
|
|
mach_msg_id_t id;
|
2004-08-14 01:05:36 +02:00
|
|
|
|
|
|
|
GC_darwin_register_mach_handler_thread(mach_thread_self());
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
r = mach_msg(
|
|
|
|
&msg.head,
|
|
|
|
MACH_RCV_MSG|MACH_RCV_LARGE|
|
|
|
|
(GC_mprotect_state == GC_MP_DISCARDING ? MACH_RCV_TIMEOUT : 0),
|
|
|
|
0,
|
|
|
|
sizeof(msg),
|
|
|
|
GC_ports.exception,
|
|
|
|
GC_mprotect_state == GC_MP_DISCARDING ? 0 : MACH_MSG_TIMEOUT_NONE,
|
|
|
|
MACH_PORT_NULL);
|
|
|
|
|
|
|
|
id = r == MACH_MSG_SUCCESS ? msg.head.msgh_id : -1;
|
|
|
|
|
|
|
|
#if defined(THREADS)
|
|
|
|
if(GC_mprotect_state == GC_MP_DISCARDING) {
|
|
|
|
if(r == MACH_RCV_TIMED_OUT) {
|
|
|
|
GC_mprotect_state = GC_MP_STOPPED;
|
|
|
|
GC_mprotect_thread_reply();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(r == MACH_MSG_SUCCESS && (id == ID_STOP || id == ID_RESUME))
|
|
|
|
ABORT("out of order mprotect thread request");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(r != MACH_MSG_SUCCESS) {
|
|
|
|
GC_err_printf2("mach_msg failed with %d %s\n",
|
|
|
|
(int)r,mach_error_string(r));
|
|
|
|
ABORT("mach_msg failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(id) {
|
|
|
|
#if defined(THREADS)
|
|
|
|
case ID_STOP:
|
|
|
|
if(GC_mprotect_state != GC_MP_NORMAL)
|
|
|
|
ABORT("Called mprotect_stop when state wasn't normal");
|
|
|
|
GC_mprotect_state = GC_MP_DISCARDING;
|
|
|
|
break;
|
|
|
|
case ID_RESUME:
|
|
|
|
if(GC_mprotect_state != GC_MP_STOPPED)
|
|
|
|
ABORT("Called mprotect_resume when state wasn't stopped");
|
|
|
|
GC_mprotect_state = GC_MP_NORMAL;
|
|
|
|
GC_mprotect_thread_reply();
|
|
|
|
break;
|
|
|
|
#endif /* THREADS */
|
|
|
|
default:
|
|
|
|
/* Handle the message (calls catch_exception_raise) */
|
|
|
|
if(!exc_server(&msg.head,&reply.head))
|
|
|
|
ABORT("exc_server failed");
|
|
|
|
/* Send the reply */
|
|
|
|
r = mach_msg(
|
|
|
|
&reply.head,
|
|
|
|
MACH_SEND_MSG,
|
|
|
|
reply.head.msgh_size,
|
|
|
|
0,
|
|
|
|
MACH_PORT_NULL,
|
|
|
|
MACH_MSG_TIMEOUT_NONE,
|
|
|
|
MACH_PORT_NULL);
|
|
|
|
if(r != MACH_MSG_SUCCESS) {
|
|
|
|
/* This will fail if the thread dies, but the thread shouldn't
|
|
|
|
die... */
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
GC_err_printf2(
|
|
|
|
"mach_msg failed with %d %s while sending exc reply\n",
|
|
|
|
(int)r,mach_error_string(r));
|
|
|
|
#else
|
|
|
|
ABORT("mach_msg failed while sending exception reply");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
} /* switch */
|
|
|
|
} /* for(;;) */
|
|
|
|
/* NOT REACHED */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All this SIGBUS code shouldn't be necessary. All protection faults should
|
|
|
|
be going throught the mach exception handler. However, it seems a SIGBUS is
|
|
|
|
occasionally sent for some unknown reason. Even more odd, it seems to be
|
|
|
|
meaningless and safe to ignore. */
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
|
|
|
|
typedef void (* SIG_PF)();
|
|
|
|
static SIG_PF GC_old_bus_handler;
|
|
|
|
|
|
|
|
/* Updates to this aren't atomic, but the SIGBUSs seem pretty rare.
|
|
|
|
Even if this doesn't get updated property, it isn't really a problem */
|
|
|
|
static int GC_sigbus_count;
|
|
|
|
|
|
|
|
static void GC_darwin_sigbus(int num,siginfo_t *sip,void *context) {
|
|
|
|
if(num != SIGBUS) ABORT("Got a non-sigbus signal in the sigbus handler");
|
|
|
|
|
|
|
|
/* Ugh... some seem safe to ignore, but too many in a row probably means
|
|
|
|
trouble. GC_sigbus_count is reset for each mach exception that is
|
|
|
|
handled */
|
|
|
|
if(GC_sigbus_count >= 8) {
|
|
|
|
ABORT("Got more than 8 SIGBUSs in a row!");
|
|
|
|
} else {
|
|
|
|
GC_sigbus_count++;
|
|
|
|
GC_err_printf0("GC: WARNING: Ignoring SIGBUS.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* BROKEN_EXCEPTION_HANDLING */
|
|
|
|
|
|
|
|
void GC_dirty_init() {
|
|
|
|
kern_return_t r;
|
|
|
|
mach_port_t me;
|
|
|
|
pthread_t thread;
|
|
|
|
pthread_attr_t attr;
|
|
|
|
exception_mask_t mask;
|
|
|
|
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_printf0("Inititalizing mach/darwin mprotect virtual dirty bit "
|
|
|
|
"implementation\n");
|
|
|
|
# endif
|
|
|
|
# ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
GC_err_printf0("GC: WARNING: Enabling workarounds for various darwin "
|
|
|
|
"exception handling bugs.\n");
|
|
|
|
# endif
|
|
|
|
GC_dirty_maintained = TRUE;
|
|
|
|
if (GC_page_size % HBLKSIZE != 0) {
|
|
|
|
GC_err_printf0("Page size not multiple of HBLKSIZE\n");
|
|
|
|
ABORT("Page size not multiple of HBLKSIZE");
|
|
|
|
}
|
|
|
|
|
|
|
|
GC_task_self = me = mach_task_self();
|
|
|
|
|
|
|
|
r = mach_port_allocate(me,MACH_PORT_RIGHT_RECEIVE,&GC_ports.exception);
|
|
|
|
if(r != KERN_SUCCESS) ABORT("mach_port_allocate failed (exception port)");
|
|
|
|
|
|
|
|
r = mach_port_insert_right(me,GC_ports.exception,GC_ports.exception,
|
|
|
|
MACH_MSG_TYPE_MAKE_SEND);
|
|
|
|
if(r != KERN_SUCCESS)
|
|
|
|
ABORT("mach_port_insert_right failed (exception port)");
|
|
|
|
|
|
|
|
#if defined(THREADS)
|
|
|
|
r = mach_port_allocate(me,MACH_PORT_RIGHT_RECEIVE,&GC_ports.reply);
|
|
|
|
if(r != KERN_SUCCESS) ABORT("mach_port_allocate failed (reply port)");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The exceptions we want to catch */
|
|
|
|
mask = EXC_MASK_BAD_ACCESS;
|
|
|
|
|
|
|
|
r = task_get_exception_ports(
|
|
|
|
me,
|
|
|
|
mask,
|
|
|
|
GC_old_exc_ports.masks,
|
|
|
|
&GC_old_exc_ports.count,
|
|
|
|
GC_old_exc_ports.ports,
|
|
|
|
GC_old_exc_ports.behaviors,
|
|
|
|
GC_old_exc_ports.flavors
|
|
|
|
);
|
|
|
|
if(r != KERN_SUCCESS) ABORT("task_get_exception_ports failed");
|
|
|
|
|
|
|
|
r = task_set_exception_ports(
|
|
|
|
me,
|
|
|
|
mask,
|
|
|
|
GC_ports.exception,
|
|
|
|
EXCEPTION_DEFAULT,
|
2007-01-11 21:06:45 +01:00
|
|
|
GC_MACH_THREAD_STATE
|
2003-07-28 06:18:23 +02:00
|
|
|
);
|
|
|
|
if(r != KERN_SUCCESS) ABORT("task_set_exception_ports failed");
|
|
|
|
|
|
|
|
if(pthread_attr_init(&attr) != 0) ABORT("pthread_attr_init failed");
|
|
|
|
if(pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED) != 0)
|
|
|
|
ABORT("pthread_attr_setdetachedstate failed");
|
|
|
|
|
|
|
|
# undef pthread_create
|
|
|
|
/* This will call the real pthread function, not our wrapper */
|
|
|
|
if(pthread_create(&thread,&attr,GC_mprotect_thread,NULL) != 0)
|
|
|
|
ABORT("pthread_create failed");
|
|
|
|
pthread_attr_destroy(&attr);
|
|
|
|
|
|
|
|
/* Setup the sigbus handler for ignoring the meaningless SIGBUSs */
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
{
|
|
|
|
struct sigaction sa, oldsa;
|
|
|
|
sa.sa_handler = (SIG_PF)GC_darwin_sigbus;
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
|
|
|
if(sigaction(SIGBUS,&sa,&oldsa) < 0) ABORT("sigaction");
|
|
|
|
GC_old_bus_handler = (SIG_PF)oldsa.sa_handler;
|
|
|
|
if (GC_old_bus_handler != SIG_DFL) {
|
|
|
|
# ifdef PRINTSTATS
|
|
|
|
GC_err_printf0("Replaced other SIGBUS handler\n");
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* BROKEN_EXCEPTION_HANDLING */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The source code for Apple's GDB was used as a reference for the exception
|
|
|
|
forwarding code. This code is similar to be GDB code only because there is
|
|
|
|
only one way to do it. */
|
|
|
|
static kern_return_t GC_forward_exception(
|
|
|
|
mach_port_t thread,
|
|
|
|
mach_port_t task,
|
|
|
|
exception_type_t exception,
|
|
|
|
exception_data_t data,
|
|
|
|
mach_msg_type_number_t data_count
|
|
|
|
) {
|
|
|
|
int i;
|
|
|
|
kern_return_t r;
|
|
|
|
mach_port_t port;
|
|
|
|
exception_behavior_t behavior;
|
|
|
|
thread_state_flavor_t flavor;
|
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
thread_state_t thread_state;
|
2003-07-28 06:18:23 +02:00
|
|
|
mach_msg_type_number_t thread_state_count = THREAD_STATE_MAX;
|
|
|
|
|
|
|
|
for(i=0;i<GC_old_exc_ports.count;i++)
|
|
|
|
if(GC_old_exc_ports.masks[i] & (1 << exception))
|
|
|
|
break;
|
|
|
|
if(i==GC_old_exc_ports.count) ABORT("No handler for exception!");
|
|
|
|
|
|
|
|
port = GC_old_exc_ports.ports[i];
|
|
|
|
behavior = GC_old_exc_ports.behaviors[i];
|
|
|
|
flavor = GC_old_exc_ports.flavors[i];
|
|
|
|
|
|
|
|
if(behavior != EXCEPTION_DEFAULT) {
|
|
|
|
r = thread_get_state(thread,flavor,thread_state,&thread_state_count);
|
|
|
|
if(r != KERN_SUCCESS)
|
|
|
|
ABORT("thread_get_state failed in forward_exception");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(behavior) {
|
|
|
|
case EXCEPTION_DEFAULT:
|
|
|
|
r = exception_raise(port,thread,task,exception,data,data_count);
|
|
|
|
break;
|
|
|
|
case EXCEPTION_STATE:
|
|
|
|
r = exception_raise_state(port,thread,task,exception,data,
|
|
|
|
data_count,&flavor,thread_state,thread_state_count,
|
|
|
|
thread_state,&thread_state_count);
|
|
|
|
break;
|
|
|
|
case EXCEPTION_STATE_IDENTITY:
|
|
|
|
r = exception_raise_state_identity(port,thread,task,exception,data,
|
|
|
|
data_count,&flavor,thread_state,thread_state_count,
|
|
|
|
thread_state,&thread_state_count);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
r = KERN_FAILURE; /* make gcc happy */
|
|
|
|
ABORT("forward_exception: unknown behavior");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(behavior != EXCEPTION_DEFAULT) {
|
|
|
|
r = thread_set_state(thread,flavor,thread_state,thread_state_count);
|
|
|
|
if(r != KERN_SUCCESS)
|
|
|
|
ABORT("thread_set_state failed in forward_exception");
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FWD() GC_forward_exception(thread,task,exception,code,code_count)
|
|
|
|
|
|
|
|
/* This violates the namespace rules but there isn't anything that can be done
|
|
|
|
about it. The exception handling stuff is hard coded to call this */
|
|
|
|
kern_return_t
|
|
|
|
catch_exception_raise(
|
|
|
|
mach_port_t exception_port,mach_port_t thread,mach_port_t task,
|
|
|
|
exception_type_t exception,exception_data_t code,
|
|
|
|
mach_msg_type_number_t code_count
|
|
|
|
) {
|
|
|
|
kern_return_t r;
|
|
|
|
char *addr;
|
|
|
|
struct hblk *h;
|
|
|
|
int i;
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(POWERPC)
|
|
|
|
# if CPP_WORDSZ == 32
|
|
|
|
thread_state_flavor_t flavor = PPC_EXCEPTION_STATE;
|
|
|
|
mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE_COUNT;
|
|
|
|
ppc_exception_state_t exc_state;
|
|
|
|
# else
|
|
|
|
thread_state_flavor_t flavor = PPC_EXCEPTION_STATE64;
|
|
|
|
mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE64_COUNT;
|
|
|
|
ppc_exception_state64_t exc_state;
|
|
|
|
# endif
|
2007-01-11 21:06:45 +01:00
|
|
|
# elif defined(I386) || defined(X86_64)
|
|
|
|
# if CPP_WORDSZ == 32
|
|
|
|
thread_state_flavor_t flavor = x86_EXCEPTION_STATE32;
|
|
|
|
mach_msg_type_number_t exc_state_count = x86_EXCEPTION_STATE32_COUNT;
|
2007-01-15 22:24:42 +01:00
|
|
|
x86_exception_state32_t exc_state;
|
2007-01-11 21:06:45 +01:00
|
|
|
# else
|
|
|
|
thread_state_flavor_t flavor = x86_EXCEPTION_STATE64;
|
|
|
|
mach_msg_type_number_t exc_state_count = x86_EXCEPTION_STATE64_COUNT;
|
|
|
|
x86_exception_state64_t exc_state;
|
|
|
|
# endif
|
2006-01-25 04:03:14 +01:00
|
|
|
# else
|
2003-07-28 06:18:23 +02:00
|
|
|
# error FIXME for non-ppc darwin
|
2006-01-25 04:03:14 +01:00
|
|
|
# endif
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
if(exception != EXC_BAD_ACCESS || code[0] != KERN_PROTECTION_FAILURE) {
|
|
|
|
#ifdef DEBUG_EXCEPTION_HANDLING
|
|
|
|
/* We aren't interested, pass it on to the old handler */
|
|
|
|
GC_printf3("Exception: 0x%x Code: 0x%x 0x%x in catch....\n",
|
|
|
|
exception,
|
|
|
|
code_count > 0 ? code[0] : -1,
|
|
|
|
code_count > 1 ? code[1] : -1);
|
|
|
|
#endif
|
|
|
|
return FWD();
|
|
|
|
}
|
|
|
|
|
|
|
|
r = thread_get_state(thread,flavor,
|
|
|
|
(natural_t*)&exc_state,&exc_state_count);
|
|
|
|
if(r != KERN_SUCCESS) {
|
|
|
|
/* The thread is supposed to be suspended while the exception handler
|
|
|
|
is called. This shouldn't fail. */
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
GC_err_printf0("thread_get_state failed in "
|
|
|
|
"catch_exception_raise\n");
|
|
|
|
return KERN_SUCCESS;
|
|
|
|
#else
|
|
|
|
ABORT("thread_get_state failed in catch_exception_raise");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the address that caused the fault */
|
2006-09-22 01:47:30 +02:00
|
|
|
#if defined(POWERPC)
|
2007-01-19 20:19:35 +01:00
|
|
|
addr = (char*) exc_state. THREAD_FLD(dar);
|
2007-01-11 21:06:45 +01:00
|
|
|
#elif defined (I386) || defined (X86_64)
|
2007-01-17 21:12:51 +01:00
|
|
|
addr = (char*) exc_state. THREAD_FLD(faultvaddr);
|
2006-09-22 01:47:30 +02:00
|
|
|
#else
|
|
|
|
# error FIXME for non POWERPC/I386
|
|
|
|
#endif
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
if((HDR(addr)) == 0) {
|
|
|
|
/* Ugh... just like the SIGBUS problem above, it seems we get a bogus
|
|
|
|
KERN_PROTECTION_FAILURE every once and a while. We wait till we get
|
|
|
|
a bunch in a row before doing anything about it. If a "real" fault
|
|
|
|
ever occurres it'll just keep faulting over and over and we'll hit
|
|
|
|
the limit pretty quickly. */
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
static char *last_fault;
|
|
|
|
static int last_fault_count;
|
|
|
|
|
|
|
|
if(addr != last_fault) {
|
|
|
|
last_fault = addr;
|
|
|
|
last_fault_count = 0;
|
|
|
|
}
|
|
|
|
if(++last_fault_count < 32) {
|
|
|
|
if(last_fault_count == 1)
|
|
|
|
GC_err_printf1(
|
|
|
|
"GC: WARNING: Ignoring KERN_PROTECTION_FAILURE at %p\n",
|
|
|
|
addr);
|
|
|
|
return KERN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
GC_err_printf1("Unexpected KERN_PROTECTION_FAILURE at %p\n",addr);
|
|
|
|
/* Can't pass it along to the signal handler because that is
|
|
|
|
ignoring SIGBUS signals. We also shouldn't call ABORT here as
|
|
|
|
signals don't always work too well from the exception handler. */
|
|
|
|
GC_err_printf0("Aborting\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
#else /* BROKEN_EXCEPTION_HANDLING */
|
|
|
|
/* Pass it along to the next exception handler
|
|
|
|
(which should call SIGBUS/SIGSEGV) */
|
|
|
|
return FWD();
|
|
|
|
#endif /* !BROKEN_EXCEPTION_HANDLING */
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef BROKEN_EXCEPTION_HANDLING
|
|
|
|
/* Reset the number of consecutive SIGBUSs */
|
|
|
|
GC_sigbus_count = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(GC_mprotect_state == GC_MP_NORMAL) { /* common case */
|
|
|
|
h = (struct hblk*)((word)addr & ~(GC_page_size-1));
|
|
|
|
UNPROTECT(h, GC_page_size);
|
|
|
|
for (i = 0; i < divHBLKSZ(GC_page_size); i++) {
|
|
|
|
register int index = PHT_HASH(h+i);
|
|
|
|
async_set_pht_entry_from_index(GC_dirty_pages, index);
|
|
|
|
}
|
|
|
|
} else if(GC_mprotect_state == GC_MP_DISCARDING) {
|
|
|
|
/* Lie to the thread for now. No sense UNPROTECT()ing the memory
|
|
|
|
when we're just going to PROTECT() it again later. The thread
|
|
|
|
will just fault again once it resumes */
|
|
|
|
} else {
|
|
|
|
/* Shouldn't happen, i don't think */
|
|
|
|
GC_printf0("KERN_PROTECTION_FAILURE while world is stopped\n");
|
|
|
|
return FWD();
|
|
|
|
}
|
|
|
|
return KERN_SUCCESS;
|
|
|
|
}
|
|
|
|
#undef FWD
|
|
|
|
|
|
|
|
/* These should never be called, but just in case... */
|
|
|
|
kern_return_t catch_exception_raise_state(mach_port_name_t exception_port,
|
|
|
|
int exception, exception_data_t code, mach_msg_type_number_t codeCnt,
|
|
|
|
int flavor, thread_state_t old_state, int old_stateCnt,
|
|
|
|
thread_state_t new_state, int new_stateCnt)
|
|
|
|
{
|
|
|
|
ABORT("catch_exception_raise_state");
|
|
|
|
return(KERN_INVALID_ARGUMENT);
|
|
|
|
}
|
|
|
|
kern_return_t catch_exception_raise_state_identity(
|
|
|
|
mach_port_name_t exception_port, mach_port_t thread, mach_port_t task,
|
|
|
|
int exception, exception_data_t code, mach_msg_type_number_t codeCnt,
|
|
|
|
int flavor, thread_state_t old_state, int old_stateCnt,
|
|
|
|
thread_state_t new_state, int new_stateCnt)
|
|
|
|
{
|
|
|
|
ABORT("catch_exception_raise_state_identity");
|
|
|
|
return(KERN_INVALID_ARGUMENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* DARWIN && MPROTECT_VDB */
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
# ifndef HAVE_INCREMENTAL_PROTECTION_NEEDS
|
|
|
|
int GC_incremental_protection_needs()
|
|
|
|
{
|
|
|
|
return GC_PROTECTS_NONE;
|
|
|
|
}
|
|
|
|
# endif /* !HAVE_INCREMENTAL_PROTECTION_NEEDS */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
/*
|
|
|
|
* Call stack save code for debugging.
|
|
|
|
* Should probably be in mach_dep.c, but that requires reorganization.
|
|
|
|
*/
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
/* I suspect the following works for most X86 *nix variants, so */
|
|
|
|
/* long as the frame pointer is explicitly stored. In the case of gcc, */
|
|
|
|
/* compiler flags (e.g. -fomit-frame-pointer) determine whether it is. */
|
|
|
|
#if defined(I386) && defined(LINUX) && defined(SAVE_CALL_CHAIN)
|
2002-02-12 05:37:57 +01:00
|
|
|
# include <features.h>
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
struct frame {
|
|
|
|
struct frame *fr_savfp;
|
|
|
|
long fr_savpc;
|
|
|
|
long fr_arg[NARGS]; /* All the arguments go here. */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2000-04-27 02:43:33 +02:00
|
|
|
#if defined(SPARC)
|
|
|
|
# if defined(LINUX)
|
2002-02-12 05:37:57 +01:00
|
|
|
# include <features.h>
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
struct frame {
|
2000-04-27 02:43:33 +02:00
|
|
|
long fr_local[8];
|
|
|
|
long fr_arg[6];
|
|
|
|
struct frame *fr_savfp;
|
|
|
|
long fr_savpc;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifndef __arch64__
|
|
|
|
char *fr_stret;
|
|
|
|
# endif
|
2000-04-27 02:43:33 +02:00
|
|
|
long fr_argd[6];
|
|
|
|
long fr_argx[0];
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
};
|
2000-04-27 02:43:33 +02:00
|
|
|
# else
|
|
|
|
# if defined(SUNOS4)
|
|
|
|
# include <machine/frame.h>
|
|
|
|
# else
|
|
|
|
# if defined (DRSNX)
|
|
|
|
# include <sys/sparc/frame.h>
|
|
|
|
# else
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(OPENBSD)
|
2000-04-27 02:43:33 +02:00
|
|
|
# include <frame.h>
|
|
|
|
# else
|
2006-01-25 04:03:14 +01:00
|
|
|
# if defined(FREEBSD) || defined(NETBSD)
|
|
|
|
# include <machine/frame.h>
|
|
|
|
# else
|
|
|
|
# include <sys/frame.h>
|
|
|
|
# endif
|
2000-04-27 02:43:33 +02:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# if NARGS > 6
|
1999-04-07 10:01:40 +02:00
|
|
|
--> We only know how to to get the first 6 arguments
|
2000-04-27 02:43:33 +02:00
|
|
|
# endif
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
#endif /* SPARC */
|
1999-04-07 10:01:40 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#ifdef NEED_CALLINFO
|
1999-04-07 10:01:40 +02:00
|
|
|
/* Fill in the pc and argument information for up to NFRAMES of my */
|
|
|
|
/* callers. Ignore my frame and my callers frame. */
|
1999-11-02 00:15:51 +01:00
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#ifdef LINUX
|
2003-07-28 06:18:23 +02:00
|
|
|
# include <unistd.h>
|
2002-02-12 05:37:57 +01:00
|
|
|
#endif
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#endif /* NEED_CALLINFO */
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
#if defined(GC_HAVE_BUILTIN_BACKTRACE)
|
|
|
|
# include <execinfo.h>
|
|
|
|
#endif
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#ifdef SAVE_CALL_CHAIN
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#if NARGS == 0 && NFRAMES % 2 == 0 /* No padding */ \
|
2003-07-28 06:18:23 +02:00
|
|
|
&& defined(GC_HAVE_BUILTIN_BACKTRACE)
|
2002-02-12 05:37:57 +01:00
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
#ifdef REDIRECT_MALLOC
|
|
|
|
/* Deal with possible malloc calls in backtrace by omitting */
|
|
|
|
/* the infinitely recursing backtrace. */
|
|
|
|
# ifdef THREADS
|
|
|
|
__thread /* If your compiler doesn't understand this */
|
|
|
|
/* you could use something like pthread_getspecific. */
|
|
|
|
# endif
|
|
|
|
GC_in_save_callers = FALSE;
|
|
|
|
#endif
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
void GC_save_callers (info)
|
|
|
|
struct callinfo info[NFRAMES];
|
|
|
|
{
|
|
|
|
void * tmp_info[NFRAMES + 1];
|
|
|
|
int npcs, i;
|
|
|
|
# define IGNORE_FRAMES 1
|
|
|
|
|
|
|
|
/* We retrieve NFRAMES+1 pc values, but discard the first, since it */
|
|
|
|
/* points to our own frame. */
|
2006-01-25 04:03:14 +01:00
|
|
|
# ifdef REDIRECT_MALLOC
|
|
|
|
if (GC_in_save_callers) {
|
|
|
|
info[0].ci_pc = (word)(&GC_save_callers);
|
|
|
|
for (i = 1; i < NFRAMES; ++i) info[i].ci_pc = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GC_in_save_callers = TRUE;
|
|
|
|
# endif
|
2002-02-12 05:37:57 +01:00
|
|
|
GC_ASSERT(sizeof(struct callinfo) == sizeof(void *));
|
|
|
|
npcs = backtrace((void **)tmp_info, NFRAMES + IGNORE_FRAMES);
|
|
|
|
BCOPY(tmp_info+IGNORE_FRAMES, info, (npcs - IGNORE_FRAMES) * sizeof(void *));
|
|
|
|
for (i = npcs - IGNORE_FRAMES; i < NFRAMES; ++i) info[i].ci_pc = 0;
|
2006-01-25 04:03:14 +01:00
|
|
|
# ifdef REDIRECT_MALLOC
|
|
|
|
GC_in_save_callers = FALSE;
|
|
|
|
# endif
|
2002-02-12 05:37:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* No builtin backtrace; do it ourselves */
|
|
|
|
|
2006-01-25 04:03:14 +01:00
|
|
|
#if (defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD)) && defined(SPARC)
|
1999-11-02 00:15:51 +01:00
|
|
|
# define FR_SAVFP fr_fp
|
|
|
|
# define FR_SAVPC fr_pc
|
|
|
|
#else
|
|
|
|
# define FR_SAVFP fr_savfp
|
|
|
|
# define FR_SAVPC fr_savpc
|
|
|
|
#endif
|
|
|
|
|
2000-04-27 02:43:33 +02:00
|
|
|
#if defined(SPARC) && (defined(__arch64__) || defined(__sparcv9))
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# define BIAS 2047
|
2000-04-27 02:43:33 +02:00
|
|
|
#else
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# define BIAS 0
|
2000-04-27 02:43:33 +02:00
|
|
|
#endif
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
void GC_save_callers (info)
|
|
|
|
struct callinfo info[NFRAMES];
|
|
|
|
{
|
|
|
|
struct frame *frame;
|
|
|
|
struct frame *fp;
|
|
|
|
int nframes = 0;
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
# ifdef I386
|
|
|
|
/* We assume this is turned on only with gcc as the compiler. */
|
|
|
|
asm("movl %%ebp,%0" : "=r"(frame));
|
|
|
|
fp = frame;
|
|
|
|
# else
|
|
|
|
frame = (struct frame *) GC_save_regs_in_stack ();
|
|
|
|
fp = (struct frame *)((long) frame -> FR_SAVFP + BIAS);
|
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
for (; (!(fp HOTTER_THAN frame) && !(GC_stackbottom HOTTER_THAN (ptr_t)fp)
|
|
|
|
&& (nframes < NFRAMES));
|
2000-04-27 02:43:33 +02:00
|
|
|
fp = (struct frame *)((long) fp -> FR_SAVFP + BIAS), nframes++) {
|
1999-04-07 10:01:40 +02:00
|
|
|
register int i;
|
|
|
|
|
1999-11-02 00:15:51 +01:00
|
|
|
info[nframes].ci_pc = fp->FR_SAVPC;
|
2001-08-18 03:04:43 +02:00
|
|
|
# if NARGS > 0
|
|
|
|
for (i = 0; i < NARGS; i++) {
|
|
|
|
info[nframes].ci_arg[i] = ~(fp->fr_arg[i]);
|
|
|
|
}
|
|
|
|
# endif /* NARGS > 0 */
|
1999-04-07 10:01:40 +02:00
|
|
|
}
|
|
|
|
if (nframes < NFRAMES) info[nframes].ci_pc = 0;
|
|
|
|
}
|
|
|
|
|
2002-02-12 05:37:57 +01:00
|
|
|
#endif /* No builtin backtrace */
|
|
|
|
|
1999-04-07 10:01:40 +02:00
|
|
|
#endif /* SAVE_CALL_CHAIN */
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
#ifdef NEED_CALLINFO
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
/* Print info to stderr. We do NOT hold the allocation lock */
|
|
|
|
void GC_print_callers (info)
|
|
|
|
struct callinfo info[NFRAMES];
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
{
|
2003-07-28 06:18:23 +02:00
|
|
|
register int i;
|
|
|
|
static int reentry_count = 0;
|
|
|
|
GC_bool stop = FALSE;
|
|
|
|
|
2004-08-14 01:05:36 +02:00
|
|
|
/* FIXME: This should probably use a different lock, so that we */
|
|
|
|
/* become callable with or without the allocation lock. */
|
2003-07-28 06:18:23 +02:00
|
|
|
LOCK();
|
|
|
|
++reentry_count;
|
|
|
|
UNLOCK();
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
# if NFRAMES == 1
|
|
|
|
GC_err_printf0("\tCaller at allocation:\n");
|
|
|
|
# else
|
|
|
|
GC_err_printf0("\tCall chain at allocation:\n");
|
|
|
|
# endif
|
|
|
|
for (i = 0; i < NFRAMES && !stop ; i++) {
|
|
|
|
if (info[i].ci_pc == 0) break;
|
|
|
|
# if NARGS > 0
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
GC_err_printf0("\t\targs: ");
|
|
|
|
for (j = 0; j < NARGS; j++) {
|
|
|
|
if (j != 0) GC_err_printf0(", ");
|
|
|
|
GC_err_printf2("%d (0x%X)", ~(info[i].ci_arg[j]),
|
|
|
|
~(info[i].ci_arg[j]));
|
|
|
|
}
|
|
|
|
GC_err_printf0("\n");
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
if (reentry_count > 1) {
|
|
|
|
/* We were called during an allocation during */
|
|
|
|
/* a previous GC_print_callers call; punt. */
|
|
|
|
GC_err_printf1("\t\t##PC##= 0x%lx\n", info[i].ci_pc);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# ifdef LINUX
|
|
|
|
FILE *pipe;
|
|
|
|
# endif
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(GC_HAVE_BUILTIN_BACKTRACE) \
|
|
|
|
&& !defined(GC_BACKTRACE_SYMBOLS_BROKEN)
|
2003-07-28 06:18:23 +02:00
|
|
|
char **sym_name =
|
|
|
|
backtrace_symbols((void **)(&(info[i].ci_pc)), 1);
|
|
|
|
char *name = sym_name[0];
|
|
|
|
# else
|
|
|
|
char buf[40];
|
|
|
|
char *name = buf;
|
|
|
|
sprintf(buf, "##PC##= 0x%lx", info[i].ci_pc);
|
|
|
|
# endif
|
|
|
|
# if defined(LINUX) && !defined(SMALL_CONFIG)
|
|
|
|
/* Try for a line number. */
|
|
|
|
{
|
|
|
|
# define EXE_SZ 100
|
|
|
|
static char exe_name[EXE_SZ];
|
|
|
|
# define CMD_SZ 200
|
|
|
|
char cmd_buf[CMD_SZ];
|
|
|
|
# define RESULT_SZ 200
|
|
|
|
static char result_buf[RESULT_SZ];
|
|
|
|
size_t result_len;
|
2004-08-14 01:05:36 +02:00
|
|
|
char *old_preload;
|
|
|
|
# define PRELOAD_SZ 200
|
|
|
|
char preload_buf[PRELOAD_SZ];
|
2003-07-28 06:18:23 +02:00
|
|
|
static GC_bool found_exe_name = FALSE;
|
|
|
|
static GC_bool will_fail = FALSE;
|
|
|
|
int ret_code;
|
|
|
|
/* Try to get it via a hairy and expensive scheme. */
|
|
|
|
/* First we get the name of the executable: */
|
|
|
|
if (will_fail) goto out;
|
|
|
|
if (!found_exe_name) {
|
|
|
|
ret_code = readlink("/proc/self/exe", exe_name, EXE_SZ);
|
|
|
|
if (ret_code < 0 || ret_code >= EXE_SZ
|
|
|
|
|| exe_name[0] != '/') {
|
|
|
|
will_fail = TRUE; /* Dont try again. */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
exe_name[ret_code] = '\0';
|
|
|
|
found_exe_name = TRUE;
|
|
|
|
}
|
|
|
|
/* Then we use popen to start addr2line -e <exe> <addr> */
|
|
|
|
/* There are faster ways to do this, but hopefully this */
|
|
|
|
/* isn't time critical. */
|
|
|
|
sprintf(cmd_buf, "/usr/bin/addr2line -f -e %s 0x%lx", exe_name,
|
|
|
|
(unsigned long)info[i].ci_pc);
|
2004-08-14 01:05:36 +02:00
|
|
|
old_preload = getenv ("LD_PRELOAD");
|
|
|
|
if (0 != old_preload) {
|
|
|
|
if (strlen (old_preload) >= PRELOAD_SZ) {
|
|
|
|
will_fail = TRUE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
strcpy (preload_buf, old_preload);
|
|
|
|
unsetenv ("LD_PRELOAD");
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
pipe = popen(cmd_buf, "r");
|
2004-08-14 01:05:36 +02:00
|
|
|
if (0 != old_preload
|
|
|
|
&& 0 != setenv ("LD_PRELOAD", preload_buf, 0)) {
|
|
|
|
WARN("Failed to reset LD_PRELOAD\n", 0);
|
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
if (pipe == NULL
|
|
|
|
|| (result_len = fread(result_buf, 1, RESULT_SZ - 1, pipe))
|
|
|
|
== 0) {
|
|
|
|
if (pipe != NULL) pclose(pipe);
|
|
|
|
will_fail = TRUE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (result_buf[result_len - 1] == '\n') --result_len;
|
|
|
|
result_buf[result_len] = 0;
|
|
|
|
if (result_buf[0] == '?'
|
|
|
|
|| result_buf[result_len-2] == ':'
|
|
|
|
&& result_buf[result_len-1] == '0') {
|
|
|
|
pclose(pipe);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* Get rid of embedded newline, if any. Test for "main" */
|
|
|
|
{
|
|
|
|
char * nl = strchr(result_buf, '\n');
|
|
|
|
if (nl != NULL && nl < result_buf + result_len) {
|
|
|
|
*nl = ':';
|
|
|
|
}
|
|
|
|
if (strncmp(result_buf, "main", nl - result_buf) == 0) {
|
|
|
|
stop = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (result_len < RESULT_SZ - 25) {
|
|
|
|
/* Add in hex address */
|
|
|
|
sprintf(result_buf + result_len, " [0x%lx]",
|
|
|
|
(unsigned long)info[i].ci_pc);
|
|
|
|
}
|
|
|
|
name = result_buf;
|
|
|
|
pclose(pipe);
|
|
|
|
out:;
|
|
|
|
}
|
|
|
|
# endif /* LINUX */
|
|
|
|
GC_err_printf1("\t\t%s\n", name);
|
2004-08-14 01:05:36 +02:00
|
|
|
# if defined(GC_HAVE_BUILTIN_BACKTRACE) \
|
|
|
|
&& !defined(GC_BACKTRACE_SYMBOLS_BROKEN)
|
2003-07-28 06:18:23 +02:00
|
|
|
free(sym_name); /* May call GC_free; that's OK */
|
|
|
|
# endif
|
|
|
|
}
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
LOCK();
|
|
|
|
--reentry_count;
|
|
|
|
UNLOCK();
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
}
|
2003-07-28 06:18:23 +02:00
|
|
|
|
|
|
|
#endif /* NEED_CALLINFO */
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
#if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG)
|
|
|
|
|
|
|
|
/* Dump /proc/self/maps to GC_stderr, to enable looking up names for
|
|
|
|
addresses in FIND_LEAK output. */
|
|
|
|
|
2003-07-28 06:18:23 +02:00
|
|
|
static word dump_maps(char *maps)
|
|
|
|
{
|
|
|
|
GC_err_write(maps, strlen(maps));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
void GC_print_address_map()
|
|
|
|
{
|
|
|
|
GC_err_printf0("---------- Begin address map ----------\n");
|
2003-07-28 06:18:23 +02:00
|
|
|
GC_apply_to_maps(dump_maps);
|
Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
README.amiga, README.debugging, README.dj, README.hp, README.linux,
README.rs6000, README.sgi, README.solaris2, README.uts,
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
hpux_irix_threads.c, makefile.depend, nursery.c,
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
files.
From-SVN: r42379
2001-05-21 10:35:14 +02:00
|
|
|
GC_err_printf0("---------- End address map ----------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
1999-04-07 10:01:40 +02:00
|
|
|
|
|
|
|
|