Merge pull request #3528 from BrzVlad/fix-sgen-check-before-collections
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 8 Sep 2016 23:54:48 +0000 (02:54 +0300)
committerGitHub <noreply@github.com>
Thu, 8 Sep 2016 23:54:48 +0000 (02:54 +0300)
[sgen] Fix sgen debug flags

1  2 
mono/sgen/sgen-marksweep.c

index a215c44502c12b226359ff45fddafe511f569374,d29b91d37015dfbdf727caff0bed4016d99d3843..d996be700ed98c014ff39b94fb94630f3d26af22
@@@ -872,6 -872,7 +872,7 @@@ major_iterate_objects (IterateObjectsFl
        gboolean pinned = flags & ITERATE_OBJECTS_PINNED;
        MSBlockInfo *block;
  
+       /* No actual sweeping will take place if we are in the middle of a major collection. */
        major_finish_sweep_checking ();
        FOREACH_BLOCK_NO_LOCK (block) {
                int count = MS_BLOCK_FREE / block->obj_size;
                        continue;
                if (!block->pinned && !non_pinned)
                        continue;
-               if (sweep && lazy_sweep) {
+               if (sweep && lazy_sweep && !block_is_swept_or_marking (block)) {
                        sweep_block (block);
                        SGEN_ASSERT (6, block->state == BLOCK_STATE_SWEPT, "Block must be swept after sweeping");
                }
  
                for (i = 0; i < count; ++i) {
                        void **obj = (void**) MS_BLOCK_OBJ (block, i);
-                       /*
-                        * We've finished sweep checking, but if we're sweeping lazily and
-                        * the flags don't require us to sweep, the block might still need
-                        * sweeping.  In that case, we need to consult the mark bits to tell
-                        * us whether an object slot is live.
-                        */
-                       if (!block_is_swept_or_marking (block)) {
-                               int word, bit;
-                               SGEN_ASSERT (6, !sweep && block->state == BLOCK_STATE_NEED_SWEEPING, "Has sweeping not finished?");
-                               MS_CALC_MARK_BIT (word, bit, obj);
-                               if (!MS_MARK_BIT (block, word, bit))
-                                       continue;
-                       }
                        if (MS_OBJ_ALLOCED (obj, block))
                                callback ((GCObject*)obj, block->obj_size, data);
                }
@@@ -1138,7 -1126,10 +1126,7 @@@ major_get_and_reset_num_major_objects_m
  
  /* gcc 4.2.1 from xcode4 crashes on sgen_card_table_get_card_address () when this is enabled */
  #if defined(PLATFORM_MACOSX)
 -#define GCC_VERSION (__GNUC__ * 10000 \
 -                               + __GNUC_MINOR__ * 100 \
 -                               + __GNUC_PATCHLEVEL__)
 -#if GCC_VERSION <= 40300
 +#if MONO_GNUC_VERSION <= 40300
  #undef PREFETCH_CARDS
  #endif
  #endif