aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@gcc.gnu.org>2000-05-06 23:59:01 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-05-06 23:59:01 +0000
commitfe95091e7140c6e3979bd2d2d6b6525d2f871b08 (patch)
tree6fc427ce7f6740d21e25abe2c391bfb4f9231260
parent4309bfec6e7f6cc9d783b1627d77c3536c2ee7ab (diff)
Imported Boehm GC 5.0alpha7
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/boehm@33746 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--boehm-gc/NT_MAKEFILE4
-rw-r--r--boehm-gc/dbg_mlc.c26
-rw-r--r--boehm-gc/dyn_load.c19
-rw-r--r--boehm-gc/finalize.c2
-rw-r--r--boehm-gc/gcj_mlc.c4
-rw-r--r--boehm-gc/include/gc_cpp.h10
-rw-r--r--boehm-gc/include/private/gc_priv.h2
-rw-r--r--boehm-gc/include/private/gcconfig.h13
-rw-r--r--boehm-gc/linux_threads.c4
-rw-r--r--boehm-gc/mark.c17
-rw-r--r--boehm-gc/os_dep.c35
-rw-r--r--boehm-gc/reclaim.c9
-rw-r--r--boehm-gc/version.h2
13 files changed, 95 insertions, 52 deletions
diff --git a/boehm-gc/NT_MAKEFILE b/boehm-gc/NT_MAKEFILE
index 52f6f4ae3a0..a642262a9ca 100644
--- a/boehm-gc/NT_MAKEFILE
+++ b/boehm-gc/NT_MAKEFILE
@@ -10,10 +10,10 @@ OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_r
all: gctest.exe cord\de.exe test_cpp.exe
.c.obj:
- $(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
+ $(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
.cpp.obj:
- $(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
+ $(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
diff --git a/boehm-gc/dbg_mlc.c b/boehm-gc/dbg_mlc.c
index d8dca25d765..20768715493 100644
--- a/boehm-gc/dbg_mlc.c
+++ b/boehm-gc/dbg_mlc.c
@@ -399,7 +399,31 @@ GC_PTR p;
GC_end_stubborn_change(q);
}
-#endif /* STUBBORN_ALLOC */
+#else /* !STUBBORN_ALLOC */
+
+# ifdef __STDC__
+ GC_PTR GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
+# else
+ GC_PTR GC_debug_malloc_stubborn(lb, s, i)
+ size_t lb;
+ char * s;
+ int i;
+# endif
+{
+ return GC_debug_malloc(lb, OPT_RA s, i);
+}
+
+void GC_debug_change_stubborn(p)
+GC_PTR p;
+{
+}
+
+void GC_debug_end_stubborn_change(p)
+GC_PTR p;
+{
+}
+
+#endif /* !STUBBORN_ALLOC */
# ifdef __STDC__
GC_PTR GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
diff --git a/boehm-gc/dyn_load.c b/boehm-gc/dyn_load.c
index f812843272e..8d00346c790 100644
--- a/boehm-gc/dyn_load.c
+++ b/boehm-gc/dyn_load.c
@@ -161,14 +161,6 @@ static ptr_t GC_first_common()
#endif /* SUNOS4 ... */
-# if defined(SUNOS4) || defined(SUNOS5DL)
-/* Add dynamic library data sections to the root set. */
-# if !defined(PCR) && !defined(SOLARIS_THREADS) && defined(THREADS)
-# ifndef SRC_M3
- --> fix mutual exclusion with dlopen
-# endif /* We assume M3 programs don't call dlopen for now */
-# endif
-
# if defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \
|| defined(HPUX_THREADS) || defined(IRIX_THREADS)
/* Make sure we're not in the middle of a collection, and make */
@@ -187,7 +179,7 @@ static ptr_t GC_first_common()
GC_bool result;
LOCK();
result = GC_dont_gc;
- while (GC_incremental && GC_collection_inProgress()) {
+ while (GC_incremental && GC_collection_in_progress()) {
GC_collect_a_little_inner(1000);
}
GC_dont_gc = TRUE;
@@ -195,7 +187,6 @@ static ptr_t GC_first_common()
return(result);
}
-
/* Redefine dlopen to guarantee mutual exclusion with */
/* GC_register_dynamic_libraries. */
/* Should probably happen for other operating systems, too. */
@@ -233,6 +224,14 @@ static ptr_t GC_first_common()
# define dlopen GC_dlopen
# endif
+# if defined(SUNOS4) || defined(SUNOS5DL)
+/* Add dynamic library data sections to the root set. */
+# if !defined(PCR) && !defined(SOLARIS_THREADS) && defined(THREADS)
+# ifndef SRC_M3
+ --> fix mutual exclusion with dlopen
+# endif /* We assume M3 programs don't call dlopen for now */
+# endif
+
# ifndef USE_PROC_FOR_LIBRARIES
void GC_register_dynamic_libraries()
{
diff --git a/boehm-gc/finalize.c b/boehm-gc/finalize.c
index 1ab56cee82e..e70a9ff1e99 100644
--- a/boehm-gc/finalize.c
+++ b/boehm-gc/finalize.c
@@ -619,7 +619,7 @@ void GC_finalize()
void GC_enqueue_all_finalizers()
{
struct finalizable_object * curr_fo, * prev_fo, * next_fo;
- ptr_t real_ptr, real_link;
+ ptr_t real_ptr;
register int i;
int fo_size;
diff --git a/boehm-gc/gcj_mlc.c b/boehm-gc/gcj_mlc.c
index ba51cbe498f..eb67eac1f36 100644
--- a/boehm-gc/gcj_mlc.c
+++ b/boehm-gc/gcj_mlc.c
@@ -282,4 +282,8 @@ DCL_LOCK_STATE;
return((GC_PTR) op);
}
+#else
+
+char GC_no_gcj_support;
+
#endif /* GC_GCJ_SUPPORT */
diff --git a/boehm-gc/include/gc_cpp.h b/boehm-gc/include/gc_cpp.h
index 36013e135b9..35686fc3527 100644
--- a/boehm-gc/include/gc_cpp.h
+++ b/boehm-gc/include/gc_cpp.h
@@ -255,12 +255,12 @@ inline gc_cleanup::gc_cleanup() {
GC_finalization_proc oldProc;
void* oldData;
void* base = GC_base( (void *) this );
- if (0 == base) return;
- GC_REGISTER_FINALIZER_IGNORE_SELF(
- base, cleanup, (void*) ((char*) this - (char*) base),
+ if (0 != base) {
+ GC_REGISTER_FINALIZER_IGNORE_SELF(
+ base, (GC_finalization_proc)cleanup, (void*) ((char*) this - (char*) base),
&oldProc, &oldData );
- if (0 != oldProc) {
- GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}}
+ if (0 != oldProc) {
+ GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}}}
inline void* operator new(
size_t size,
diff --git a/boehm-gc/include/private/gc_priv.h b/boehm-gc/include/private/gc_priv.h
index eabb85f0c20..ce685875549 100644
--- a/boehm-gc/include/private/gc_priv.h
+++ b/boehm-gc/include/private/gc_priv.h
@@ -1405,7 +1405,7 @@ extern GC_bool GC_objects_are_marked; /* There are marked objects in */
extern GC_bool GC_incremental;
/* Using incremental/generational collection. */
#else
-# define GC_incremental TRUE
+# define GC_incremental FALSE
/* Hopefully allow optimizer to remove some code. */
#endif
diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h
index 4c4bca31222..045617a1d7b 100644
--- a/boehm-gc/include/private/gcconfig.h
+++ b/boehm-gc/include/private/gcconfig.h
@@ -386,6 +386,11 @@
* to the nearest plausible page boundary, and use that instead
* of STACKBOTTOM.
*
+ * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
+ * the value of environ is a pointer that can serve as STACKBOTTOM.
+ * I expect that HEURISTIC2 can be replaced by this approach, which
+ * interferes far less with debugging.
+ *
* If no expression for STACKBOTTOM can be found, and neither of the above
* heuristics are usable, the collector can still be used with all of the above
* undefined, provided one of the following is done:
@@ -553,6 +558,7 @@
/* This was 2, but that didn't sound right. */
# define OS_TYPE "LINUX"
# define HEURISTIC1
+# define DYNAMIC_LOADING
# undef STACK_GRAN
# define STACK_GRAN 0x10000000
/* Stack usually starts at 0x80000000 */
@@ -990,7 +996,11 @@
/* this.) */
# define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
# else
-# define HEURISTIC2
+ /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
+ /* to this. We'll probably do this on other platforms, too. */
+ /* For now I'll use it where I can test it. */
+ extern char ** environ;
+# define STACKBOTTOM ((ptr_t)environ)
# endif
# define STACK_GROWS_UP
# define DYNAMIC_LOADING
@@ -1076,7 +1086,6 @@
/* Requires Linux 2.3.47 or later. */
extern int _end;
# define DATAEND (&_end)
- /* PREFETCH appears to have a large performance impact. */
# define PREFETCH(x) \
__asm__ (" lfetch [%0]": : "r"((void *)(x)))
# define PREFETCH_FOR_WRITE(x) \
diff --git a/boehm-gc/linux_threads.c b/boehm-gc/linux_threads.c
index 7670268ec22..4b8088231c5 100644
--- a/boehm-gc/linux_threads.c
+++ b/boehm-gc/linux_threads.c
@@ -196,6 +196,7 @@ void GC_suspend_handler(int sig)
# ifdef NO_SIGNALS
if (sigdelset(&mask, SIGINT) != 0) ABORT("sigdelset() failed");
if (sigdelset(&mask, SIGQUIT) != 0) ABORT("sigdelset() failed");
+ if (sigdelset(&mask, SIGTERM) != 0) ABORT("sigdelset() failed");
# endif
do {
me->signal = 0;
@@ -476,7 +477,8 @@ void GC_thr_init()
}
# ifdef NO_SIGNALS
if (sigdelset(&act.sa_mask, SIGINT) != 0
- || sigdelset(&act.sa_mask, SIGQUIT != 0)) {
+ || sigdelset(&act.sa_mask, SIGQUIT != 0)
+ || sigdelset(&act.sa_mask, SIGTERM != 0)) {
ABORT("sigdelset() failed");
}
# endif
diff --git a/boehm-gc/mark.c b/boehm-gc/mark.c
index 827b219018d..216accf3237 100644
--- a/boehm-gc/mark.c
+++ b/boehm-gc/mark.c
@@ -493,7 +493,8 @@ void GC_mark_from_mark_stack()
if ((signed_word)descr < 0) {
current = *current_p;
if ((ptr_t)current >= least_ha && (ptr_t)current < greatest_ha) {
- PUSH_CONTENTS((ptr_t)current, GC_mark_stack_top_reg,
+ PREFETCH(current);
+ HC_PUSH_CONTENTS((ptr_t)current, GC_mark_stack_top_reg,
mark_stack_limit, current_p, exit1);
}
}
@@ -1113,6 +1114,7 @@ struct hblk *h;
register hdr * hhdr;
{
register int sz = hhdr -> hb_sz;
+ register int descr = hhdr -> hb_descr;
register word * p;
register int word_no;
register word * lim;
@@ -1120,19 +1122,14 @@ register hdr * hhdr;
register mse * mark_stack_limit = &(GC_mark_stack[GC_mark_stack_size]);
/* Some quick shortcuts: */
- {
- struct obj_kind *ok = &(GC_obj_kinds[hhdr -> hb_obj_kind]);
- if ((0 | DS_LENGTH) == ok -> ok_descriptor
- && FALSE == ok -> ok_relocate_descr)
- return;
- }
+ if ((0 | DS_LENGTH) == descr) return;
if (GC_block_empty(hhdr)/* nothing marked */) return;
# ifdef GATHERSTATS
GC_n_rescuing_pages++;
# endif
GC_objects_are_marked = TRUE;
if (sz > MAXOBJSZ) {
- lim = (word *)(h + 1);
+ lim = (word *)h + HDR_WORDS;
} else {
lim = (word *)(h + 1) - sz;
}
@@ -1155,10 +1152,6 @@ register hdr * hhdr;
GC_mark_stack_top_reg = GC_mark_stack_top;
for (p = (word *)h + HDR_WORDS, word_no = HDR_WORDS; p <= lim;
p += sz, word_no += sz) {
- /* This ignores user specified mark procs. This currently */
- /* doesn't matter, since marking from the whole object */
- /* is always sufficient, and we will eventually use the user */
- /* mark proc to avoid any bogus pointers. */
if (mark_bit_from_hdr(hhdr, word_no)) {
/* Mark from fields inside the object */
PUSH_OBJ((word *)p, hhdr, GC_mark_stack_top_reg, mark_stack_limit);
diff --git a/boehm-gc/os_dep.c b/boehm-gc/os_dep.c
index 6158906e88d..783ae41d4c4 100644
--- a/boehm-gc/os_dep.c
+++ b/boehm-gc/os_dep.c
@@ -598,31 +598,48 @@ ptr_t GC_get_stack_base()
#ifdef LINUX_STACKBOTTOM
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
# define STAT_SKIP 27 /* Number of fields preceding startstack */
/* field in /proc/self/stat */
ptr_t GC_linux_stack_base(void)
{
- FILE *f;
+ /* 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
+# ifdef USE_LD_WRAP
+# define STAT_READ __real_read
+# else
+# define STAT_READ read
+# endif
+ char stat_buf[STAT_BUF_SIZE];
+ int f;
char c;
word result = 0;
- int i;
+ size_t i, buf_offset = 0;
- f = fopen("/proc/self/stat", "r");
- if (NULL == f) ABORT("Couldn't open /proc/self/stat");
- c = getc(f);
+ f = open("/proc/self/stat", O_RDONLY);
+ if (f < 0 || read(f, stat_buf, STAT_BUF_SIZE) < 2 * STAT_SKIP) {
+ ABORT("Couldn't read /proc/self/stat");
+ }
+ c = stat_buf[buf_offset++];
/* Skip the required number of fields. This number is hopefully */
/* constant across all Linux implementations. */
for (i = 0; i < STAT_SKIP; ++i) {
- while (isspace(c)) c = getc(f);
- while (!isspace(c)) c = getc(f);
+ while (isspace(c)) c = stat_buf[buf_offset++];
+ while (!isspace(c)) c = stat_buf[buf_offset++];
}
- while (isspace(c)) c = getc(f);
+ while (isspace(c)) c = stat_buf[buf_offset++];
while (isdigit(c)) {
result *= 10;
result += c - '0';
- c = getc(f);
+ c = stat_buf[buf_offset++];
}
+ close(f);
if (result < 0x10000000) ABORT("Absurd stack bottom value");
return (ptr_t)result;
}
diff --git a/boehm-gc/reclaim.c b/boehm-gc/reclaim.c
index 1847e590aad..57c652ef265 100644
--- a/boehm-gc/reclaim.c
+++ b/boehm-gc/reclaim.c
@@ -29,13 +29,8 @@ word sz;
} else {
GC_err_printf0("Leaked composite object at ");
}
- if (GC_debugging_started && GC_has_debug_info(p)) {
- GC_print_obj(p);
- } else {
- GC_err_printf2("0x%lx (appr. size = %ld)\n",
- (unsigned long)p,
- (unsigned long)WORDS_TO_BYTES(sz));
- }
+ GC_print_heap_obj(p);
+ GC_err_printf0("\n");
}
# define FOUND_FREE(hblk, word_no) \
diff --git a/boehm-gc/version.h b/boehm-gc/version.h
index c7095488bd5..2aedacce531 100644
--- a/boehm-gc/version.h
+++ b/boehm-gc/version.h
@@ -1,6 +1,6 @@
#define GC_VERSION_MAJOR 5
#define GC_VERSION_MINOR 0
-#define GC_ALPHA_VERSION 6
+#define GC_ALPHA_VERSION 7
# define GC_NOT_ALPHA 0xff