Эх сурвалжийг харах

Fix total free size calculation during reclaiming objects (#2510)

Xu Jun 2 жил өмнө
parent
commit
6de889b732

+ 2 - 8
core/shared/mem-alloc/ems/ems_gc.c

@@ -69,10 +69,7 @@ sweep_instance_heap(gc_heap_t *heap)
     hmu_type_t ut;
     hmu_type_t ut;
     gc_size_t size;
     gc_size_t size;
     int i, lsize;
     int i, lsize;
-
-#if GC_STAT_DATA != 0
     gc_size_t tot_free = 0;
     gc_size_t tot_free = 0;
-#endif
 
 
     bh_assert(gci_is_heap_valid(heap));
     bh_assert(gci_is_heap_valid(heap));
 
 
@@ -116,9 +113,7 @@ sweep_instance_heap(gc_heap_t *heap)
         else {
         else {
             /* current block is still live */
             /* current block is still live */
             if (last) {
             if (last) {
-#if GC_STAT_DATA != 0
                 tot_free += (char *)cur - (char *)last;
                 tot_free += (char *)cur - (char *)last;
-#endif
                 gci_add_fc(heap, last, (char *)cur - (char *)last);
                 gci_add_fc(heap, last, (char *)cur - (char *)last);
                 hmu_mark_pinuse(last);
                 hmu_mark_pinuse(last);
                 last = NULL;
                 last = NULL;
@@ -136,16 +131,15 @@ sweep_instance_heap(gc_heap_t *heap)
     bh_assert(cur == end);
     bh_assert(cur == end);
 
 
     if (last) {
     if (last) {
-#if GC_STAT_DATA != 0
         tot_free += (char *)cur - (char *)last;
         tot_free += (char *)cur - (char *)last;
-#endif
         gci_add_fc(heap, last, (char *)cur - (char *)last);
         gci_add_fc(heap, last, (char *)cur - (char *)last);
         hmu_mark_pinuse(last);
         hmu_mark_pinuse(last);
     }
     }
 
 
+    heap->total_free_size = tot_free;
+
 #if GC_STAT_DATA != 0
 #if GC_STAT_DATA != 0
     heap->total_gc_count++;
     heap->total_gc_count++;
-    heap->total_free_size = tot_free;
     if ((heap->current_size - tot_free) > heap->highmark_size)
     if ((heap->current_size - tot_free) > heap->highmark_size)
         heap->highmark_size = heap->current_size - tot_free;
         heap->highmark_size = heap->current_size - tot_free;