Merge pull request #2977 from BrzVlad/fix-major-log2
[mono.git] / mono / metadata / sgen-mono.c
index 63d16f620d468c1655f9ffb6cee487d029382653..c7a467ce832b3696afca54df2258b153424dd50e 100644 (file)
@@ -2183,11 +2183,7 @@ sgen_client_thread_register (SgenThreadInfo* info, void *stack_bottom_fallback)
                info->client_info.stack_end = (char*)stack_bottom;
        }
 
-#ifdef USE_MONO_CTX
        memset (&info->client_info.ctx, 0, sizeof (MonoContext));
-#else
-       memset (&info->client_info.regs, 0, sizeof (info->client_info.regs));
-#endif
 
        if (mono_gc_get_gc_callbacks ()->thread_attach_func)
                info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
@@ -2288,7 +2284,7 @@ void
 sgen_client_thread_register_worker (void)
 {
        mono_thread_info_register_small_id ();
-       mono_thread_info_set_name (mono_native_thread_id_get (), "SGen worker");
+       mono_native_thread_set_name (mono_native_thread_id_get (), "SGen worker");
 }
 
 /* Variables holding start/end nursery so it won't have to be passed at every call */
@@ -2319,7 +2315,7 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
 
        FOREACH_THREAD (info) {
                int skip_reason = 0;
-               void *aligned_stack_start = (void*)(mword) ALIGN_TO ((mword)info->client_info.stack_start, SIZEOF_VOID_P);
+               void *aligned_stack_start;
 
                if (info->client_info.skip) {
                        SGEN_LOG (3, "Skipping dead thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start);
@@ -2330,6 +2326,9 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
                } else if (!mono_thread_info_is_live (info)) {
                        SGEN_LOG (3, "Skipping non-running thread %p, range: %p-%p, size: %zd (state %x)", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start, info->client_info.info.thread_state);
                        skip_reason = 3;
+               } else if (!info->client_info.stack_start) {
+                       SGEN_LOG (3, "Skipping starting or detaching thread %p", info);
+                       skip_reason = 4;
                }
 
                binary_protocol_scan_stack ((gpointer)mono_thread_info_get_tid (info), info->client_info.stack_start, info->client_info.stack_end, skip_reason);
@@ -2337,6 +2336,11 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
                if (skip_reason)
                        continue;
 
+               g_assert (info->client_info.stack_start);
+               g_assert (info->client_info.stack_end);
+
+               aligned_stack_start = (void*)(mword) ALIGN_TO ((mword)info->client_info.stack_start, SIZEOF_VOID_P);
+
                g_assert (info->client_info.suspend_done);
                SGEN_LOG (3, "Scanning thread %p, range: %p-%p, size: %zd, pinned=%zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start, sgen_get_pinned_count ());
                if (mono_gc_get_gc_callbacks ()->thread_mark_func && !conservative_stack_mark) {
@@ -2350,13 +2354,9 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
                }
 
                if (!precise) {
-#ifdef USE_MONO_CTX
                        sgen_conservatively_pin_objects_from ((void**)&info->client_info.ctx, (void**)(&info->client_info.ctx + 1),
                                start_nursery, end_nursery, PIN_TYPE_STACK);
-#else
-                       sgen_conservatively_pin_objects_from ((void**)&info->client_info.regs, (void**)&info->client_info.regs + ARCH_NUM_REGS,
-                                       start_nursery, end_nursery, PIN_TYPE_STACK);
-#endif
+
                        {
                                // This is used on Coop GC for platforms where we cannot get the data for individual registers.
                                // We force a spill of all registers into the stack and pass a chunk of data into sgen.
@@ -2726,7 +2726,7 @@ sgen_client_log_timing (GGTimingInfo *info, mword promoted_size, mword major_use
        full_timing_buff [0] = '\0';
 
        if (!info->is_overflow)
-               sprintf (full_timing_buff, "total %.2fms, bridge %.2fms", info->stw_time / 10000.0f, (int)info->bridge_time / 10000.0f);
+               sprintf (full_timing_buff, "total %.2fms", info->stw_time / 10000.0f);
        if (info->generation == GENERATION_OLD)
                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s los size: %dK in use: %dK",
                        info->is_overflow ? "_OVERFLOW" : "",