Working on precise.
authorNathan Ricci <naricc@microsoft.com>
Wed, 21 Aug 2019 19:51:45 +0000 (15:51 -0400)
committerNathan Ricci <naricc@microsoft.com>
Wed, 21 Aug 2019 19:51:45 +0000 (15:51 -0400)
Commit migrated from https://github.com/mono/mono/commit/65360da5d9801c35c7b77b7b573d64e2f907723d

src/mono/mono/metadata/sgen-mono.c
src/mono/mono/sgen/sgen-alloc.c
src/mono/mono/sgen/sgen-gc.c
src/mono/mono/sgen/sgen-gc.h

index 7ed40c7..32e54f0 100644 (file)
@@ -2518,9 +2518,20 @@ mono_gc_get_allocated_bytes_for_current_thread (void)
 guint64
 mono_gc_get_total_allocated_bytes(MonoBoolean precise)
 {
-       return total_bytes_allocated;
+       if (precise) 
+       {
+               mono_threads_begin_global_suspend();
+               guint64 count = sgen_updated_allocation_count();
+               mono_threads_end_global_suspend();
+               return count;
+       }
+       
+       return total_bytes_allocated
 }
 
+
+
+
 gpointer
 sgen_client_default_metadata (void)
 {
index 73688cd..b471ccb 100644 (file)
@@ -523,6 +523,19 @@ sgen_clear_tlabs (void)
        sgen_set_total_bytes_allocated(total_bytes_allocated_globally);
 } 
 
+void sgen_update_allocation_count (void)
+{
+       guint64 total_bytes_allocated_globally = 0;
+
+       FOREACH_THREAD_ALL (info) {
+               total_bytes_allocated_globally += info->tlab_next - info->tlab_start;
+               total_bytes_allocated_globally += info->total_bytes_allocated;
+       } FOREACH_THREAD_END
+
+       sgen_set_total_bytes_allocated(total_bytes_allocated_globally);
+}
+
+
 void
 sgen_init_allocator (void)
 {
index 1572800..2e53802 100644 (file)
@@ -3917,4 +3917,9 @@ sgen_check_canary_for_object (gpointer addr)
        }
 }
 
+guint64 sgen_get_precise_allocation_count (void)
+{
+       
+}
+
 #endif /* HAVE_SGEN_GC */
index c201b52..9276a8e 100644 (file)
@@ -1144,6 +1144,8 @@ gboolean sgen_nursery_canaries_enabled (void);
 void
 sgen_check_canary_for_object (gpointer addr);
 
+guint64 sgen_get_precise_allocation_count (void);
+
 #define CHECK_CANARY_FOR_OBJECT(addr, ignored) \
        (sgen_nursery_canaries_enabled () ? sgen_check_canary_for_object (addr) : (void)0)