#if defined(HAVE_SGEN_GC) && defined(HOST_WIN32)
-#include <windows.h>
+#include "io-layer/io-layer.h"
#include "metadata/sgen-gc.h"
#include "metadata/gc-internal.h"
gboolean
-mono_sgen_resume_thread (SgenThreadInfo *info)
+sgen_resume_thread (SgenThreadInfo *info)
{
DWORD id = mono_thread_info_get_tid (info);
HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
}
gboolean
-mono_sgen_suspend_thread (SgenThreadInfo *info)
+sgen_suspend_thread (SgenThreadInfo *info)
{
DWORD id = mono_thread_info_get_tid (info);
HANDLE handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id);
CONTEXT context;
DWORD result;
+ g_assert (id != GetCurrentThreadId ());
+
g_assert (handle);
result = SuspendThread (handle);
- g_assert (result != (DWORD)-1);
if (result == (DWORD)-1) {
+ fprintf (stderr, "could not suspend thread %x (handle %p): %d\n", id, handle, GetLastError ()); fflush (stderr);
CloseHandle (handle);
return FALSE;
}
CloseHandle (handle);
- info->stopped_domain = NULL; /* FIXME: implement! */
+#ifdef USE_MONO_CTX
+ memset (&info->ctx, 0, sizeof (MonoContext));
+#ifdef TARGET_AMD64
+ info->ctx.rip = context.Rip;
+ info->ctx.rax = context.Rax;
+ info->ctx.rcx = context.Rcx;
+ info->ctx.rdx = context.Rdx;
+ info->ctx.rbx = context.Rbx;
+ info->ctx.rsp = context.Rsp;
+ info->ctx.rbp = context.Rbp;
+ info->ctx.rsi = context.Rsi;
+ info->ctx.rdi = context.Rdi;
+ info->ctx.r8 = context.R8;
+ info->ctx.r9 = context.R9;
+ info->ctx.r10 = context.R10;
+ info->ctx.r11 = context.R11;
+ info->ctx.r12 = context.R12;
+ info->ctx.r13 = context.R13;
+ info->ctx.r14 = context.R14;
+ info->ctx.r15 = context.R15;
+ info->stopped_ip = info->ctx.rip;
+ info->stack_start = (char*)info->ctx.rsp - REDZONE_SIZE;
+#else
+ info->ctx.edi = context.Edi;
+ info->ctx.esi = context.Esi;
+ info->ctx.ebx = context.Ebx;
+ info->ctx.edx = context.Edx;
+ info->ctx.ecx = context.Ecx;
+ info->ctx.eax = context.Eax;
+ info->ctx.ebp = context.Ebp;
+ info->ctx.esp = context.Esp;
info->stopped_ip = (gpointer)context.Eip;
info->stack_start = (char*)context.Esp - REDZONE_SIZE;
+#endif
+#else
info->regs [0] = context.Edi;
info->regs [1] = context.Esi;
info->regs [2] = context.Ebx;
info->regs [5] = context.Eax;
info->regs [6] = context.Ebp;
info->regs [7] = context.Esp;
- info->stopped_regs = &info->regs;
+ info->stopped_ip = (gpointer)context.Eip;
+ info->stack_start = (char*)context.Esp - REDZONE_SIZE;
+#endif
/* Notify the JIT */
if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
- mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, NULL);
+ mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, NULL, NULL);
return TRUE;
}
void
-mono_sgen_wait_for_suspend_ack (int count)
+sgen_wait_for_suspend_ack (int count)
{
/* Win32 suspend/resume is synchronous, so we don't need to wait for anything */
}
int
-mono_sgen_thread_handshake (BOOL suspend)
+sgen_thread_handshake (BOOL suspend)
{
SgenThreadInfo *info;
SgenThreadInfo *current = mono_thread_info_current ();
FOREACH_THREAD_SAFE (info) {
if (info == current)
continue;
+ if (info->gc_disabled)
+ continue;
if (suspend) {
- g_assert (!info->doing_handshake);
- info->doing_handshake = TRUE;
-
- if (!mono_sgen_suspend_thread (info))
+ if (!sgen_suspend_thread (info))
continue;
} else {
- g_assert (info->doing_handshake);
- info->doing_handshake = FALSE;
-
- if (!mono_sgen_resume_thread (info))
+ if (!sgen_resume_thread (info))
continue;
}
-
++count;
} END_FOREACH_THREAD_SAFE
return count;
}
void
-mono_sgen_os_init (void)
+sgen_os_init (void)
{
}