+static void checkGeneration (generation *gen,
+ rtsBool after_major_gc USED_IF_THREADS)
+{
+ nat n;
+ gen_workspace *ws;
+
+ ASSERT(countBlocks(gen->blocks) == gen->n_blocks);
+ ASSERT(countBlocks(gen->large_objects) == gen->n_large_blocks);
+
+#if defined(THREADED_RTS)
+ // heap sanity checking doesn't work with SMP, because we can't
+ // zero the slop (see Updates.h). However, we can sanity-check
+ // the heap after a major gc, because there is no slop.
+ if (!after_major_gc) return;
+#endif
+
+ checkHeapChain(gen->blocks);
+
+ for (n = 0; n < n_capabilities; n++) {
+ ws = &gc_threads[n]->gens[gen->no];
+ checkHeapChain(ws->todo_bd);
+ checkHeapChain(ws->part_list);
+ checkHeapChain(ws->scavd_list);
+ }
+
+ checkLargeObjects(gen->large_objects);
+}