#include <glib.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/threads-types.h>
-#include <mono/metadata/sgen-conf.h>
#include <mono/utils/gc_wrapper.h>
typedef struct {
long long minor_gc_time;
long long major_gc_time;
long long major_gc_time_concurrent;
-#ifdef HEAVY_STATISTICS
- unsigned long long gray_queue_section_alloc;
- unsigned long long gray_queue_section_free;
- unsigned long long gray_queue_enqueue_fast_path;
- unsigned long long gray_queue_dequeue_fast_path;
- unsigned long long gray_queue_enqueue_slow_path;
- unsigned long long gray_queue_dequeue_slow_path;
-#endif
} GCStats;
#define mono_domain_finalizers_lock(domain) mono_mutex_lock (&(domain)->finalizable_objects_hash_lock);
mono_counters_register ("Minor GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.minor_gc_time);
mono_counters_register ("Major GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.major_gc_time);
mono_counters_register ("Major GC time concurrent", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.major_gc_time_concurrent);
-#ifdef HEAVY_STATISTICS
- mono_counters_register ("Gray Queue alloc section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_section_alloc);
- mono_counters_register ("Gray Queue free section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_section_free);
- mono_counters_register ("Gray Queue enqueue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_enqueue_fast_path);
- mono_counters_register ("Gray Queue dequeue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_dequeue_fast_path);
- mono_counters_register ("Gray Queue enqueue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_enqueue_slow_path);
- mono_counters_register ("Gray Queue dequeue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_dequeue_slow_path);
-#endif
mono_gc_base_init ();
sgen_init_stw ();
sgen_init_hash_table ();
sgen_init_descriptors ();
+ sgen_init_gray_queues ();
sgen_register_fixed_internal_mem_type (INTERNAL_MEM_SECTION, SGEN_SIZEOF_GC_MEM_SECTION);
sgen_register_fixed_internal_mem_type (INTERNAL_MEM_FINALIZE_READY_ENTRY, sizeof (FinalizeReadyEntry));
#include "utils/mono-counters.h"
#include "sgen-protocol.h"
+#ifdef HEAVY_STATISTICS
+unsigned long long stat_gray_queue_section_alloc;
+unsigned long long stat_gray_queue_section_free;
+unsigned long long stat_gray_queue_enqueue_fast_path;
+unsigned long long stat_gray_queue_dequeue_fast_path;
+unsigned long long stat_gray_queue_enqueue_slow_path;
+unsigned long long stat_gray_queue_dequeue_slow_path;
+#endif
+
#define GRAY_QUEUE_LENGTH_LIMIT 64
#ifdef SGEN_CHECK_GRAY_OBJECT_SECTIONS
{
GrayQueueSection *section;
- HEAVY_STAT (gc_stats.gray_queue_section_alloc ++);
+ HEAVY_STAT (stat_gray_queue_section_alloc ++);
if (queue->alloc_prepare_func)
queue->alloc_prepare_func (queue);
void
sgen_gray_object_free_queue_section (GrayQueueSection *section)
{
- HEAVY_STAT (gc_stats.gray_queue_section_free ++);
+ HEAVY_STAT (stat_gray_queue_section_free ++);
STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_FLOATING, GRAY_QUEUE_SECTION_STATE_FREED);
sgen_free_internal (section, INTERNAL_MEM_GRAY_QUEUE);
{
GrayQueueEntry entry = { obj, desc };
- HEAVY_STAT (gc_stats.gray_queue_enqueue_slow_path ++);
+ HEAVY_STAT (stat_gray_queue_enqueue_slow_path ++);
SGEN_ASSERT (9, obj, "enqueueing a null object");
//sgen_check_objref (obj);
{
GrayQueueEntry entry;
- HEAVY_STAT (gc_stats.gray_queue_dequeue_slow_path ++);
+ HEAVY_STAT (stat_gray_queue_dequeue_slow_path ++);
if (sgen_gray_object_queue_is_empty (queue)) {
entry.obj = NULL;
unlock_section_queue (queue);
}
+void
+sgen_init_gray_queues (void)
+{
+#ifdef HEAVY_STATISTICS
+ mono_counters_register ("Gray Queue alloc section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_section_alloc);
+ mono_counters_register ("Gray Queue free section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_section_free);
+ mono_counters_register ("Gray Queue enqueue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_enqueue_fast_path);
+ mono_counters_register ("Gray Queue dequeue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_dequeue_fast_path);
+ mono_counters_register ("Gray Queue enqueue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_enqueue_slow_path);
+ mono_counters_register ("Gray Queue dequeue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_dequeue_slow_path);
+#endif
+}
#endif
#define GRAY_LAST_CURSOR_POSITION(s) ((s)->entries + SGEN_GRAY_QUEUE_SECTION_SIZE - 1)
#define GRAY_FIRST_CURSOR_POSITION(s) ((s)->entries)
+#ifdef HEAVY_STATISTICS
+extern unsigned long long stat_gray_queue_section_alloc;
+extern unsigned long long stat_gray_queue_section_free;
+extern unsigned long long stat_gray_queue_enqueue_fast_path;
+extern unsigned long long stat_gray_queue_dequeue_fast_path;
+extern unsigned long long stat_gray_queue_enqueue_slow_path;
+extern unsigned long long stat_gray_queue_dequeue_slow_path;
+#endif
+
+void sgen_init_gray_queues (void) MONO_INTERNAL;
+
void sgen_gray_object_enqueue (SgenGrayQueue *queue, char *obj, mword desc) MONO_INTERNAL;
GrayQueueEntry sgen_gray_object_dequeue (SgenGrayQueue *queue) MONO_INTERNAL;
GrayQueueSection* sgen_gray_object_dequeue_section (SgenGrayQueue *queue) MONO_INTERNAL;
} else {
GrayQueueEntry entry = { obj, desc };
- HEAVY_STAT (gc_stats.gray_queue_enqueue_fast_path ++);
+ HEAVY_STAT (stat_gray_queue_enqueue_fast_path ++);
*++queue->cursor = entry;
#ifdef SGEN_HEAVY_BINARY_PROTOCOL
*desc = entry.desc;
#else
if (!queue->first) {
- HEAVY_STAT (gc_stats.gray_queue_dequeue_fast_path ++);
+ HEAVY_STAT (stat_gray_queue_dequeue_fast_path ++);
*obj = NULL;
#ifdef SGEN_HEAVY_BINARY_PROTOCOL
*obj = entry.obj;
*desc = entry.desc;
} else {
- HEAVY_STAT (gc_stats.gray_queue_dequeue_fast_path ++);
+ HEAVY_STAT (stat_gray_queue_dequeue_fast_path ++);
entry = *queue->cursor--;
*obj = entry.obj;