+2009-12-08 Ivan Maidanski <ivmai@mail.ru>
+
+ * darwin_stop_world.c (GC_push_all_stacks): Fix a bug (call
+ GC_push_all_stack() instead of GC_push_all_stack_frames()).
+ * include/private/gc_priv.h (GC_push_all_stack_frames,
+ GC_push_all_register_frames): Rename to
+ GC_push_all_stack_sections and GC_push_all_register_sections,
+ respectively.
+ * mark_rts.c (GC_push_all_stack_frames,
+ GC_push_all_register_frames, GC_push_all_stack_part_eager_frames,
+ GC_push_current_stack): Ditto.
+ * pthread_stop_world.c (GC_push_all_stacks): Ditto.
+ * win32_threads.c (GC_push_stack_for): Ditto.
+ * misc.c (GC_call_with_gc_active): Rename "frame" local variable
+ to "stacksect".
+ * pthread_support.c (GC_call_with_gc_active): Ditto.
+ * win32_threads.c (GC_call_with_gc_active): Ditto.
+ * pthread_support.c (GC_call_with_gc_active): Update FIXME for
+ Darwin.
+ * win32_threads.c (GC_Thread_Rep): Update the comment for
+ traced_stack_sect.
+
2009-12-08 Ivan Maidanski <ivmai@mail.ru> (really mostly Hans Boehm)
* darwin_stop_world.c (GC_push_all_stacks): Rename
GC_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
(unsigned long) p -> id, lo, hi);
# endif
- GC_push_all_stack_frames(lo, hi, p -> traced_stack_sect);
+ /* FIXME: It is impossible to use GC_push_all_stack_sections() */
+ /* here while GC_do_blocking_inner() and GC_call_with_gc_active() */
+ /* contain unimplemented code for Darwin. */
+ GC_push_all_stack(lo, hi);
total_size += hi - lo; /* lo <= hi */
} /* for(p=GC_threads[i]...) */
} /* for(i=0;i<THREAD_TABLE_SZ...) */
GC_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
(unsigned long) thread, lo, hi);
# endif
- /* FIXME: use GC_push_all_stack_frames. */
+ /* FIXME: use GC_push_all_stack_sections. */
GC_push_all_stack(lo, hi);
mach_port_deallocate(my_task, thread);
total_size += hi - lo; /* lo <= hi */
void * client_data; /* and result */
};
-/* This is used by GC_call_with_gc_active(), GC_push_all_stack_frames(). */
+/* This is used by GC_call_with_gc_active(), GC_push_all_stack_sections(). */
struct GC_traced_stack_sect_s {
ptr_t saved_stack_ptr;
#ifdef IA64
#ifdef THREADS
/* Process all "traced stack sections" - scan entire stack except for */
/* frames belonging to the user functions invoked by GC_do_blocking(). */
- GC_INNER void GC_push_all_stack_frames(ptr_t lo, ptr_t hi,
+ GC_INNER void GC_push_all_stack_sections(ptr_t lo, ptr_t hi,
struct GC_traced_stack_sect_s *traced_stack_sect);
GC_EXTERN word GC_total_stacksize; /* updated on every push_all_stacks */
#else
#endif /* !THREADS */
#ifdef IA64
- /* Similar to GC_push_all_stack_frames() but for IA-64 registers store. */
- GC_INNER void GC_push_all_register_frames(ptr_t bs_lo, ptr_t bs_hi,
+ /* Similar to GC_push_all_stack_sections() but for IA-64 registers store. */
+ GC_INNER void GC_push_all_register_sections(ptr_t bs_lo, ptr_t bs_hi,
int eager, struct GC_traced_stack_sect_s *traced_stack_sect);
#endif
}
#ifdef IA64
- /* Similar to GC_push_all_stack_frames() but for IA-64 registers store. */
- GC_INNER void GC_push_all_register_frames(ptr_t bs_lo, ptr_t bs_hi,
+ /* Similar to GC_push_all_stack_sections() but for IA-64 registers store. */
+ GC_INNER void GC_push_all_register_sections(ptr_t bs_lo, ptr_t bs_hi,
int eager, struct GC_traced_stack_sect_s *traced_stack_sect)
{
while (traced_stack_sect != NULL) {
#ifdef THREADS
-GC_INNER void GC_push_all_stack_frames(ptr_t lo, ptr_t hi,
+GC_INNER void GC_push_all_stack_sections(ptr_t lo, ptr_t hi,
struct GC_traced_stack_sect_s *traced_stack_sect)
{
while (traced_stack_sect != NULL) {
# endif
}
-/* Similar to GC_push_all_stack_frames() but also uses cold_gc_frame. */
-STATIC void GC_push_all_stack_part_eager_frames(ptr_t lo, ptr_t hi,
+/* Similar to GC_push_all_stack_sections() but also uses cold_gc_frame. */
+STATIC void GC_push_all_stack_part_eager_sections(ptr_t lo, ptr_t hi,
ptr_t cold_gc_frame, struct GC_traced_stack_sect_s *traced_stack_sect)
{
GC_ASSERT(traced_stack_sect == NULL || cold_gc_frame == NULL ||
GC_push_all_eager(cold_gc_frame, GC_approx_sp());
# endif
# else
- GC_push_all_stack_part_eager_frames(GC_approx_sp(), GC_stackbottom,
+ GC_push_all_stack_part_eager_sections(GC_approx_sp(), GC_stackbottom,
cold_gc_frame, GC_traced_stack_sect);
# ifdef IA64
/* We also need to push the register stack backing store. */
GC_traced_stack_sect->backing_store_end)
cold_gc_bs_pointer =
GC_traced_stack_sect->backing_store_end;
- GC_push_all_register_frames(BACKING_STORE_BASE,
+ GC_push_all_register_sections(BACKING_STORE_BASE,
cold_gc_bs_pointer, FALSE, GC_traced_stack_sect);
GC_push_all_eager(cold_gc_bs_pointer, bsp);
} else {
- GC_push_all_register_frames(BACKING_STORE_BASE, bsp,
+ GC_push_all_register_sections(BACKING_STORE_BASE, bsp,
TRUE /* eager */, GC_traced_stack_sect);
}
/* All values should be sufficiently aligned that we */
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
void * client_data)
{
- struct GC_traced_stack_sect_s frame;
+ struct GC_traced_stack_sect_s stacksect;
GC_ASSERT(GC_is_initialized);
/* Adjust our stack base value (this could happen if */
/* GC_get_main_stack_base() is unimplemented or broken for */
/* the platform). */
- if (GC_stackbottom HOTTER_THAN (ptr_t)(&frame))
- GC_stackbottom = (ptr_t)(&frame);
+ if (GC_stackbottom HOTTER_THAN (ptr_t)(&stacksect))
+ GC_stackbottom = (ptr_t)(&stacksect);
if (GC_blocked_sp == NULL) {
/* We are not inside GC_do_blocking() - do nothing more. */
return fn(client_data);
}
- /* Setup new "frame". */
- frame.saved_stack_ptr = GC_blocked_sp;
+ /* Setup new "stack section". */
+ stacksect.saved_stack_ptr = GC_blocked_sp;
# ifdef IA64
/* This is the same as in GC_call_with_stack_base(). */
- frame.backing_store_end = GC_save_regs_in_stack();
+ stacksect.backing_store_end = GC_save_regs_in_stack();
/* Unnecessarily flushes register stack, */
/* but that probably doesn't hurt. */
- frame.saved_backing_store_ptr = GC_blocked_register_sp;
+ stacksect.saved_backing_store_ptr = GC_blocked_register_sp;
# endif
- frame.prev = GC_traced_stack_sect;
+ stacksect.prev = GC_traced_stack_sect;
GC_blocked_sp = NULL;
- GC_traced_stack_sect = &frame;
+ GC_traced_stack_sect = &stacksect;
client_data = fn(client_data);
GC_ASSERT(GC_blocked_sp == NULL);
- GC_ASSERT(GC_traced_stack_sect == &frame);
+ GC_ASSERT(GC_traced_stack_sect == &stacksect);
- /* Restore original "frame". */
- GC_traced_stack_sect = frame.prev;
+ /* Restore original "stack section". */
+ GC_traced_stack_sect = stacksect.prev;
# ifdef IA64
- GC_blocked_register_sp = frame.saved_backing_store_ptr;
+ GC_blocked_register_sp = stacksect.saved_backing_store_ptr;
# endif
- GC_blocked_sp = frame.saved_stack_ptr;
+ GC_blocked_sp = stacksect.saved_stack_ptr;
return client_data; /* result */
}
(unsigned)(p -> id), lo, hi);
# endif
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!");
- GC_push_all_stack_frames(lo, hi, p -> traced_stack_sect);
+ GC_push_all_stack_sections(lo, hi, p -> traced_stack_sect);
# ifdef STACK_GROWS_UP
total_size += lo - hi;
# else
# endif
/* FIXME: This (if p->id==me) may add an unbounded number of */
/* entries, and hence overflow the mark stack, which is bad. */
- GC_push_all_register_frames(bs_lo, bs_hi, THREAD_EQUAL(p -> id, me),
- p -> traced_stack_sect);
+ GC_push_all_register_sections(bs_lo, bs_hi,
+ THREAD_EQUAL(p -> id, me),
+ p -> traced_stack_sect);
total_size += bs_hi - bs_lo; /* bs_lo <= bs_hi */
# endif
}
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
void * client_data)
{
- struct GC_traced_stack_sect_s frame;
+ struct GC_traced_stack_sect_s stacksect;
GC_thread me;
LOCK(); /* This will block if the world is stopped. */
me = GC_lookup_thread(pthread_self());
/* GC_get_stack_base() was used which returned GC_SUCCESS). */
if ((me -> flags & MAIN_THREAD) == 0) {
GC_ASSERT(me -> stack_end != NULL);
- if (me -> stack_end HOTTER_THAN (ptr_t)(&frame))
- me -> stack_end = (ptr_t)(&frame);
+ if (me -> stack_end HOTTER_THAN (ptr_t)(&stacksect))
+ me -> stack_end = (ptr_t)(&stacksect);
} else {
/* The original stack. */
- if (GC_stackbottom HOTTER_THAN (ptr_t)(&frame))
- GC_stackbottom = (ptr_t)(&frame);
+ if (GC_stackbottom HOTTER_THAN (ptr_t)(&stacksect))
+ GC_stackbottom = (ptr_t)(&stacksect);
}
if (me -> thread_blocked == FALSE) {
return fn(client_data);
}
- /* Setup new "frame". */
+ /* Setup new "stack section". */
# ifdef GC_DARWIN_THREADS
- /* FIXME: Implement it for Darwin ("frames" are ignored at present). */
+ /* FIXME: Implement it (and GC_do_blocking_inner) for Darwin. */
# else
- frame.saved_stack_ptr = me -> stop_info.stack_ptr;
+ stacksect.saved_stack_ptr = me -> stop_info.stack_ptr;
# endif
# ifdef IA64
/* This is the same as in GC_call_with_stack_base(). */
- frame.backing_store_end = GC_save_regs_in_stack();
+ stacksect.backing_store_end = GC_save_regs_in_stack();
/* Unnecessarily flushes register stack, */
/* but that probably doesn't hurt. */
- frame.saved_backing_store_ptr = me -> backing_store_ptr;
+ stacksect.saved_backing_store_ptr = me -> backing_store_ptr;
# endif
- frame.prev = me -> traced_stack_sect;
+ stacksect.prev = me -> traced_stack_sect;
me -> thread_blocked = FALSE;
- me -> traced_stack_sect = &frame;
+ me -> traced_stack_sect = &stacksect;
UNLOCK();
client_data = fn(client_data);
GC_ASSERT(me -> thread_blocked == FALSE);
- GC_ASSERT(me -> traced_stack_sect == &frame);
+ GC_ASSERT(me -> traced_stack_sect == &stacksect);
- /* Restore original "frame". */
+ /* Restore original "stack section". */
LOCK();
- me -> traced_stack_sect = frame.prev;
+ me -> traced_stack_sect = stacksect.prev;
# ifdef IA64
- me -> backing_store_ptr = frame.saved_backing_store_ptr;
+ me -> backing_store_ptr = stacksect.saved_backing_store_ptr;
# endif
me -> thread_blocked = TRUE;
# ifndef GC_DARWIN_THREADS
- me -> stop_info.stack_ptr = frame.saved_stack_ptr;
+ me -> stop_info.stack_ptr = stacksect.saved_stack_ptr;
# endif
UNLOCK();
/* not need to stop this thread. */
struct GC_traced_stack_sect_s *traced_stack_sect;
- /* Points to the "frame" data held in stack by */
- /* the innermost GC_call_with_gc_active() of */
- /* this thread. May be NULL. */
+ /* Points to the "stack section" data */
+ /* held in stack by the innermost */
+ /* GC_call_with_gc_active() of this */
+ /* thread. May be NULL. */
unsigned finalizer_nested;
unsigned finalizer_skipped; /* Used by GC_check_finalizer_nested() */
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
void * client_data)
{
- struct GC_traced_stack_sect_s frame;
+ struct GC_traced_stack_sect_s stacksect;
GC_thread me;
LOCK(); /* This will block if the world is stopped. */
me = GC_lookup_thread_inner(GetCurrentThreadId());
/* Adjust our stack base value (this could happen unless */
/* GC_get_stack_base() was used which returned GC_SUCCESS). */
GC_ASSERT(me -> stack_base != NULL);
- if (me -> stack_base < (ptr_t)(&frame))
- me -> stack_base = (ptr_t)(&frame);
+ if (me -> stack_base < (ptr_t)(&stacksect))
+ me -> stack_base = (ptr_t)(&stacksect);
if (me -> thread_blocked_sp == NULL) {
/* We are not inside GC_do_blocking() - do nothing more. */
return fn(client_data);
}
- /* Setup new "frame". */
- frame.saved_stack_ptr = me -> thread_blocked_sp;
+ /* Setup new "stack section". */
+ stacksect.saved_stack_ptr = me -> thread_blocked_sp;
# ifdef IA64
/* This is the same as in GC_call_with_stack_base(). */
- frame.backing_store_end = GC_save_regs_in_stack();
+ stacksect.backing_store_end = GC_save_regs_in_stack();
/* Unnecessarily flushes register stack, */
/* but that probably doesn't hurt. */
- frame.saved_backing_store_ptr = me -> backing_store_ptr;
+ stacksect.saved_backing_store_ptr = me -> backing_store_ptr;
# endif
- frame.prev = me -> traced_stack_sect;
+ stacksect.prev = me -> traced_stack_sect;
me -> thread_blocked_sp = NULL;
- me -> traced_stack_sect = &frame;
+ me -> traced_stack_sect = &stacksect;
UNLOCK();
client_data = fn(client_data);
GC_ASSERT(me -> thread_blocked_sp == NULL);
- GC_ASSERT(me -> traced_stack_sect == &frame);
+ GC_ASSERT(me -> traced_stack_sect == &stacksect);
- /* Restore original "frame". */
+ /* Restore original "stack section". */
LOCK();
- me -> traced_stack_sect = frame.prev;
+ me -> traced_stack_sect = stacksect.prev;
# ifdef IA64
- me -> backing_store_ptr = frame.saved_backing_store_ptr;
+ me -> backing_store_ptr = stacksect.saved_backing_store_ptr;
# endif
- me -> thread_blocked_sp = frame.saved_stack_ptr;
+ me -> thread_blocked_sp = stacksect.saved_stack_ptr;
UNLOCK();
return client_data; /* result */
GC_printf("Pushing stack for 0x%x from sp %p to %p from 0x%x\n",
(int)thread -> id, sp, thread -> stack_base, (int)me);
# endif
- GC_push_all_stack_frames(sp, thread->stack_base, traced_stack_sect);
+ GC_push_all_stack_sections(sp, thread->stack_base, traced_stack_sect);
} else {
/* If not current thread then it is possible for sp to point to */
/* the guarded (untouched yet) page just below the current */