X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fsgen-stw.c;h=a8a1b9bf32c9f8437d6772e3031ddf03ea1e3625;hb=a7c9e39f0f58a1dcd41475f5623f301f14e31da7;hp=88f25d67c67c87b8a9d06175f90c606a3057b8a2;hpb=3b2913ca03f284906f55606c9b36540890b7572a;p=mono.git diff --git a/mono/metadata/sgen-stw.c b/mono/metadata/sgen-stw.c index 88f25d67c67..a8a1b9bf32c 100644 --- a/mono/metadata/sgen-stw.c +++ b/mono/metadata/sgen-stw.c @@ -1,5 +1,6 @@ -/* - * sgen-stw.c: Stop the world functionality +/** + * \file + * Stop the world functionality * * Author: * Paolo Molaro (lupus@ximian.com) @@ -19,7 +20,7 @@ #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" @@ -65,10 +66,12 @@ update_current_thread_stack (void *start) 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); +#elif defined (HOST_WASM) + //nothing #else g_error ("Sgen STW requires a working mono-context"); #endif @@ -103,14 +106,11 @@ sgen_client_stop_world (int generation) { 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_RAISE (gc_event, (MONO_GC_EVENT_PRE_STOP_WORLD, generation)); acquire_gc_locks (); - mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED, generation); + MONO_PROFILER_RAISE (gc_event, (MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED, generation)); /* We start to scan after locks are taking, this ensures we won't be interrupted. */ sgen_process_togglerefs (); @@ -125,6 +125,8 @@ sgen_client_stop_world (int generation) SGEN_LOG (3, "world stopped"); + MONO_PROFILER_RAISE (gc_event, (MONO_GC_EVENT_POST_STOP_WORLD, generation)); + TV_GETTIME (end_handshake); time_stop_world += TV_ELAPSED (stop_world_time, end_handshake); @@ -143,9 +145,11 @@ sgen_client_restart_world (int generation, gint64 *stw_time) /* 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)) + if (MONO_PROFILER_ENABLED (gc_moves)) mono_sgen_gc_event_moves (); + MONO_PROFILER_RAISE (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)); @@ -163,6 +167,8 @@ sgen_client_restart_world (int generation, gint64 *stw_time) SGEN_LOG (2, "restarted (pause time: %d usec, max: %d)", (int)usec, (int)max_pause_usec); + MONO_PROFILER_RAISE (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 @@ -175,7 +181,7 @@ sgen_client_restart_world (int generation, gint64 *stw_time) */ release_gc_locks (); - mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD_UNLOCKED, generation); + MONO_PROFILER_RAISE (gc_event, (MONO_GC_EVENT_POST_START_WORLD_UNLOCKED, generation)); *stw_time = usec; } @@ -358,8 +364,8 @@ sgen_unified_suspend_stop_world (void) /* 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); - if (info->client_info.stack_start < info->client_info.stack_start_limit - || info->client_info.stack_start >= 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. @@ -373,7 +379,7 @@ sgen_unified_suspend_stop_world (void) 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 }