Permalink
Browse files

Store the thread context in SgenThreadInfo in all cases to reduce the…

… amount of #ifdefs.
  • Loading branch information...
1 parent d773d57 commit 42cda67dc28ed355dd85a5cf62aa1bfec7aa1e2c @vargaz vargaz committed Oct 22, 2012
@@ -420,9 +420,9 @@ find_pinning_ref_from_thread (char *obj, size_t size)
for (j = 0; j < ARCH_NUM_REGS; ++j) {
#ifdef USE_MONO_CTX
- mword w = ((mword*)info->monoctx) [j];
+ mword w = ((mword*)&info->ctx) [j];
#else
- mword w = (mword)info->stopped_regs [j];
+ mword w = (mword)&info->regs [j];
#endif
if (w >= (mword)obj && w < (mword)obj + size)
View
@@ -3399,12 +3399,12 @@ update_current_thread_stack (void *start)
g_assert (info->stack_start >= info->stack_start_limit && info->stack_start < info->stack_end);
#ifdef USE_MONO_CTX
MONO_CONTEXT_GET_CURRENT (cur_thread_ctx);
- info->monoctx = &cur_thread_ctx;
+ memcpy (&info->ctx, &cur_thread_ctx, sizeof (MonoContext));
if (gc_callbacks.thread_suspend_func)
- gc_callbacks.thread_suspend_func (info->runtime_data, NULL, info->monoctx);
+ gc_callbacks.thread_suspend_func (info->runtime_data, NULL, &info->ctx);
#else
ARCH_STORE_REGS (reg_ptr);
- info->stopped_regs = reg_ptr;
+ memcpy (&info->regs, reg_ptr, sizeof (info->regs));
if (gc_callbacks.thread_suspend_func)
gc_callbacks.thread_suspend_func (info->runtime_data, NULL, NULL);
#endif
@@ -3566,9 +3566,9 @@ restart_world (int generation, GGTimingInfo *timing)
FOREACH_THREAD (info) {
info->stack_start = NULL;
#ifdef USE_MONO_CTX
- info->monoctx = NULL;
+ memset (&info->ctx, 0, sizeof (MonoContext));
#else
- info->stopped_regs = NULL;
+ memset (&info->regs, 0, sizeof (info->regs));
#endif
} END_FOREACH_THREAD
@@ -3670,15 +3670,15 @@ scan_thread_data (void *start_nursery, void *end_nursery, gboolean precise, Gray
}
}
+ if (!info->thread_is_dying && !precise) {
#ifdef USE_MONO_CTX
- if (!info->thread_is_dying && !precise)
- conservatively_pin_objects_from ((void**)info->monoctx, (void**)info->monoctx + ARCH_NUM_REGS,
+ conservatively_pin_objects_from ((void**)&info->ctx, (void**)&info->ctx + ARCH_NUM_REGS,
start_nursery, end_nursery, PIN_TYPE_STACK);
#else
- if (!info->thread_is_dying && !precise)
- conservatively_pin_objects_from (info->stopped_regs, info->stopped_regs + ARCH_NUM_REGS,
+ conservatively_pin_objects_from (&info->regs, &info->regs + ARCH_NUM_REGS,
start_nursery, end_nursery, PIN_TYPE_STACK);
#endif
+ }
} END_FOREACH_THREAD
}
@@ -3724,9 +3724,9 @@ sgen_thread_register (SgenThreadInfo* info, void *addr)
info->stopped_ip = NULL;
info->stopped_domain = NULL;
#ifdef USE_MONO_CTX
- info->monoctx = NULL;
+ memset (&info->ctx, 0, sizeof (MonoContext));
#else
- info->stopped_regs = NULL;
+ memset (&info->regs, 0, sizeof (info->regs));
#endif
sgen_init_tlab_info (info);
View
@@ -130,22 +130,15 @@ struct _SgenThreadInfo {
long *store_remset_buffer_index_addr;
RememberedSet *remset;
gpointer runtime_data;
+
gpointer stopped_ip; /* only valid if the thread is stopped */
MonoDomain *stopped_domain; /* ditto */
#ifdef USE_MONO_CTX
-#ifdef __MACH__
MonoContext ctx; /* ditto */
-#endif
- MonoContext *monoctx; /* ditto */
-
#else
-
-#if defined(__MACH__) || defined(HOST_WIN32)
gpointer regs[ARCH_NUM_REGS]; /* ditto */
#endif
- gpointer *stopped_regs; /* ditto */
-#endif
#ifndef HAVE_KW_THREAD
char *tlab_start;
@@ -86,10 +86,8 @@ sgen_suspend_thread (SgenThreadInfo *info)
#ifdef USE_MONO_CTX
mono_sigctx_to_monoctx (&ctx, &info->ctx);
- info->monoctx = &info->ctx;
#else
ARCH_COPY_SIGCTX_REGS (&info->regs, &ctx);
- info->stopped_regs = &info->regs;
#endif
} else {
g_assert (!info->stack_start);
@@ -57,9 +57,7 @@ static void
suspend_thread (SgenThreadInfo *info, void *context)
{
int stop_count;
-#ifdef USE_MONO_CTX
- MonoContext monoctx;
-#else
+#ifndef USE_MONO_CTX
gpointer regs [ARCH_NUM_REGS];
#endif
gpointer stack_start;
@@ -83,17 +81,16 @@ suspend_thread (SgenThreadInfo *info, void *context)
#ifdef USE_MONO_CTX
if (context) {
- mono_sigctx_to_monoctx (context, &monoctx);
- info->monoctx = &monoctx;
+ mono_sigctx_to_monoctx (context, &info->ctx);
} else {
- info->monoctx = NULL;
+ memset (&info->ctx, 0, sizeof (MonoContext));
}
#else
if (context) {
ARCH_COPY_SIGCTX_REGS (regs, context);
- info->stopped_regs = regs;
+ memcpy (&info->regs, regs, sizeof (info->regs));
} else {
- info->stopped_regs = NULL;
+ memset (&info->regs, 0, sizeof (info->regs));
}
#endif
} else {
@@ -68,7 +68,6 @@ sgen_suspend_thread (SgenThreadInfo *info)
info->regs [5] = context.Eax;
info->regs [6] = context.Ebp;
info->regs [7] = context.Esp;
- info->stopped_regs = &info->regs;
/* Notify the JIT */
if (mono_gc_get_gc_callbacks ()->thread_suspend_func)

0 comments on commit 42cda67

Please sign in to comment.