summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--darwin_stop_world.c3
-rw-r--r--dyn_load.c8
-rw-r--r--include/gc/gc.h14
-rw-r--r--include/private/gcconfig.h2
-rw-r--r--include/private/pthread_support.h3
-rw-r--r--mark_rts.c8
-rw-r--r--pthread_stop_world.c16
-rw-r--r--pthread_support.c98
8 files changed, 59 insertions, 93 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index c64b4bfb..76b1e98b 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -333,8 +333,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
if (NULL == p) ABORT("Bad GC_stack_range_for call");
# endif
crtn = p -> crtn;
- *phi = EXPECT((p -> flags & MAIN_THREAD) == 0, TRUE) ? crtn -> stack_end
- : GC_stackbottom;
+ *phi = crtn -> stack_end;
if (crtn -> altstack != NULL && (word)(crtn -> altstack) <= (word)lo
&& (word)lo <= (word)(crtn -> altstack) + crtn -> altstack_size) {
*paltstack_lo = lo;
diff --git a/dyn_load.c b/dyn_load.c
index 7c5fc2c8..ed296b30 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -328,11 +328,13 @@ STATIC void GC_register_map_entries(const char *maps)
/* This is a writable mapping. Add it to */
/* the root set unless it is already otherwise */
/* accounted for. */
- if ((word)start <= (word)GC_stackbottom
- && (word)end >= (word)GC_stackbottom) {
+# ifndef THREADS
+ if ((word)start <= (word)GC_stackbottom
+ && (word)end >= (word)GC_stackbottom) {
/* Stack mapping; discard */
continue;
- }
+ }
+# endif
# if defined(E2K) && defined(__ptr64__)
/* TODO: avoid hard-coded addresses */
if ((word)start == 0xc2fffffff000UL
diff --git a/include/gc/gc.h b/include/gc/gc.h
index 811add18..bf64d2d9 100644
--- a/include/gc/gc.h
+++ b/include/gc/gc.h
@@ -382,11 +382,15 @@ GC_API GC_ATTR_DEPRECATED char *GC_stackbottom;
/* potentially some signals that can */
/* confuse debuggers. Otherwise the */
/* collector attempts to set it */
- /* automatically. */
- /* For multi-threaded code, this is the */
- /* cold end of the stack for the */
- /* primordial thread. Portable clients */
- /* should use GC_get_stack_base(), */
+ /* automatically. For multi-threaded */
+ /* code, this is the cold end of the */
+ /* stack for the primordial thread. */
+ /* For multi-threaded code, altering */
+ /* GC_stackbottom value directly after */
+ /* GC initialization has no effect. */
+ /* Portable clients should use */
+ /* GC_set_stackbottom(), */
+ /* GC_get_stack_base(), */
/* GC_call_with_gc_active() and */
/* GC_register_my_thread() instead. */
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 839f0ef1..1f25e5c1 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -1851,7 +1851,6 @@ EXTERN_C_BEGIN
/* address minus one page. */
# define BACKING_STORE_DISPLACEMENT 0x1000000
# define BACKING_STORE_ALIGNMENT 0x1000
-# define BACKING_STORE_BASE GC_register_stackbottom
/* Known to be wrong for recent HP/UX versions!!! */
# endif
# ifdef LINUX
@@ -1861,7 +1860,6 @@ EXTERN_C_BEGIN
/* TODO: LINUX_STACKBOTTOM does not work on NUE. */
/* We also need the base address of the register stack */
/* backing store. */
-# define BACKING_STORE_BASE GC_register_stackbottom
# define SEARCH_FOR_DATA_START
# ifdef __GNUC__
# define DYNAMIC_LOADING
diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h
index dab3738b..091e153e 100644
--- a/include/private/pthread_support.h
+++ b/include/private/pthread_support.h
@@ -184,9 +184,6 @@ typedef struct GC_Thread_Rep {
/* it unregisters itself, since it */
/* may not return a GC pointer. */
# endif
-# ifndef GC_WIN32_THREADS
-# define MAIN_THREAD 0x4 /* True for the original thread only. */
-# endif
# if (defined(GC_HAVE_PTHREAD_EXIT) || !defined(GC_NO_PTHREAD_CANCEL)) \
&& defined(GC_PTHREADS)
# define DISABLED_GC 0x10 /* Collections are disabled while the */
diff --git a/mark_rts.c b/mark_rts.c
index bb39e9da..8e61fd31 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -804,8 +804,8 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void *context)
{
ptr_t bsp = GC_save_regs_ret_val;
ptr_t cold_gc_bs_pointer = bsp - 2048;
- if (GC_all_interior_pointers
- && (word)cold_gc_bs_pointer > (word)BACKING_STORE_BASE) {
+ if (GC_all_interior_pointers && (word)cold_gc_bs_pointer
+ > (word)GC_register_stackbottom) {
/* Adjust cold_gc_bs_pointer if below our innermost */
/* "traced stack section" in backing store. */
if (GC_traced_stack_sect != NULL
@@ -813,11 +813,11 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void *context)
< (word)GC_traced_stack_sect->backing_store_end)
cold_gc_bs_pointer =
GC_traced_stack_sect->backing_store_end;
- GC_push_all_register_sections(BACKING_STORE_BASE,
+ GC_push_all_register_sections(GC_register_stackbottom,
cold_gc_bs_pointer, FALSE, GC_traced_stack_sect);
GC_push_all_eager(cold_gc_bs_pointer, bsp);
} else {
- GC_push_all_register_sections(BACKING_STORE_BASE, bsp,
+ GC_push_all_register_sections(GC_register_stackbottom, bsp,
TRUE /* eager */, GC_traced_stack_sect);
}
/* All values should be sufficiently aligned that we */
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 77d1a194..3db01761 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -839,18 +839,10 @@ GC_INNER void GC_push_all_stacks(void)
traced_stack_sect = traced_stack_sect -> prev;
}
}
- if (EXPECT((p -> flags & MAIN_THREAD) == 0, TRUE)) {
- hi = crtn -> stack_end;
-# ifdef IA64
- bs_lo = crtn -> backing_store_end;
-# endif
- } else {
- /* The original stack. */
- hi = GC_stackbottom;
-# ifdef IA64
- bs_lo = BACKING_STORE_BASE;
-# endif
- }
+ hi = crtn -> stack_end;
+# ifdef IA64
+ bs_lo = crtn -> backing_store_end;
+# endif
# ifdef DEBUG_THREADS
GC_log_printf("Stack for thread %p is [%p,%p)\n",
(void *)p->id, (void *)lo, (void *)hi);
diff --git a/pthread_support.c b/pthread_support.c
index 4d565983..63daff2b 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -1648,7 +1648,7 @@ GC_INNER void GC_thr_init(void)
# endif
GC_ASSERT(NULL == GC_self_thread_inner());
me = GC_register_my_thread_inner(&sb, thread_id_self());
- me -> flags = DETACHED | MAIN_THREAD;
+ me -> flags = DETACHED;
/* Copy the alt-stack information if set. */
crtn = me -> crtn;
crtn -> normstack = (ptr_t)main_normstack;
@@ -1860,67 +1860,50 @@ GC_API void GC_CALL GC_set_stackbottom(void *gc_thread_handle,
const struct GC_stack_base *sb)
{
GC_thread t = (GC_thread)gc_thread_handle;
+ GC_stack_context_t crtn;
GC_ASSERT(sb -> mem_base != NULL);
if (!EXPECT(GC_is_initialized, TRUE)) {
- GC_ASSERT(NULL == t);
- } else {
- GC_stack_context_t crtn;
-
- GC_ASSERT(I_HOLD_LOCK());
- if (NULL == t) /* current thread? */
- t = GC_self_thread_inner();
- GC_ASSERT(!KNOWN_FINISHED(t));
- crtn = t -> crtn;
- GC_ASSERT((t -> flags & DO_BLOCKING) == 0
- && NULL == crtn -> traced_stack_sect); /* for now */
-
-# ifndef GC_WIN32_THREADS
- if (EXPECT((t -> flags & MAIN_THREAD) == 0, TRUE))
-# endif
- {
- crtn -> stack_end = (ptr_t)sb->mem_base;
-# ifdef IA64
- crtn -> backing_store_end = (ptr_t)sb->reg_base;
-# endif
-# ifdef GC_WIN32_THREADS
- /* Reset the known minimum (hottest address in the stack). */
- crtn -> last_stack_min = ADDR_LIMIT;
-# endif
- return;
- }
- /* Otherwise alter the stack bottom of the primordial thread. */
+ GC_ASSERT(NULL == t);
+ /* Alter the stack bottom of the primordial thread. */
+ GC_stackbottom = (char*)(sb -> mem_base);
+# ifdef IA64
+ GC_register_stackbottom = (ptr_t)(sb -> reg_base);
+# endif
+ return;
}
- GC_stackbottom = (char*)sb->mem_base;
+ GC_ASSERT(I_HOLD_LOCK());
+ if (NULL == t) /* current thread? */
+ t = GC_self_thread_inner();
+ GC_ASSERT(!KNOWN_FINISHED(t));
+ crtn = t -> crtn;
+ GC_ASSERT((t -> flags & DO_BLOCKING) == 0
+ && NULL == crtn -> traced_stack_sect); /* for now */
+
+ crtn -> stack_end = (ptr_t)(sb -> mem_base);
# ifdef IA64
- GC_register_stackbottom = (ptr_t)sb->reg_base;
+ crtn -> backing_store_end = (ptr_t)(sb -> reg_base);
+# endif
+# ifdef GC_WIN32_THREADS
+ /* Reset the known minimum (hottest address in the stack). */
+ crtn -> last_stack_min = ADDR_LIMIT;
# endif
}
GC_API void * GC_CALL GC_get_my_stackbottom(struct GC_stack_base *sb)
{
GC_thread me;
+ GC_stack_context_t crtn;
LOCK();
me = GC_self_thread_inner();
/* The thread is assumed to be registered. */
-# ifndef GC_WIN32_THREADS
- if (EXPECT((me -> flags & MAIN_THREAD) != 0, FALSE)) {
- sb -> mem_base = GC_stackbottom;
-# ifdef IA64
- sb -> reg_base = GC_register_stackbottom;
-# endif
- } else
+ crtn = me -> crtn;
+ sb -> mem_base = crtn -> stack_end;
+# ifdef IA64
+ sb -> reg_base = crtn -> backing_store_end;
# endif
- /* else */ {
- GC_stack_context_t crtn = me -> crtn;
-
- sb -> mem_base = crtn -> stack_end;
-# ifdef IA64
- sb -> reg_base = crtn -> backing_store_end;
-# endif
- }
# ifdef E2K
sb -> reg_base = NULL;
# endif
@@ -1938,6 +1921,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
struct GC_traced_stack_sect_s stacksect;
GC_thread me;
GC_stack_context_t crtn;
+ ptr_t stack_end;
# ifdef E2K
size_t stack_size;
# endif
@@ -1948,23 +1932,13 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
/* Adjust our stack bottom value (this could happen unless */
/* GC_get_stack_base() was used which returned GC_SUCCESS). */
-# ifndef GC_WIN32_THREADS
- if (EXPECT((me -> flags & MAIN_THREAD) != 0, FALSE)) {
- /* The original stack. */
- if ((word)GC_stackbottom HOTTER_THAN (word)(&stacksect))
- GC_stackbottom = (ptr_t)COVERT_DATAFLOW(&stacksect);
- } else
-# endif
- /* else */ {
- ptr_t stack_end = crtn -> stack_end; /* read of a volatile field */
-
- GC_ASSERT(stack_end != NULL);
- if ((word)stack_end HOTTER_THAN (word)(&stacksect)) {
- crtn -> stack_end = (ptr_t)(&stacksect);
-# if defined(I386) && defined(GC_WIN32_THREADS)
- crtn -> initial_stack_base = (ptr_t)(&stacksect);
-# endif
- }
+ stack_end = crtn -> stack_end; /* read of a volatile field */
+ GC_ASSERT(stack_end != NULL);
+ if ((word)stack_end HOTTER_THAN (word)(&stacksect)) {
+ crtn -> stack_end = (ptr_t)(&stacksect);
+# if defined(I386) && defined(GC_WIN32_THREADS)
+ crtn -> initial_stack_base = (ptr_t)(&stacksect);
+# endif
}
if ((me -> flags & DO_BLOCKING) == 0) {