-/*
- * sgen-stw.c: Stop the world functionality
+/**
+ * \file
+ * Stop the world functionality
*
* Author:
* Paolo Molaro (lupus@ximian.com)
#include "sgen/sgen-gc.h"
#include "sgen/sgen-protocol.h"
#include "sgen/sgen-memory-governor.h"
-#include "sgen/sgen-thread-pool.h"
+#include "sgen/sgen-workers.h"
#include "metadata/profiler-private.h"
#include "sgen/sgen-client.h"
#include "metadata/sgen-bridge-internals.h"
info->client_info.stack_start = align_pointer (&stack_guard);
g_assert (info->client_info.stack_start);
- g_assert (info->client_info.stack_start >= info->client_info.stack_start_limit && info->client_info.stack_start < info->client_info.stack_end);
+ g_assert (info->client_info.stack_start >= info->client_info.info.stack_start_limit && info->client_info.stack_start < info->client_info.info.stack_end);
#if !defined(MONO_CROSS_COMPILE) && MONO_ARCH_HAS_MONO_CONTEXT
MONO_CONTEXT_GET_CURRENT (info->client_info.ctx);
{
TV_DECLARE (end_handshake);
- /* notify the profiler of the leftovers */
- /* FIXME this is the wrong spot at we can STW for non collection reasons. */
- if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES))
- mono_sgen_gc_event_moves ();
+ mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD, generation);
acquire_gc_locks ();
SGEN_LOG (3, "world stopped");
+ mono_profiler_gc_event (MONO_GC_EVENT_POST_STOP_WORLD, generation);
+
TV_GETTIME (end_handshake);
time_stop_world += TV_ELAPSED (stop_world_time, end_handshake);
if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES))
mono_sgen_gc_event_moves ();
+ mono_profiler_gc_event (MONO_GC_EVENT_PRE_START_WORLD, generation);
+
FOREACH_THREAD (info) {
info->client_info.stack_start = NULL;
memset (&info->client_info.ctx, 0, sizeof (MonoContext));
SGEN_LOG (2, "restarted (pause time: %d usec, max: %d)", (int)usec, (int)max_pause_usec);
+ mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD, generation);
+
/*
* We must release the thread info suspend lock after doing
* the thread handshake. Otherwise, if the GC stops the world
We can't suspend the workers that will do all the heavy lifting.
FIXME Use some state bit in SgenThreadInfo for this.
*/
- if (sgen_thread_pool_is_thread_pool_thread (mono_thread_info_get_tid (info))) {
+ if (sgen_thread_pool_is_thread_pool_thread (major_collector.get_sweep_pool (), mono_thread_info_get_tid (info)) ||
+ sgen_workers_is_worker_thread (mono_thread_info_get_tid (info))) {
if (reason)
*reason = 4;
return FALSE;
/* Once we remove the old suspend code, we should move sgen to directly access the state in MonoThread */
info->client_info.stack_start = (gpointer) ((char*)MONO_CONTEXT_GET_SP (&info->client_info.ctx) - REDZONE_SIZE);
- /* altstack signal handler, sgen can't handle them, mono-threads should have handled this. */
- if (!info->client_info.stack_start
- || info->client_info.stack_start < info->client_info.stack_start_limit
- || info->client_info.stack_start >= info->client_info.stack_end) {
- g_error ("BAD STACK: stack_start = %p, stack_start_limit = %p, stack_end = %p",
- info->client_info.stack_start, info->client_info.stack_start_limit, info->client_info.stack_end);
+ if (info->client_info.stack_start < info->client_info.info.stack_start_limit
+ || info->client_info.stack_start >= info->client_info.info.stack_end) {
+ /*
+ * Thread context is in unhandled state, most likely because it is
+ * dying. We don't scan it.
+ * FIXME We should probably rework and check the valid flag instead.
+ */
+ info->client_info.stack_start = NULL;
}
stopped_ip = (gpointer) (MONO_CONTEXT_GET_IP (&info->client_info.ctx));
binary_protocol_thread_suspend ((gpointer) mono_thread_info_get_tid (info), stopped_ip);
THREADS_STW_DEBUG ("[GC-STW-SUSPEND-END] thread %p is suspended, stopped_ip = %p, stack = %p -> %p\n",
- mono_thread_info_get_tid (info), stopped_ip, info->client_info.stack_start, info->client_info.stack_start ? info->client_info.stack_end : NULL);
+ mono_thread_info_get_tid (info), stopped_ip, info->client_info.stack_start, info->client_info.stack_start ? info->client_info.info.stack_end : NULL);
} FOREACH_THREAD_END
}