*
* Copyright (C) 2014 Xamarin Inc
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License 2.0 as published by the Free Software Foundation;
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License 2.0 along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
#include "metadata/handle.h"
#include "utils/mono-memory-model.h"
#include "utils/mono-logger-internals.h"
+#include "sgen/sgen-thread-pool.h"
#ifdef HEAVY_STATISTICS
static guint64 stat_wbarrier_set_arrayref = 0;
g_assert_not_reached ();
}
- if (atype != ATYPE_SMALL) {
- /* size += ALLOC_ALIGN - 1; */
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
- mono_mb_emit_byte (mb, CEE_ADD);
- /* size &= ~(ALLOC_ALIGN - 1); */
- mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
- mono_mb_emit_byte (mb, CEE_AND);
- mono_mb_emit_stloc (mb, size_var);
- }
+ /* size += ALLOC_ALIGN - 1; */
+ mono_mb_emit_ldloc (mb, size_var);
+ mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
+ mono_mb_emit_byte (mb, CEE_ADD);
+ /* size &= ~(ALLOC_ALIGN - 1); */
+ mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
+ mono_mb_emit_byte (mb, CEE_AND);
+ mono_mb_emit_stloc (mb, size_var);
/* if (size > MAX_SMALL_OBJ_SIZE) goto slowpath */
if (atype != ATYPE_SMALL) {
mono_mb_emit_byte (mb, MONO_CEE_ADD);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_STIND_I4);
- /* s->chars [len] = 0; */
- mono_mb_emit_ldloc (mb, p_var);
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, 2);
- mono_mb_emit_byte (mb, MONO_CEE_SUB);
- mono_mb_emit_byte (mb, MONO_CEE_ADD);
- mono_mb_emit_icon (mb, 0);
- mono_mb_emit_byte (mb, MONO_CEE_STIND_I2);
}
/*
sgen_client_thread_register_worker (void)
{
mono_thread_info_register_small_id ();
+ mono_thread_info_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 */
if (!info->is_overflow)
sprintf (full_timing_buff, "total %.2fms, bridge %.2fms", info->stw_time / 10000.0f, (int)info->bridge_time / 10000.0f);
if (info->generation == GENERATION_OLD)
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s major %dK/%dK los %dK/%dK",
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s los %dK/%dK",
info->is_overflow ? "_OVERFLOW" : "",
info->reason ? info->reason : "",
(int)info->total_time / 10000.0f,
full_timing_buff,
- major_collector->section_size * num_major_sections / 1024,
- major_collector->section_size * last_major_num_sections / 1024,
los_memory_usage / 1024,
last_los_memory_usage / 1024);
else
sgen_bridge_describe_pointer (ptr);
}
+static gboolean gc_inited;
+
void
mono_gc_base_init (void)
{
+ if (gc_inited)
+ return;
+
mono_counters_init ();
#ifdef HEAVY_STATISTICS
if (mono_tls_key_get_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR) == -1)
sgen_set_use_managed_allocator (FALSE);
#endif
+
+ gc_inited = TRUE;
}
void
mono_gc_base_cleanup (void)
{
+ sgen_thread_pool_shutdown ();
}
gboolean