[sgen] Performance improvement for ms_block_size computations
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 22 Jun 2017 20:15:53 +0000 (23:15 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Thu, 22 Jun 2017 22:14:27 +0000 (01:14 +0300)
This reduces regressions for switching from MS_BLOCK_SIZE compile time constant
to ms_block_size variable by 85% on the tests where this was showing up. In the
future we should implement a block allocator, which would, amongst other benefits,
enable us to remove the block-size/page-size dependency.

mono/sgen/sgen-marksweep.c

index e496288a2e718cbc302d8fd52a7c57284e0c7c28..7711679e3cb8239c3b06fdccf20f5c57cb84a82b 100644 (file)
@@ -1409,10 +1409,10 @@ static inline void
 sweep_block_for_size (MSBlockInfo *block, int count, int obj_size)
 {
        int obj_index;
+       void *obj = MS_BLOCK_OBJ_FOR_SIZE (block, 0, obj_size);
 
-       for (obj_index = 0; obj_index < count; ++obj_index) {
+       for (obj_index = 0; obj_index < count; ++obj_index, obj = (void*)((mword)obj + obj_size)) {
                int word, bit;
-               void *obj = MS_BLOCK_OBJ_FOR_SIZE (block, obj_index, obj_size);
 
                MS_CALC_MARK_BIT (word, bit, obj);
                if (MS_MARK_BIT (block, word, bit)) {