@@ -458,6 +458,11 @@ INTERNAL_HIDDEN iso_alloc_zone_t *_iso_new_zone(size_t size, bool internal, int3
458458 new_zone -> is_full = false;
459459 new_zone -> chunk_size = size ;
460460
461+ /* We compute this now so that in the hot path we can
462+ * perform a fast bit shift:
463+ * chunk_number = (chunk_offset >> zone->chunk_size_pow2)
464+ * vs a slow division:
465+ * chunk_number = (chunk_offset / zone->chunk_size) */
461466 new_zone -> chunk_size_pow2 = _log2 (new_zone -> chunk_size );
462467 new_zone -> chunk_count = (ZONE_USER_SIZE >> new_zone -> chunk_size_pow2 );
463468
@@ -747,8 +752,8 @@ INTERNAL_HIDDEN bit_slot_t get_next_free_bit_slot(iso_alloc_zone_t *zone) {
747752 return zone -> next_free_bit_slot ;
748753}
749754
750- /* Iterate through a zone bitmap a qword at a time
751- * looking for empty holes (i.e. slot == 0) */
755+ /* Iterate through a zone bitmap a qword at
756+ * a time looking for empty slots */
752757INTERNAL_HIDDEN bit_slot_t iso_scan_zone_free_slot (iso_alloc_zone_t * zone ) {
753758 const bitmap_index_t * bm = (bitmap_index_t * ) zone -> bitmap_start ;
754759
@@ -1409,7 +1414,7 @@ INTERNAL_HIDDEN void iso_free_chunk_from_zone(iso_alloc_zone_t *zone, void *rest
14091414 p , zone -> index , zone -> chunk_size , (chunk_offset & (zone -> chunk_size - 1 )));
14101415 }
14111416
1412- if (UNLIKELY (dwords_to_bit_slot > ( zone -> bitmap_size >> 3 ) )) {
1417+ if (UNLIKELY (dwords_to_bit_slot > zone -> max_bitmap_idx )) {
14131418 LOG_AND_ABORT ("Cannot calculate this chunks location in the bitmap 0x%p" , p );
14141419 }
14151420
0 commit comments