Add debug check outside of the loop in hpa_alloc_batch.

This optimizes the whole loop away for non-debug builds.
This commit is contained in:
Stan Angelov 2021-09-30 17:37:59 -07:00 committed by Qi Wang
parent cf9724531a
commit 912324a1ac

View File

@ -733,17 +733,25 @@ hpa_alloc_batch(tsdn_t *tsdn, pai_t *self, size_t size, size_t nallocs,
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn), witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
WITNESS_RANK_CORE, 0); WITNESS_RANK_CORE, 0);
edata_t *edata; /*
ql_foreach(edata, &results->head, ql_link_active) { * Guard the sanity checks with config_debug because the loop cannot be
emap_assert_mapped(tsdn, shard->emap, edata); * proven non-circular by the compiler, even if everything within the
assert(edata_pai_get(edata) == EXTENT_PAI_HPA); * loop is optimized away.
assert(edata_state_get(edata) == extent_state_active); */
assert(edata_arena_ind_get(edata) == shard->ind); if (config_debug) {
assert(edata_szind_get_maybe_invalid(edata) == SC_NSIZES); edata_t *edata;
assert(!edata_slab_get(edata)); ql_foreach(edata, &results->head, ql_link_active) {
assert(edata_committed_get(edata)); emap_assert_mapped(tsdn, shard->emap, edata);
assert(edata_base_get(edata) == edata_addr_get(edata)); assert(edata_pai_get(edata) == EXTENT_PAI_HPA);
assert(edata_base_get(edata) != NULL); assert(edata_state_get(edata) == extent_state_active);
assert(edata_arena_ind_get(edata) == shard->ind);
assert(edata_szind_get_maybe_invalid(edata) ==
SC_NSIZES);
assert(!edata_slab_get(edata));
assert(edata_committed_get(edata));
assert(edata_base_get(edata) == edata_addr_get(edata));
assert(edata_base_get(edata) != NULL);
}
} }
return nsuccess; return nsuccess;
} }